llvm.org GIT mirror llvm / 405e645
[X86][SSE] Add support for VZEXT constant folding git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265646 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 3 years ago
4 changed file(s) with 21 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2960829608 const X86Subtarget &Subtarget) {
2960929609 SDLoc DL(N);
2961029610 MVT VT = N->getSimpleValueType(0);
29611 MVT SVT = VT.getVectorElementType();
2961129612 SDValue Op = N->getOperand(0);
2961229613 MVT OpVT = Op.getSimpleValueType();
2961329614 MVT OpEltVT = OpVT.getVectorElementType();
2961429615 unsigned InputBits = OpEltVT.getSizeInBits() * VT.getVectorNumElements();
29616
29617 // Perform any constant folding.
29618 if (ISD::isBuildVectorOfConstantSDNodes(Op.getNode())) {
29619 SmallVector Vals;
29620 for (int i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
29621 SDValue OpElt = Op.getOperand(i);
29622 if (OpElt.getOpcode() == ISD::UNDEF) {
29623 Vals.push_back(DAG.getUNDEF(SVT));
29624 continue;
29625 }
29626 APInt Cst = cast(OpElt.getNode())->getAPIntValue();
29627 assert(Cst.getBitWidth() == OpEltVT.getSizeInBits());
29628 Cst = Cst.zextOrTrunc(SVT.getSizeInBits());
29629 Vals.push_back(DAG.getConstant(Cst, DL, SVT));
29630 }
29631 return DAG.getNode(ISD::BUILD_VECTOR, DL, VT, Vals);
29632 }
2961529633
2961629634 // (vzext (bitcast (vzext (x)) -> (vzext x)
2961729635 SDValue V = peekThroughBitcasts(Op);
989989 ; AVX2: # BB#0:
990990 ; AVX2-NEXT: vpmullw {{.*}}(%rip), %xmm0, %xmm1
991991 ; AVX2-NEXT: vpmovzxwd {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero
992 ; AVX2-NEXT: vpmovzxwd {{.*#+}} ymm2 = mem[0],zero,mem[1],zero,mem[2],zero,mem[3],zero,mem[4],zero,mem[5],zero,mem[6],zero,mem[7],zero
993 ; AVX2-NEXT: vpsrlvd %ymm2, %ymm0, %ymm0
992 ; AVX2-NEXT: vpsrlvd {{.*}}(%rip), %ymm0, %ymm0
994993 ; AVX2-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1,4,5,8,9,12,13],zero,zero,zero,zero,zero,zero,zero,zero,ymm0[16,17,20,21,24,25,28,29],zero,zero,zero,zero,zero,zero,zero,zero
995994 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
996995 ; AVX2-NEXT: vpor %xmm0, %xmm1, %xmm0
12141214 ; AVX2-LABEL: constant_shift_v8i16:
12151215 ; AVX2: # BB#0:
12161216 ; AVX2-NEXT: vpmovsxwd %xmm0, %ymm0
1217 ; AVX2-NEXT: vpmovzxwd {{.*#+}} ymm1 = mem[0],zero,mem[1],zero,mem[2],zero,mem[3],zero,mem[4],zero,mem[5],zero,mem[6],zero,mem[7],zero
1218 ; AVX2-NEXT: vpsravd %ymm1, %ymm0, %ymm0
1217 ; AVX2-NEXT: vpsravd {{.*}}(%rip), %ymm0, %ymm0
12191218 ; AVX2-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1,4,5,8,9,12,13],zero,zero,zero,zero,zero,zero,zero,zero,ymm0[16,17,20,21,24,25,28,29],zero,zero,zero,zero,zero,zero,zero,zero
12201219 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
12211220 ; AVX2-NEXT: vzeroupper
948948 ; AVX2-LABEL: constant_shift_v8i16:
949949 ; AVX2: # BB#0:
950950 ; AVX2-NEXT: vpmovzxwd {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero
951 ; AVX2-NEXT: vpmovzxwd {{.*#+}} ymm1 = mem[0],zero,mem[1],zero,mem[2],zero,mem[3],zero,mem[4],zero,mem[5],zero,mem[6],zero,mem[7],zero
952 ; AVX2-NEXT: vpsrlvd %ymm1, %ymm0, %ymm0
951 ; AVX2-NEXT: vpsrlvd {{.*}}(%rip), %ymm0, %ymm0
953952 ; AVX2-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1,4,5,8,9,12,13],zero,zero,zero,zero,zero,zero,zero,zero,ymm0[16,17,20,21,24,25,28,29],zero,zero,zero,zero,zero,zero,zero,zero
954953 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
955954 ; AVX2-NEXT: vzeroupper