[llvm-bugs] [Bug 40318] New: [x86] try harder to reduce shuffle with zero operand
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 15 07:40:54 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40318
Bug ID: 40318
Summary: [x86] try harder to reduce shuffle with zero operand
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
As noted here:
https://reviews.llvm.org/D56281
...we should be able to do better than this:
define <8 x i16> @shift_zext(<8 x i16> %x) {
%r = shufflevector <8 x i16> %x, <8 x i16> zeroinitializer, <8 x i32> <i32 1,
i32 9, i32 10, i32 11, i32 undef, i32 undef, i32 undef, i32 undef>
ret <8 x i16> %r
}
$ llc -o - shufsse.ll
pxor %xmm1, %xmm1
punpcklwd %xmm0, %xmm1 ## xmm1 =
xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
pshufhw $232, %xmm1, %xmm0 ## xmm0 = xmm1[0,1,2,3,4,6,6,7]
pshufd $230, %xmm0, %xmm0 ## xmm0 = xmm0[2,1,2,3]
pshuflw $75, %xmm0, %xmm0 ## xmm0 = xmm0[3,2,0,1,4,5,6,7]
retq
Or an even worse example:
define <8 x i16> @shift_zext_worse
(<8 x i16> %x) {
%r = shufflevector <8 x i16> %x, <8 x i16> zeroinitializer, <8 x i32> <i32 2,
i32 9, i32 10, i32 11, i32 undef, i32 undef, i32 undef, i32 undef>
ret <8 x i16> %r
}
$ llc -o - shufsse.ll
pxor %xmm1, %xmm1
punpcklwd %xmm0, %xmm1 ## xmm1 =
xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
pshufd $39, %xmm1, %xmm0 ## xmm0 = xmm1[3,1,2,0]
pshuflw $232, %xmm0, %xmm0 ## xmm0 = xmm0[0,2,2,3,4,5,6,7]
pshufd $232, %xmm0, %xmm0 ## xmm0 = xmm0[0,2,2,3]
pshuflw $39, %xmm0, %xmm0 ## xmm0 = xmm0[3,1,2,0,4,5,6,7]
retq
----------------------------------------------------------------------------
When shuffling with a zero operand, we should try harder to use logical shifts?
In all cases, 2 opposing shifts can put zero elements into all lanes.
--
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/20190115/7105a9a8/attachment.html>
More information about the llvm-bugs
mailing list