<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 - Incorrect fold of ashr+xor -> lshr w/ vectors"
href="https://bugs.llvm.org/show_bug.cgi?id=43665">43665</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect fold of ashr+xor -> lshr w/ vectors
</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, regehr@cs.utah.edu, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>The following test in Transforms/InstCombine/vector-xor.ll shows an incorrect
transformation. I reproduce it here with a smaller vector size & bitwidth to
make it easier to understand.
The issue is that "undef >> 4" is "ssss.sxyz" (s = sign bit), while "undef u>>
4" is "0000.xyzw", so it can produce the value "0000.1000", while ashr cannot.
See details below:
define <2 x i8> @test_v4i32_not_ashr_negative_const_undef(<2 x i8> %a0) {
%1 = ashr <2 x i8> { 251, undef }, %a0
%2 = xor <2 x i8> { 255, 255 }, %1
ret <2 x i8> %2
}
=>
define <2 x i8> @test_v4i32_not_ashr_negative_const_undef(<2 x i8> %a0) {
%1 = lshr <2 x i8> { 4, undef }, %a0
ret <2 x i8> %1
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
<2 x i8> %a0 = < #x00 (0), #x04 (4) >
Source:
<2 x i8> %1 = < #xfb (251, -5), #x00 (0) [based on undef value] >
<2 x i8> %2 = < #x04 (4), #xff (255, -1) >
Target:
<2 x i8> %1 = < #x04 (4), #x08 (8) >
Source value: < #x04 (4), #xff (255, -1) >
Target value: < #x04 (4), #x08 (8) ></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>