https://bugs.llvm.org/show_bug.cgi?id=46531
Bug ID: 46531
Summary: [X86][SSE] Failure to convert (x&1) bittest to a shift
to drive a blendvps
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
https://c.godbolt.org/z/cvDB4B
#include <x86intrin.h>
inline unsigned opt(unsigned x, unsigned y) {
unsigned val = x | y;
if (y & 1) { val = x ^ y; }
return val;
}
void opt( unsigned * __restrict dst, const unsigned *x, const unsigned *y )
{
*dst++ = opt(*x++, *y++);
*dst++ = opt(*x++, *y++);
*dst++ = opt(*x++, *y++);
*dst++ = opt(*x++, *y++);
}
.LCPI0_0:
.long 1 # 0x1
opt:
vmovdqu (%rdx), %xmm1
vpbroadcastd .LCPI0_0(%rip), %xmm3 # xmm3 = [1,1,1,1]
vmovdqu (%rsi), %xmm0
vpxor %xmm4, %xmm4, %xmm4
vpand %xmm3, %xmm1, %xmm3
vpor %xmm0, %xmm1, %xmm2
vpxor %xmm0, %xmm1, %xmm0
vpcmpeqd %xmm4, %xmm3, %xmm3
vblendvps %xmm3, %xmm2, %xmm0, %xmm0
vmovups %xmm0, (%rdi)
retq
but we should be able to replace the vpcmpeqd(vpand(y, 1), 0) with vpslli(y,31)
to drive the vblendvps (with inverted selections):
opt:
vmovdqu (%rdx), %xmm1
vmovdqu (%rsi), %xmm0
vpslld $31, %xmm1, %xmm3
vpor %xmm0, %xmm1, %xmm2
vpxor %xmm0, %xmm1, %xmm0
vblendvps %xmm3, %xmm0, %xmm2, %xmm0
vmovups %xmm0, (%rdi)
retq
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs