[PATCH] D30123: [InstCombine] shrink truncated splat shuffle
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 14:30:55 PST 2017
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.
LGTM, but you might want to look into the following...
define <8 x i16> @wide_splat1(<8 x i32> %x) {
%shuf = trunc <8 x i32> %x to <8 x i16>
%trunc = shufflevector <8 x i16> %shuf, <8 x i16> undef, <8 x i32> <i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2>
ret <8 x i16> %trunc
}
define <8 x i16> @wide_splat2(<8 x i32> %x) {
%trunc = shufflevector <8 x i32> %x, <8 x i32> undef, <8 x i32> <i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2>
%shuf = trunc <8 x i32> %trunc to <8 x i16>
ret <8 x i16> %shuf
}
llc output (x86-64, no SSSE3):
.text
.file "<stdin>"
.globl wide_splat1
.p2align 4, 0x90
.type wide_splat1, at function
wide_splat1: # @wide_splat1
.cfi_startproc
# BB#0:
pslld $16, %xmm1
psrad $16, %xmm1
pslld $16, %xmm0
psrad $16, %xmm0
packssdw %xmm1, %xmm0
pshuflw $170, %xmm0, %xmm0 # xmm0 = xmm0[2,2,2,2,4,5,6,7]
pshufd $80, %xmm0, %xmm0 # xmm0 = xmm0[0,0,1,1]
retq
.Lfunc_end0:
.size wide_splat1, .Lfunc_end0-wide_splat1
.cfi_endproc
.globl wide_splat2
.p2align 4, 0x90
.type wide_splat2, at function
wide_splat2: # @wide_splat2
.cfi_startproc
# BB#0:
pshufd $170, %xmm0, %xmm0 # xmm0 = xmm0[2,2,2,2]
pslld $16, %xmm0
psrad $16, %xmm0
packssdw %xmm0, %xmm0
retq
.Lfunc_end1:
.size wide_splat2, .Lfunc_end1-wide_splat2
.cfi_endproc
https://reviews.llvm.org/D30123
More information about the llvm-commits
mailing list