https://bugs.llvm.org/show_bug.cgi?id=43840

            Bug ID: 43840
           Summary: Loop peeling is errneously not performed - only
                    considers inequality predicates
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Trivial example:

void init();
void sink();

void bad(int len) {
    for(int i = 0; i < len; i++) {
        if(i == 0) {
            init();
        }
        sink();
    }
}

It would make sense to peel the first iteration, so we no longer have
the always-false condition for the rest of the loop.
But the peeling does not happen!
https://godbolt.org/z/Y_wBgM

It does happen if *two* iterations should be peeled:
https://godbolt.org/z/RTf_QS

This appears to be an oversight: it only considers inequality comparisons,
it does not know how to deal with equality comparisons:
https://godbolt.org/z/1xmCKx

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to