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: [email protected]
ReportedBy: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs