Fuse Loops to Reduce Overhead and Improve Performance
- Loops must be adjacent. That is, you cannot have a statement Siwith side-effects such that Siexecutes after Ljand before Lk.
- Each loop must have a single-entry point and a single exit point. For example, loops that contain break statements are not considered for fusion.
- Loops must have no negative-distance dependencies. That is, for loops Ljand Lkwhere Ljis defined before Lk, iterationmof loop Lkdoes not depend on values calculated in iterationm+n(wheren>0) of loop Lj.
Automatic Loop Fusion
- One of the two loops, but not both, is annotated with the ivdep attribute.
- One of the two loops, but not both, contains stall-free logic.