[LLVMbugs] [Bug 707] NEW: [loops] Should "unswitch" trivial conditions

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Feb 7 15:19:33 PST 2006


http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=707

           Summary: [loops] Should "unswitch" trivial conditions
           Product: libraries
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Loop Optimizer
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org


Consider this simple case:

void test(int N, int* P) {
  int i, j;
  for (j = 0; j < N; ++j)
    for (i = 0; i < N; ++i)
       P[i+j] = 0;
}

The inner loop does a comparison of N against 0 to see if it should enter the inner loop.  This test is 
invariant in the outer loop (and even shared) so it is hoisted.  Despite this, we still do the comparison 
each time through the outer loop.  If the comparison can't succeed, and if the outer loop does no other 
work, we should do a trivial unswitch on that value.

This is particularly important if the outer loop has many more iterations than the inner loop, such as in 
173.applu and other programs.

-Chris



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




More information about the llvm-bugs mailing list