<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:aschwaighofer@apple.com" title="Arnold Schwaighofer <aschwaighofer@apple.com>"> <span class="fn">Arnold Schwaighofer</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - X86 CodeGen: Miscompile vector kernel"
href="http://llvm.org/bugs/show_bug.cgi?id=15467">bug 15467</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - X86 CodeGen: Miscompile vector kernel"
href="http://llvm.org/bugs/show_bug.cgi?id=15467#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - X86 CodeGen: Miscompile vector kernel"
href="http://llvm.org/bugs/show_bug.cgi?id=15467">bug 15467</a>
from <span class="vcard"><a class="email" href="mailto:aschwaighofer@apple.com" title="Arnold Schwaighofer <aschwaighofer@apple.com>"> <span class="fn">Arnold Schwaighofer</span></a>
</span></b>
<pre>Duh, I should be more careful with auto generated code :).
Thanks for taking a look!
Closing as not a bug.
(In reply to <a href="show_bug.cgi?id=15467#c1">comment #1</a>)
<span class="quote">> I don't see it's bug but an undefined behavior. X86 has 2 different shift
> behaviors, taking 32-bit integer as examples:
>
> * scalar shift (SAR/SHL/SRL), the shift amount will be masked 0x1F, as a
> result (x << 32) == (x << 0), (y << 33) == (y << 33)
> * vector shift (PSLL,PSRA,PSRL for immediate shift amount and
> PSLLV,PSRAV,PSRLV for varialble shift amount), the shift amount is maximized
> at 32, as a result (x << 32) == 0 and (y << 33) == 0
>
> As C doesn't define the behavior of shift when the shift amount is beyond
> the width of the operand type, both behaviors are valid.
>
> Back to the test reported in this bug. On AVX, there's no variable shift.
> The variable shift is emulated by multiplication. The shift amount is
> converted to (1 << ShAmt) though FP2INT trick. It follows the behavior of
> vector version of shift, i.e. if ShAmt > 31, the result will be 0.
>
> With the following change, you could ask it to following scalar version
> behavior. But, the fundamental question is which behavior is expected in a
> vectorized code.
>
> diff --git a/lib/Target/X86/X86ISelLowering.cpp
> b/lib/Target/X86/X86ISelLowering.cpp
> index b19f2f6..7b42424 100644
> --- a/lib/Target/X86/X86ISelLowering.cpp
> +++ b/lib/Target/X86/X86ISelLowering.cpp
> @@ -11608,6 +11608,7 @@ SDValue X86TargetLowering::LowerShift(SDValue Op,
> SelectionDAG &DAG) const {
> if (VT == MVT::v4i32 && Op->getOpcode() == ISD::SHL) {
> Op = DAG.getNode(ISD::SHL, dl, VT, Amt, DAG.getConstant(23, VT));
>
> + Op = DAG.getNode(ISD::AND, dl, VT, Op, DAG.getConstant(0x0f800000U,
> VT));
> Op = DAG.getNode(ISD::ADD, dl, VT, Op, DAG.getConstant(0x3f800000U,
> VT));
> Op = DAG.getNode(ISD::BITCAST, dl, MVT::v4f32, Op);
> Op = DAG.getNode(ISD::FP_TO_SINT, dl, VT, Op);</span ></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>