<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 - Instcombine incorrectly transforms store i64 -> store double"
href="https://bugs.llvm.org/show_bug.cgi?id=45152">45152</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Instcombine incorrectly transforms store i64 -> store double
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>miscompilation
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>nunoplopes@sapo.pt
</td>
</tr>
<tr>
<th>CC</th>
<td>juneyoung.lee@sf.snu.ac.kr, llvm-bugs@lists.llvm.org, nikita.ppv@gmail.com, regehr@cs.utah.edu, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>The unit test "test/Transforms/InstCombine/bitcast-phi-uselistorder.ll" shows
an incorrect transformation from load+store i64 into load/store double. These
are not equivalent because NaN values can be canonicalized by the CPU so the
store double can write a different bit-pattern than store i64.
Alive2's counterexample:
@Q = global 8 bytes, align 8
define double @test(i1 %c, * %p) {
%entry:
br i1 %c, label %if, label %end
%if:
%__constexpr_0 = bitcast * @Q to *
%load = load i64, * %__constexpr_0, align 8
br label %end
%end:
%phi = phi i64 [ 0, %entry ], [ %load, %if ]
store i64 %phi, * %p, align 8
%cast = bitcast i64 %phi to double
ret double %cast
}
=>
@Q = global 8 bytes, align 8
define double @test(i1 %c, * %p) {
%entry:
br i1 %c, label %if, label %end
%if:
%load1 = load double, * @Q, align 8
br label %end
%end:
%0 = phi double [ 0.000000, %entry ], [ %load1, %if ]
%1 = bitcast * %p to *
store double %0, * %1, align 8
ret double %0
}
Transformation doesn't verify!
ERROR: Mismatch in memory
Example:
i1 %c = #x1 (1)
* %p = pointer(non-local, block_id=2, offset=64)
Source:
* %__constexpr_0 = pointer(non-local, block_id=1, offset=0)
i64 %load = #x7ff0000001000000 (9218868437244182528)
i64 %phi = #x7ff0000001000000 (9218868437244182528)
double %cast = NaN
Target:
double %load1 = NaN
double %0 = NaN
* %1 = pointer(non-local, block_id=2, offset=64)
Mismatch in pointer(non-local, block_id=2, offset=64)
Source value: #x7ff0000001000000
Target value: #x7ff0000000020000</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>