<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: incorrect select fast-math folds"
href="https://bugs.llvm.org/show_bug.cgi?id=50281">50281</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>InstCombine: incorrect select fast-math folds
</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>lebedev.ri@gmail.com, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>Alive2 reports a few incorrect optimizations around select w/ fast-math in
Transforms/InstCombine/minmax-fp.ll:
-----------------------------------------
nsz allows the output to be +0/-0 non-deterministically. In this example, the
source always returns +0 and the target may return +0 or -0. The select in src
would need nsz as well:
define <2 x float> @fsub_fmax(<2 x float> %x, <2 x float> %y) {
%n1 = fsub <2 x float> { -0.000000, -0.000000 }, %x
%n2 = fsub <2 x float> { -0.000000, -0.000000 }, %y
%cond = fcmp nnan nsz uge <2 x float> %n1, %n2
%max = select <2 x i1> %cond, <2 x float> %n1, <2 x float> %n2
ret <2 x float> %max
}
=>
define <2 x float> @fsub_fmax(<2 x float> %x, <2 x float> %y) {
%cond.inv = fcmp nnan nsz ogt <2 x float> %x, %y
%1 = select nnan nsz <2 x i1> %cond.inv, <2 x float> %y, <2 x float> %x
%max = fneg <2 x float> %1
ret <2 x float> %max
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
<2 x float> %x = < poison, #x80000000 (-0.0) >
<2 x float> %y = < poison, #x00800001 (0.000000000000?) >
Source:
<2 x float> %n1 = < poison, #x00000000 (+0.0) >
<2 x float> %n2 = < poison, #x80800001 (-0.000000000000?) >
<2 x i1> %cond = < poison, #x1 (1) >
<2 x float> %max = < poison, #x00000000 (+0.0) >
Target:
<2 x i1> %cond.inv = < poison, #x0 (0) >
<2 x float> %1 = < poison, #x00000000 (+0.0) >
<2 x float> %max = < poison, #x80000000 (-0.0) >
Source value: < poison, #x00000000 (+0.0) >
Target value: < poison, #x80000000 (-0.0) >
-----------------------------
select nnan only applies to the chosen operand (?). If that's the case then the
optimization below isn't correct for a NaN input. If nnan applies to both
select operands, then fptrunc_select_true_val_extra_use in fptrunc.ll is
incorrect.
define float @maxnum_ogt_fmf_on_select(float %a, float %b) {
%cond = fcmp ogt float %a, %b
%f = select nnan nsz i1 %cond, float %a, float %b
ret float %f
}
=>
define float @maxnum_ogt_fmf_on_select(float %a, float %b) {
%1 = fmax nnan nsz float %a, %b
ret float %1
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
float %a = NaN
float %b = #x20008b45 (0.000000000000?)
Source:
i1 %cond = #x0 (0)
float %f = #x20008b45 (0.000000000000?)
Target:
float %1 = poison
Source value: #x20008b45 (0.000000000000?)
Target value: poison</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>