[llvm-bugs] [Bug 46531] New: [X86][SSE] Failure to convert (x&1) bittest to a shift to drive a blendvps
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 1 09:18:10 PDT 2020
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: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200701/5b614c67/attachment.html>
More information about the llvm-bugs
mailing list