From: Craig Topper Date: Sun, 8 Sep 2019 20:56:09 +0000 (+0000) Subject: [X86] Add a hack to combineVSelectWithAllOnesOrZeros to turn selects with two zero... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=978310581aecea9bfc225aa7ac2ff5c58e1205dd;p=llvm [X86] Add a hack to combineVSelectWithAllOnesOrZeros to turn selects with two zero/undef vector inputs into an all zeroes vector. If the two zero vectors have undefs in different places they won't get combined by simplifySelect. This fixes a regression from an earlier commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371351 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index db4738372da..c164da784e4 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -36503,6 +36503,15 @@ combineVSelectWithAllOnesOrZeros(SDNode *N, SelectionDAG &DAG, // get simplified at node creation time)? bool TValIsAllZeros = ISD::isBuildVectorAllZeros(LHS.getNode()); bool FValIsAllZeros = ISD::isBuildVectorAllZeros(RHS.getNode()); + + // If both inputs are 0/undef, create a complete zero vector. + // FIXME: As noted above this should be handled by DAGCombiner/getNode. + if (TValIsAllZeros && FValIsAllZeros) { + if (VT.isFloatingPoint()) + return DAG.getConstantFP(0.0, DL, VT); + return DAG.getConstant(0, DL, VT); + } + if (TValIsAllZeros && !FValIsAllZeros && Subtarget.hasAVX512() && Cond.hasOneUse() && CondVT.getVectorElementType() == MVT::i1) { // Invert the cond to not(cond) : xor(op,allones)=not(op) diff --git a/test/CodeGen/X86/avx512-vec-cmp.ll b/test/CodeGen/X86/avx512-vec-cmp.ll index f7ad935a63b..023aef9df30 100644 --- a/test/CodeGen/X86/avx512-vec-cmp.ll +++ b/test/CodeGen/X86/avx512-vec-cmp.ll @@ -1101,20 +1101,12 @@ define i16 @pcmpeq_mem_2(<16 x i32> %a, <16 x i32>* %b) { define <2 x i64> @PR41066(<2 x i64> %t0, <2 x double> %x, <2 x double> %y) { ; AVX512-LABEL: PR41066: ; AVX512: ## %bb.0: -; AVX512-NEXT: ## kill: def $xmm2 killed $xmm2 def $zmm2 -; AVX512-NEXT: ## kill: def $xmm1 killed $xmm1 def $zmm1 -; AVX512-NEXT: vcmpltpd %zmm1, %zmm2, %k1 ## encoding: [0x62,0xf1,0xed,0x48,0xc2,0xc9,0x01] -; AVX512-NEXT: vpxor %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xf9,0xef,0xc0] -; AVX512-NEXT: vmovdqa64 %zmm0, %zmm0 {%k1} {z} ## encoding: [0x62,0xf1,0xfd,0xc9,0x6f,0xc0] -; AVX512-NEXT: ## kill: def $xmm0 killed $xmm0 killed $zmm0 -; AVX512-NEXT: vzeroupper ## encoding: [0xc5,0xf8,0x77] +; AVX512-NEXT: vxorps %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xf8,0x57,0xc0] ; AVX512-NEXT: retq ## encoding: [0xc3] ; ; SKX-LABEL: PR41066: ; SKX: ## %bb.0: -; SKX-NEXT: vcmpltpd %xmm1, %xmm2, %k1 ## encoding: [0x62,0xf1,0xed,0x08,0xc2,0xc9,0x01] -; SKX-NEXT: vpxor %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf9,0xef,0xc0] -; SKX-NEXT: vmovdqa64 %xmm0, %xmm0 {%k1} {z} ## encoding: [0x62,0xf1,0xfd,0x89,0x6f,0xc0] +; SKX-NEXT: vxorps %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x57,0xc0] ; SKX-NEXT: retq ## encoding: [0xc3] %t1 = fcmp ogt <2 x double> %x, %y %t2 = select <2 x i1> %t1, <2 x i64> , <2 x i64> zeroinitializer