[LLVMbugs] [Bug 12110] New: Optimizer fails to fold one-iteration loop

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 28 05:36:13 PST 2012


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

             Bug #: 12110
           Summary: Optimizer fails to fold one-iteration loop
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: benny.kra at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This came up on llvmdev
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-February/047768.html


int main(int argc, char ** argv) {
  int lowerBound = argc;
  int upperBound = lowerBound;

  int i = lowerBound;

  int s = 0;
  while (i <= upperBound) {
    s += i;
    i++;
  }
  return s;
}


since lowerBound is equal to upperBound this loop has only one iteration and
can be folded to "return argc;"

While it's possible to solve this within InstSimplify, it would be much better
to make SCEV's backedge taken computation smart enough to deal with this case.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list