https://bugs.llvm.org/show_bug.cgi?id=32374
Bug ID: 32374
Summary: Loop Strength Reduction generating incorrect result
Product: new-bugs
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: a...@azul.com
CC: llvm-bugs@lists.llvm.org
When running loop strength reduce on an IR, it generates the incorrect result.
Source code snippet:
intarg = longarg = 0;
for (firstiv = 117; firstiv > 3; --firstiv) {
var = dummy_call();
}
for (secondiv = 6; secondiv < 126; secondiv++) {
intarg+= (secondiv * secondiv);
Test.iArrFld[secondiv + 1] -= (int)(--f1);
}
sum = intarg+ longarg+ firstiv + secondiv;
Here sum should be intarg + 0 + 3 + 126, where intarg = sum of squares from 6
to 125 (inclusive) [1]
Quick calculation shows sum = 659202
I will attached the original IR and LSR optimized IR for this code.
Reproduce the problem as:
lli test.ll
659202
opt -loop-reduce -S test.ll > testlsr.ll
lli testlsr.ll
659455
[1] FYI: Can use sum of squares of first n numbers to calculate the sum of (6*6
+ 7 *7 +.. + 125*125) as S(125) - S(5)
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs