Loop Unwinding - Disadvantages

Disadvantages

  • Increased program code size, which can be undesirable, particularly for embedded applications.
    • Can also cause an increase in instruction cache misses, which may adversely affect performance.
  • Unless performed transparently by an optimizing compiler, the code may become less readable.
  • If the code in the body of the loop involves function calls, it may not be possible to combine unrolling with inlining, since the increase in code size might be excessive. Thus there can be a trade-off between the two optimizations.
  • Possible increased register usage in a single iteration to store temporary variables, which may reduce performance (though much will depend on possible optimizations).
  • Apart from very small and simple codes, unrolled loops that contain any branches are even slower than recursions

Read more about this topic:  Loop Unwinding