From: Craig Topper Date: Wed, 18 Dec 2019 18:41:34 +0000 (-0800) Subject: [SelectionDAGBuilder] Use getConstant instead of getTargetConstant to build the offse... X-Git-Tag: llvmorg-11-init~1837 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfe316007fb8492535d697717c24ce72621a8d5e;p=platform%2Fupstream%2Fllvm.git [SelectionDAGBuilder] Use getConstant instead of getTargetConstant to build the offset for struct types in getUniformBase. getTargetConstant prevents any optimizations from operating on the value and basically says its already been iseled. But since we want the index to be in a register, this isn't true. Prior to this we were generating a vbroadcast with an immediate argument which is illegal and was flagged by the expensive checks bot. --- diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 735ac67..c69fe55 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4390,8 +4390,8 @@ static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index, } auto *CI = cast(C); Scale = DAG.getTargetConstant(1, SDB->getCurSDLoc(), TLI.getPointerTy(DL)); - Index = DAG.getTargetConstant(SL->getElementOffset(CI->getZExtValue()), - SDB->getCurSDLoc(), TLI.getPointerTy(DL)); + Index = DAG.getConstant(SL->getElementOffset(CI->getZExtValue()), + SDB->getCurSDLoc(), TLI.getPointerTy(DL)); } else { Scale = DAG.getTargetConstant( DL.getTypeAllocSize(GEP->getResultElementType()), diff --git a/llvm/test/CodeGen/X86/masked_gather.ll b/llvm/test/CodeGen/X86/masked_gather.ll index dd41009..7ea2cac 100644 --- a/llvm/test/CodeGen/X86/masked_gather.ll +++ b/llvm/test/CodeGen/X86/masked_gather.ll @@ -1725,13 +1725,14 @@ define <8 x i32> @gather_v8i32_v8i32(<8 x i32> %trigger) { ; AVX512-LABEL: gather_v8i32_v8i32: ; AVX512: # %bb.0: ; AVX512-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0 -; AVX512-NEXT: vptestnmd %zmm0, %zmm0, %k1 -; AVX512-NEXT: kshiftlw $8, %k1, %k0 -; AVX512-NEXT: kshiftrw $8, %k0, %k2 +; AVX512-NEXT: vptestnmd %zmm0, %zmm0, %k0 +; AVX512-NEXT: kshiftlw $8, %k0, %k0 +; AVX512-NEXT: kshiftrw $8, %k0, %k1 ; AVX512-NEXT: vpbroadcastd {{.*#+}} zmm0 = [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] +; AVX512-NEXT: kmovw %k1, %k2 ; AVX512-NEXT: vpgatherdd c(,%zmm0,4), %zmm1 {%k2} -; AVX512-NEXT: vpbroadcastq $28, %zmm0 -; AVX512-NEXT: vpgatherqd c(,%zmm0), %ymm2 {%k1} +; AVX512-NEXT: vpbroadcastd {{.*#+}} zmm0 = [28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28] +; AVX512-NEXT: vpgatherdd c(,%zmm0), %zmm2 {%k1} ; AVX512-NEXT: vpaddd %ymm2, %ymm2, %ymm0 ; AVX512-NEXT: vpaddd %ymm0, %ymm1, %ymm0 ; AVX512-NEXT: retq