[llvm] r359669 - [X86][SSE] Move extract_subvector(pshufb) fold to SimplifyDemandedVectorEltsForTargetNode
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed May 1 03:58:38 PDT 2019
Author: rksimon
Date: Wed May 1 03:58:38 2019
New Revision: 359669
URL: http://llvm.org/viewvc/llvm-project?rev=359669&view=rev
Log:
[X86][SSE] Move extract_subvector(pshufb) fold to SimplifyDemandedVectorEltsForTargetNode
This lets us hit more cases than combineExtractSubvector and allows us reuse more code.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/var-permute-128.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=359669&r1=359668&r2=359669&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed May 1 03:58:38 2019
@@ -33406,6 +33406,9 @@ bool X86TargetLowering::SimplifyDemanded
// TODO: Handle 512-bit -> 128/256-bit ops as well.
if (VT.is256BitVector() && DemandedElts.lshr(NumElts / 2) == 0) {
switch (Opc) {
+ // Target Shuffles.
+ case X86ISD::PSHUFB:
+ // Horizontal Ops.
case X86ISD::HADD:
case X86ISD::HSUB:
case X86ISD::FHADD:
@@ -42817,18 +42820,6 @@ static SDValue combineExtractSubvector(S
InVec.getOperand(0).getSimpleValueType().is128BitVector()) {
return DAG.getNode(InOpcode, SDLoc(N), VT, InVec.getOperand(0));
}
- if (InOpcode == ISD::BITCAST) {
- // TODO - do this for target shuffles in general.
- SDValue InVecBC = peekThroughOneUseBitcasts(InVec);
- if (InVecBC.getOpcode() == X86ISD::PSHUFB && VT.is128BitVector()) {
- SDLoc DL(N);
- SDValue SubPSHUFB =
- DAG.getNode(X86ISD::PSHUFB, DL, MVT::v16i8,
- extract128BitVector(InVecBC.getOperand(0), 0, DAG, DL),
- extract128BitVector(InVecBC.getOperand(1), 0, DAG, DL));
- return DAG.getBitcast(VT, SubPSHUFB);
- }
- }
}
return SDValue();
Modified: llvm/trunk/test/CodeGen/X86/var-permute-128.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/var-permute-128.ll?rev=359669&r1=359668&r2=359669&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/var-permute-128.ll (original)
+++ llvm/trunk/test/CodeGen/X86/var-permute-128.ll Wed May 1 03:58:38 2019
@@ -1027,13 +1027,11 @@ define <16 x i8> @var_shuffle_v16i8_from
; AVX2-LABEL: var_shuffle_v16i8_from_v32i8_v16i8:
; AVX2: # %bb.0:
; AVX2-NEXT: # kill: def $xmm1 killed $xmm1 def $ymm1
-; AVX2-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm2
-; AVX2-NEXT: vpshufb %ymm1, %ymm2, %ymm2
-; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm3
-; AVX2-NEXT: vpblendd {{.*#+}} ymm0 = ymm3[0,1,2,3],ymm0[4,5,6,7]
-; AVX2-NEXT: vpshufb %ymm1, %ymm0, %ymm0
+; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2
+; AVX2-NEXT: vpshufb %xmm1, %xmm2, %xmm2
+; AVX2-NEXT: vpshufb %xmm1, %xmm0, %xmm0
; AVX2-NEXT: vpcmpgtb {{.*}}(%rip), %ymm1, %ymm1
-; AVX2-NEXT: vpblendvb %ymm1, %ymm0, %ymm2, %ymm0
+; AVX2-NEXT: vpblendvb %ymm1, %ymm2, %ymm0, %ymm0
; AVX2-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
; AVX2-NEXT: vzeroupper
; AVX2-NEXT: retq
@@ -1041,13 +1039,11 @@ define <16 x i8> @var_shuffle_v16i8_from
; AVX512-LABEL: var_shuffle_v16i8_from_v32i8_v16i8:
; AVX512: # %bb.0:
; AVX512-NEXT: # kill: def $xmm1 killed $xmm1 def $ymm1
-; AVX512-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm2
-; AVX512-NEXT: vpshufb %ymm1, %ymm2, %ymm2
-; AVX512-NEXT: vextracti128 $1, %ymm0, %xmm3
-; AVX512-NEXT: vpblendd {{.*#+}} ymm0 = ymm3[0,1,2,3],ymm0[4,5,6,7]
-; AVX512-NEXT: vpshufb %ymm1, %ymm0, %ymm0
+; AVX512-NEXT: vextracti128 $1, %ymm0, %xmm2
+; AVX512-NEXT: vpshufb %xmm1, %xmm2, %xmm2
+; AVX512-NEXT: vpshufb %xmm1, %xmm0, %xmm0
; AVX512-NEXT: vpcmpgtb {{.*}}(%rip), %ymm1, %ymm1
-; AVX512-NEXT: vpblendvb %ymm1, %ymm0, %ymm2, %ymm0
+; AVX512-NEXT: vpblendvb %ymm1, %ymm2, %ymm0, %ymm0
; AVX512-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
; AVX512-NEXT: vzeroupper
; AVX512-NEXT: retq
@@ -1055,13 +1051,12 @@ define <16 x i8> @var_shuffle_v16i8_from
; AVX512VLBW-LABEL: var_shuffle_v16i8_from_v32i8_v16i8:
; AVX512VLBW: # %bb.0:
; AVX512VLBW-NEXT: # kill: def $xmm1 killed $xmm1 def $ymm1
-; AVX512VLBW-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm2
-; AVX512VLBW-NEXT: vpshufb %ymm1, %ymm2, %ymm2
-; AVX512VLBW-NEXT: vextracti128 $1, %ymm0, %xmm3
-; AVX512VLBW-NEXT: vpblendd {{.*#+}} ymm0 = ymm3[0,1,2,3],ymm0[4,5,6,7]
+; AVX512VLBW-NEXT: vextracti128 $1, %ymm0, %xmm2
+; AVX512VLBW-NEXT: vpshufb %xmm1, %xmm2, %xmm2
+; AVX512VLBW-NEXT: vpshufb %xmm1, %xmm0, %xmm0
; AVX512VLBW-NEXT: vpcmpgtb {{.*}}(%rip), %ymm1, %k1
-; AVX512VLBW-NEXT: vpshufb %ymm1, %ymm0, %ymm2 {%k1}
-; AVX512VLBW-NEXT: vmovdqa %xmm2, %xmm0
+; AVX512VLBW-NEXT: vmovdqu8 %ymm2, %ymm0 {%k1}
+; AVX512VLBW-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
; AVX512VLBW-NEXT: vzeroupper
; AVX512VLBW-NEXT: retq
;
More information about the llvm-commits
mailing list