<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 - [LoopVersioningLICM] wrong code"
href="https://bugs.llvm.org/show_bug.cgi?id=36589">36589</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LoopVersioningLICM] wrong code
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>paulsson@linux.vnet.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19994" name="attach_19994" title="reduced test case">attachment 19994</a> <a href="attachment.cgi?id=19994&action=edit" title="reduced test case">[details]</a></span>
reduced test case
It seems that passing -loop-versioning-licm produces wrong result with the
following reduced csmith program:
a[6];
int b = 5, c = 0, d = 0, f = 0, j = 0;
short e = 0, i = 0;
g[50];
*h = &f;
main() {
for (; c < 6; c++)
a[5] = c;
for (; e >= 0; e--) {
*h = 1;
d = 0;
for (; d <= 4; d++) {
g[e] = i;
g[d] = 80;
}
}
b = a[b ^ g[j]];
printf("checksum = %X\n", b);
}
The checksum becomes 0 instead of 5 (per 8 other compilations).
I added some extra printf statements like:
...
for (; d <= 4; d++) {
g[e] = i;
g[d] = 80;
}
}
printf("b = %d, g[0]=%d, ", b, g[0]);
int L = b ^ g[j];
printf ("L = %d ", L);
b = a[L];
printf("b = %d, j = %d ", b, j);
printf("checksum = %X\n", b);
}
and got
...
b = 5, g[0]=0, L = 5 b = 5, j = 0 checksum = 5
...
b = 5, g[0]=80, L = 85 b = 0, j = 0 checksum = 0
, which shows that g[0] is 80, and not 0 as it should be, since i and e are
constant 0.
A minimal opt line, and debug output:
bin/opt -mtriple=s390x-linux-gnu -mcpu=z13 tc_lv_licm.bc -o tc_lv_licm.opt.ll
-S -tbaa -scoped-noalias -loop-rotate -licm -loop-unroll -gvn -sccp -instcombin
e -globalopt -loop-versioning-licm -licm -debug-only=loop-versioning-licm
Loop: Loop at depth 1 containing:
%for.body4<header>,%for.body8.lr.ph,%for.body8.prol.preheader,%for.body8.prol,%for.body8.prol.loopexit.unr-lcssa,%for.body8.prol.loopexit,%for.body8.lr.ph.ne
w,%for.body8,%for.cond5.for.end14_crit_edge.unr-lcssa,%for.cond5.for.end14_crit_edge,%for.end14<latch><exiting>
Loop Versioning found to be beneficial
Loop: Loop at depth 1 containing: %for.body<header><latch><exiting>
LAA: Runtime check not found !!
Loop instructions not suitable for LoopVersioningLICM
Loop: Loop at depth 1 containing: %for.body.prol<header><latch><exiting>
Parallel loop is not worth versioning
Loop structure not suitable for LoopVersioningLICM
It seems then that it is only one loop that is handled.</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>