From: Simon Pilgrim Date: Sat, 11 Feb 2017 22:47:06 +0000 (+0000) Subject: [X86][SSE] Use VSEXT/VZEXT constant folding for SIGN_EXTEND_VECTOR_INREG/ZERO_EXTEND_... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04a335bf92805086ce0a474cedfb850e3943d43c;p=llvm [X86][SSE] Use VSEXT/VZEXT constant folding for SIGN_EXTEND_VECTOR_INREG/ZERO_EXTEND_VECTOR_INREG Preparatory step for PR31712 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294874 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 474a8a60b9b..e7417b75ae7 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -1698,6 +1698,8 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, setTargetDAGCombine(ISD::ANY_EXTEND); setTargetDAGCombine(ISD::SIGN_EXTEND); setTargetDAGCombine(ISD::SIGN_EXTEND_INREG); + setTargetDAGCombine(ISD::SIGN_EXTEND_VECTOR_INREG); + setTargetDAGCombine(ISD::ZERO_EXTEND_VECTOR_INREG); setTargetDAGCombine(ISD::SINT_TO_FP); setTargetDAGCombine(ISD::UINT_TO_FP); setTargetDAGCombine(ISD::SETCC); @@ -34019,7 +34021,8 @@ static SDValue combineVSZext(SDNode *N, SelectionDAG &DAG, if (getTargetConstantBitsFromNode(Op, OpEltSizeInBits, UndefElts, EltBits)) { SmallBitVector Undefs(NumElts, false); SmallVector Vals(NumElts, APInt(EltSizeInBits, 0)); - bool IsZEXT = (Opcode == X86ISD::VZEXT); + bool IsZEXT = + (Opcode == X86ISD::VZEXT) || (Opcode == ISD::ZERO_EXTEND_VECTOR_INREG); for (unsigned i = 0; i != NumElts; ++i) { if (UndefElts[i]) { Undefs[i] = true; @@ -34311,6 +34314,8 @@ SDValue X86TargetLowering::PerformDAGCombine(SDNode *N, case X86ISD::VSHLI: case X86ISD::VSRAI: case X86ISD::VSRLI: return combineVectorShift(N, DAG, DCI, Subtarget); + case ISD::SIGN_EXTEND_VECTOR_INREG: + case ISD::ZERO_EXTEND_VECTOR_INREG: case X86ISD::VSEXT: case X86ISD::VZEXT: return combineVSZext(N, DAG, DCI, Subtarget); case X86ISD::PINSRB: diff --git a/test/CodeGen/X86/fold-vector-sext-zext.ll b/test/CodeGen/X86/fold-vector-sext-zext.ll index f6d1e2c60be..575bd5897e4 100644 --- a/test/CodeGen/X86/fold-vector-sext-zext.ll +++ b/test/CodeGen/X86/fold-vector-sext-zext.ll @@ -300,10 +300,9 @@ define <4 x i32> @test_zext_4i8_4i32_undef() { define <4 x i64> @test_zext_4i8_4i64_undef() { ; X32-LABEL: test_zext_4i8_4i64_undef: ; X32: # BB#0: -; X32-NEXT: vmovaps {{.*#+}} xmm0 = [255,0,255,0] +; X32-NEXT: vmovaps {{.*#+}} xmm0 = ; X32-NEXT: movl $2, %eax ; X32-NEXT: vmovd %eax, %xmm1 -; X32-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero ; X32-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0 ; X32-NEXT: retl ;