handle empty loops in new loop optimizations; fixes #1270