<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Loop Strength Reduction generating incorrect result"
href="https://bugs.llvm.org/show_bug.cgi?id=32374">32374</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Loop Strength Reduction generating incorrect result
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>anna@azul.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>