Prevent unrolling of non-nested loops

Otherwise, some loop nests with constant bounds are fully unrolled,
which leads to code burst.

As a side effect, cleanup the generated code.