<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 - Suboptimal int vector ugt setcc lowering"
href="https://bugs.llvm.org/show_bug.cgi?id=39859">39859</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Suboptimal int vector ugt setcc lowering
</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>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nikita.ppv@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>From <a href="https://github.com/rust-lang/rust/issues/56421">https://github.com/rust-lang/rust/issues/56421</a>, original code:
pub unsafe fn foo(x: __m128i, y: __m128i) -> __m128i {
let cmp = _mm_cmpeq_epi16(_mm_max_epu16(x, _mm_set1_epi16(0x100)), x);
_mm_blendv_epi8(x, y, cmp)
}
LLVM IR:
define void @foo(<2 x i64>* noalias nocapture sret dereferenceable(16), <2 x
i64>* noalias nocapture readonly dereferenceable(16) %x, <2 x i64>* noalias
nocapture readonly dereferenceable(16) %y) unnamed_addr {
start:
%1 = load <2 x i64>, <2 x i64>* %x, align 16
%2 = bitcast <2 x i64> %1 to <8 x i16>
%3 = icmp ugt <8 x i16> %2, <i16 255, i16 255, i16 255, i16 255, i16 255, i16
255, i16 255, i16 255>
%4 = sext <8 x i1> %3 to <8 x i16>
%5 = bitcast <2 x i64>* %y to <16 x i8>*
%6 = load <16 x i8>, <16 x i8>* %5, align 16
%7 = bitcast <2 x i64> %1 to <16 x i8>
%8 = bitcast <8 x i16> %4 to <16 x i8>
%9 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %7, <16 x i8> %6,
<16 x i8> %8)
%10 = bitcast <2 x i64>* %0 to <16 x i8>*
store <16 x i8> %9, <16 x i8>* %10, align 16
ret void
}
declare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>)
llc -mcpu=haswell gives:
vmovdqa (%rsi), %xmm0
vpminuw .LCPI0_0(%rip), %xmm0, %xmm1 # .LCPI0_0 is vector of 255s
vpcmpeqw %xmm1, %xmm0, %xmm1
vpcmpeqd %xmm2, %xmm2, %xmm2
vpxor %xmm2, %xmm1, %xmm1
vpblendvb %xmm1, (%rdx), %xmm0, %xmm0
movq %rdi, %rax
vmovdqa %xmm0, (%rdi)
retq
LowerVSETCC() lowers the ugt setcc as an inverted ule setcc (umin+pcmpeq).
However, in this case it would also be possible to instead adjust the constant
setcc operand by one and then lower the resulting uge setcc into umax+pcmpeq,
saving the invert and matching what the code originally intended to do.</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>