<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 - [MachineLICM] wrong code"
href="https://bugs.llvm.org/show_bug.cgi?id=36889">36889</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[MachineLICM] 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>Common Code Generator Code
</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=20117" name="attach_20117" title="reduced testcase (llc input)">attachment 20117</a> <a href="attachment.cgi?id=20117&action=edit" title="reduced testcase (llc input)">[details]</a></span>
reduced testcase (llc input)
It seems that "Re-commit: [MachineLICM] Add functions to MachineLICM to hoist
invariant stores" (4561f7d / r328326) is causing failures in internal test-runs
on SystemZ (CSmith).
I have reduced such a test case with creduce and analyzed it to a point where I
can see the error. It is clear to me that an illegal hoisting of a store has
been made, and the unreduced test case passes if I revert the commit.
Program:
a[6];
b = 15, c, d, e = -1L, f, h;
*g = &f;
main() {
for (; c < 6; c++)
a[1] = c;
int i = 14;
for (; d >= 0; d--) {
for (; e <= 0; e++)
*g = i;
int j = &i;
h = j;
i = 0;
b = a[b ^ f];
}
printf("checksum = %X\n", b);
}
The correct checksum is 5. With MachineLICM 0 is instead printed.
- a[1] becomes 5 in the first loop.
- b is initialized to 15.
- *g points to f, and gets value 14 in innermost loop.
- b ^ f (15 ^ 14) is 1, so b gets a[1], which is 5.
The incorrect LICM transformation is to move out the 'i = 0;' statement. If
that is made before the loop, then *g gets value 0 instead, and b ^ f does not
become 1.
Debug output:
Hoisting MVHI %stack.0.i, 0, 0 :: (store 4 into %ir.i, !tbaa !2)
Run line: bin/llc -mcpu=z13 -O3 wrong1.ll -o out.s</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>