Index: lib/CodeGen/SelectionDAG/TargetLowering.cpp =================================================================== --- lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1291,11 +1291,11 @@ if (!BV) return false; - BitVector UndefElements; - CN = BV->getConstantSplatNode(&UndefElements); - // Only interested in constant splats, and we don't try to handle undef - // elements in identifying boolean constants. - if (!CN || UndefElements.none()) + // Only interested in constant splats, we don't care about undef + // elements in identifying boolean constants and getConstantSplatNode + // returns NULL if all ops are undef; + CN = BV->getConstantSplatNode(); + if (!CN) return false; } @@ -1331,11 +1331,11 @@ if (!BV) return false; - BitVector UndefElements; - CN = BV->getConstantSplatNode(&UndefElements); - // Only interested in constant splats, and we don't try to handle undef - // elements in identifying boolean constants. - if (!CN || UndefElements.none()) + // Only interested in constant splats, we don't care about undef + // elements in identifying boolean constants and getConstantSplatNode + // returns NULL if all ops are undef; + CN = BV->getConstantSplatNode(); + if (!CN) return false; } Index: test/CodeGen/X86/avx512-ext.ll =================================================================== --- test/CodeGen/X86/avx512-ext.ll +++ test/CodeGen/X86/avx512-ext.ll @@ -1400,19 +1400,14 @@ define <8 x i32> @sext_8i1_8i32(<8 x i32> %a1, <8 x i32> %a2) nounwind { ; KNL-LABEL: sext_8i1_8i32: ; KNL: ## BB#0: -; KNL-NEXT: ## kill: %YMM1 %YMM1 %ZMM1 -; KNL-NEXT: ## kill: %YMM0 %YMM0 %ZMM0 -; KNL-NEXT: vpcmpgtd %zmm0, %zmm1, %k0 -; KNL-NEXT: knotw %k0, %k1 -; KNL-NEXT: vpternlogd $255, %zmm0, %zmm0, %zmm0 -; KNL-NEXT: vmovdqa64 %zmm0, %zmm0 {%k1} {z} -; KNL-NEXT: vpmovqd %zmm0, %ymm0 +; KNL-NEXT: vpcmpgtd %ymm0, %ymm1, %ymm0 +; KNL-NEXT: vpcmpeqd %ymm1, %ymm1, %ymm1 +; KNL-NEXT: vpxor %ymm1, %ymm0, %ymm0 ; KNL-NEXT: retq ; ; SKX-LABEL: sext_8i1_8i32: ; SKX: ## BB#0: -; SKX-NEXT: vpcmpgtd %ymm0, %ymm1, %k0 -; SKX-NEXT: knotb %k0, %k0 +; SKX-NEXT: vpcmpled %ymm0, %ymm1, %k0 ; SKX-NEXT: vpmovm2d %k0, %ymm0 ; SKX-NEXT: retq %x = icmp slt <8 x i32> %a1, %a2 Index: test/CodeGen/X86/avx512-vec-cmp.ll =================================================================== --- test/CodeGen/X86/avx512-vec-cmp.ll +++ test/CodeGen/X86/avx512-vec-cmp.ll @@ -659,7 +659,8 @@ ; CHECK-LABEL: test14: ; CHECK: ## BB#0: ; CHECK-NEXT: vpsubd %zmm1, %zmm0, %zmm1 -; CHECK-NEXT: vpcmpgtd %zmm0, %zmm1, %k1 +; CHECK-NEXT: vpcmpled %zmm0, %zmm1, %k0 +; CHECK-NEXT: knotw %k0, %k1 ; CHECK-NEXT: vmovdqa32 %zmm1, %zmm0 {%k1} {z} ; CHECK-NEXT: retq %sub_r = sub <16 x i32> %a, %b @@ -674,7 +675,8 @@ ; CHECK-LABEL: test15: ; CHECK: ## BB#0: ; CHECK-NEXT: vpsubq %zmm1, %zmm0, %zmm1 -; CHECK-NEXT: vpcmpgtq %zmm0, %zmm1, %k1 +; CHECK-NEXT: vpcmpleq %zmm0, %zmm1, %k0 +; CHECK-NEXT: knotw %k0, %k1 ; CHECK-NEXT: vmovdqa64 %zmm1, %zmm0 {%k1} {z} ; CHECK-NEXT: retq %sub_r = sub <8 x i64> %a, %b Index: test/CodeGen/X86/v8i1-masks.ll =================================================================== --- test/CodeGen/X86/v8i1-masks.ll +++ test/CodeGen/X86/v8i1-masks.ll @@ -48,10 +48,8 @@ ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx ; X32-NEXT: vmovups (%ecx), %ymm0 -; X32-NEXT: vcmpltps (%eax), %ymm0, %ymm0 -; X32-NEXT: vmovaps {{.*#+}} ymm1 = [1,1,1,1,1,1,1,1] -; X32-NEXT: vxorps %ymm1, %ymm0, %ymm0 -; X32-NEXT: vandps %ymm1, %ymm0, %ymm0 +; X32-NEXT: vcmpnltps (%eax), %ymm0, %ymm0 +; X32-NEXT: vandps LCPI1_0, %ymm0, %ymm0 ; X32-NEXT: vmovaps %ymm0, (%eax) ; X32-NEXT: vzeroupper ; X32-NEXT: retl @@ -59,10 +57,8 @@ ; X64-LABEL: neg_masks: ; X64: ## BB#0: ; X64-NEXT: vmovups (%rsi), %ymm0 -; X64-NEXT: vcmpltps (%rdi), %ymm0, %ymm0 -; X64-NEXT: vmovaps {{.*#+}} ymm1 = [1,1,1,1,1,1,1,1] -; X64-NEXT: vxorps %ymm1, %ymm0, %ymm0 -; X64-NEXT: vandps %ymm1, %ymm0, %ymm0 +; X64-NEXT: vcmpnltps (%rdi), %ymm0, %ymm0 +; X64-NEXT: vandps {{.*}}(%rip), %ymm0, %ymm0 ; X64-NEXT: vmovaps %ymm0, (%rax) ; X64-NEXT: vzeroupper ; X64-NEXT: retq