<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 - [NewGVN] Seemingly incorrect transformation."
href="https://bugs.llvm.org/show_bug.cgi?id=36437">36437</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[NewGVN] Seemingly incorrect transformation.
</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=19900" name="attach_19900" title="reduced test case">attachment 19900</a> <a href="attachment.cgi?id=19900&action=edit" title="reduced test case">[details]</a></span>
reduced test case
I discovered a runtime error with csmith, which was tracked down to
-enable-newgvn. I have reduced the test case and it seems indeed that there is
something suspicious in the transformation of NewGVN:
*** IR Dump After MergedLoadStoreMotion ***
; Function Attrs: nounwind
define dso_local signext i32 @main() local_unnamed_addr #1 {
entry:
store i64 0, i64* @g_27, align 8, !tbaa !8
br label %for.body
for.body: ; preds = %entry, %land.end
%storemerge5 = phi i64 [ 0, %entry ], [ %inc3, %land.end ]
%0 = load i32, i32* @g_49, align 4, !tbaa !6
%tobool = icmp ne i32 %0, 0
%tobool1 = icmp ne i64 %storemerge5, 0
%or.cond = and i1 %tobool1, %tobool
br i1 %or.cond, label %land.rhs, label %land.end
* %tobool compares %0, which is a load from @g_49, which is stored to in loop
* %storemerge5 starts from 0 and is incremented by 1, so %tobool1 is false
first iteration, then true.
* %or.cond is the and both both comparisons. First iteration must be false, the
rest depends on %tobool.
-> transformed into: ( rest of loop unmodified) ->
*** IR Dump After Global Value Numbering ***
; Function Attrs: nounwind
define dso_local signext i32 @main() local_unnamed_addr #1 {
entry:
store i64 0, i64* @g_27, align 8, !tbaa !8
br label %for.body
for.body: ; preds = %entry, %land.end
%phiofops6 = phi i1 [ false, %entry ], [ true, %land.end ]
%phiofops = phi i1 [ false, %entry ], [ %tobool, %land.end ]
%storemerge5 = phi i64 [ 0, %entry ], [ %inc3, %land.end ]
%0 = load i32, i32* @g_49, align 4, !tbaa !6
%tobool = icmp ne i32 %0, 0
br i1 %phiofops, label %land.rhs, label %land.end
* First iteration: %phiofops is false, which is correct.
* Next iteration: %phiofops depends only on %tobol, which is correct, but this
seems to be %tobol of the *previous* iteration. This seems wrong, since @g_46
is stored to in the loop.
* %phiofops6 has no users!
---
/home/ijonpan/llvm/build/llvm-dev/bin/clang -O3 -march=z13 -o a.out -w
./creduced.i
./a.out
checksum = 0
/home/ijonpan/llvm/build/llvm-dev/bin/clang -O3 -march=z13 -o a.out -w
./creduced.i -mllvm -enable-newgvn
./a.out
checksum = 10000</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>