<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 - Miscompile with LoopLoadElim due to wrong store forwarding"
href="https://bugs.llvm.org/show_bug.cgi?id=49875">49875</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Miscompile with LoopLoadElim due to wrong store forwarding
</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>Windows NT
</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>max.kazantsev@azul.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Run: opt -loop-load-elim -S on the following test:
----------------------------------------------------------
define void @test(i32** %arg) {
bb:
%tmp = load i32*, i32** %arg, align 8
br label %bb1
bb1: ; preds = %bb1, %bb
%tmp2 = phi i64 [ %tmp7, %bb1 ], [ 1, %bb ]
%tmp3 = add nsw i64 %tmp2, -1
%tmp4 = getelementptr i32, i32* %tmp, i64 %tmp3
%tmp5 = load i32, i32* %tmp4, align 4
%tmp6 = getelementptr i32, i32* %tmp, i64 %tmp2
store i32 %tmp5, i32* %tmp6, align 4
%tmp7 = add nuw nsw i64 %tmp2, 1
%tmp8 = icmp ugt i64 %tmp2, 2
br i1 %tmp8, label %bb9, label %bb1
bb9: ; preds = %bb1
ret void
}
----------------------------------------------------------
The result will be like:
----------------------------------------------------------
define void @test(i32** %arg) {
bb:
%tmp = load i32*, i32** %arg, align 8
%load_initial = load i32, i32* %tmp, align 4
br label %bb1
bb1: ; preds = %bb1, %bb
%store_forwarded = phi i32 [ %load_initial, %bb ], [ %store_forwarded, %bb1 ]
%tmp2 = phi i64 [ %tmp7, %bb1 ], [ 1, %bb ]
%tmp3 = add nsw i64 %tmp2, -1
%tmp4 = getelementptr i32, i32* %tmp, i64 %tmp3
%tmp5 = load i32, i32* %tmp4, align 4
%tmp6 = getelementptr i32, i32* %tmp, i64 %tmp2
store i32 %store_forwarded, i32* %tmp6, align 4
%tmp7 = add nuw nsw i64 %tmp2, 1
%tmp8 = icmp ugt i64 %tmp2, 2
br i1 %tmp8, label %bb9, label %bb1
bb9: ; preds = %bb1
ret void
}
----------------------------------------------------------
This is a miscompile for the following reason: in the initial example we were
making something like arr[i] = arr[i - 1], and each stored value was different
(it was loaded from memory by inductive offset). After the transform, the
stored value %store_forwarded does not change.
It looks like a messy update of backedge value for %store_forwarded.</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>