<html>
<head>
<base href="https://llvm.org/bugs/" />
</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] bitcasts hinder simple vector logic ops"
href="https://llvm.org/bugs/show_bug.cgi?id=26702">26702</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[InstCombine] bitcasts hinder simple vector logic ops
</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>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</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>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>#include <xmmintrin.h>
// There are no 'less-than' or 'less-than-or-equal' instructions.
// So use 'not greater-than -1'.
__m128i is_negative(__m128i x) {
__m128i ones = _mm_set1_epi32(-1);
__m128i isposorzero = _mm_cmpgt_epi32(x, ones); // x > -1
__m128i isneg = _mm_xor_si128(isposorzero, ones); // not pos or zero
return isneg;
}
$ ./clang pcmp.c -O1 -mavx -S -o -
...
vpsrad $31, %xmm0, %xmm0
vpcmpeqd %xmm1, %xmm1, %xmm1
vpxor %xmm1, %xmm0, %xmm0
vpxor %xmm1, %xmm0, %xmm0
retq
------------------------------------------------------------------------------
The first problem seems to be in instcombine:
define <2 x i64> @is_negative(<2 x i64> %x) #0 {
entry:
%0 = bitcast <2 x i64> %x to <4 x i32>
%.lobit = ashr <4 x i32> %0, <i32 31, i32 31, i32 31, i32 31>
%.lobit.not = xor <4 x i32> %.lobit, <i32 -1, i32 -1, i32 -1, i32 -1>
%1 = bitcast <4 x i32> %.lobit.not to <2 x i64>
%xor.i = xor <2 x i64> %1, <i64 -1, i64 -1>
ret <2 x i64> %xor.i
}</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>