[LLVMbugs] [Bug 20812] New: Failure to reduce loop w/known exit conditions (pass ordering?)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 29 15:15:59 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20812

            Bug ID: 20812
           Summary: Failure to reduce loop w/known exit conditions (pass
                    ordering?)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: listmail at philipreames.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12961
  --> http://llvm.org/bugs/attachment.cgi?id=12961&action=edit
C++ source code for example

LLVM O3 will currently convert this loop into a single increment of "counter":
void test_return_high_gt() {
  for(int i = 0; i < 20; i++) {
    if( i > 10 ) return;
    counter++;
  }
}

But will not perform the same optimization on this loop:
int test_return_value_high_gt() {
  for(int i = 0; i < 20; i++) {
    if( i > 10 ) return 0;
    counter++;
  }
  return 1;
}

I have not analyzed this extensively, but I suspect this is a pass ordering
problem.  If I run the IR generated by Clang for the second example through
"opt -O3" twice, I get the exact same IR as in the first example.  

I've attached both the cpp example and the LL file generated by clang 3.4 w/O3.
 I used a recent TOT opt version for the pass ordering investigation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140829/f2329291/attachment.html>


More information about the llvm-bugs mailing list