Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
@@ -26796,12 +26796,18 @@
   SDLoc DL(N);
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
 
-  // Condition value type must match vselect operand type.
-  if (N->getOpcode() != ISD::VSELECT || CondVT != VT)
+  if (N->getOpcode() != ISD::VSELECT)
     return SDValue();
 
-  assert(Cond.getValueType().isVector() &&
-         "Vector select expects a vector selector!");
+  assert(CondVT.isVector() && "Vector select expects a vector selector!");
+
+  // To use the condition operand as a bitwise mask, it must have elements that
+  // are the same size as the select elements. Ie, the condition operand must
+  // have already been promoted from the IR select condition type <N x i1>.
+  // Don't check if the types themselves are equal because that excludes
+  // vector floating-point selects.
+  if (CondVT.getScalarSizeInBits() != VT.getScalarSizeInBits())
+    return SDValue();
 
   bool TValIsAllOnes = ISD::isBuildVectorAllOnes(LHS.getNode());
   bool FValIsAllZeros = ISD::isBuildVectorAllZeros(RHS.getNode());
Index: llvm/trunk/test/CodeGen/X86/avx512-cvt.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/avx512-cvt.ll
+++ llvm/trunk/test/CodeGen/X86/avx512-cvt.ll
@@ -415,9 +415,9 @@
 ; KNL-LABEL: fptrunc02:
 ; KNL:       ## BB#0:
 ; KNL-NEXT:    vpslld $31, %xmm1, %xmm1
+; KNL-NEXT:    vpsrad $31, %xmm1, %xmm1
 ; KNL-NEXT:    vcvtpd2psy %ymm0, %xmm0
-; KNL-NEXT:    vxorps %xmm2, %xmm2, %xmm2
-; KNL-NEXT:    vblendvps %xmm1, %xmm0, %xmm2, %xmm0
+; KNL-NEXT:    vpand %xmm0, %xmm1, %xmm0
 ; KNL-NEXT:    retq
 ;
 ; SKX-LABEL: fptrunc02:
@@ -445,8 +445,7 @@
 ; KNL:       ## BB#0:
 ; KNL-NEXT:    vcvtps2pd %xmm0, %ymm0
 ; KNL-NEXT:    vcmpltpd %ymm2, %ymm1, %ymm1
-; KNL-NEXT:    vxorpd %ymm2, %ymm2, %ymm2
-; KNL-NEXT:    vblendvpd %ymm1, %ymm0, %ymm2, %ymm0
+; KNL-NEXT:    vandpd %ymm0, %ymm1, %ymm0
 ; KNL-NEXT:    retq
 ;
 ; SKX-LABEL: fpext01:
Index: llvm/trunk/test/CodeGen/X86/select-with-and-or.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/select-with-and-or.ll
+++ llvm/trunk/test/CodeGen/X86/select-with-and-or.ll
@@ -90,8 +90,7 @@
 ; CHECK-LABEL: test1f:
 ; CHECK:       # BB#0:
 ; CHECK-NEXT:    vcmpltpd %xmm0, %xmm1, %xmm0
-; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm1
-; CHECK-NEXT:    vblendvpd %xmm0, %xmm2, %xmm1, %xmm0
+; CHECK-NEXT:    vandpd %xmm2, %xmm0, %xmm0
 ; CHECK-NEXT:    retq
 ;
   %f = fcmp ogt <2 x double> %a, %b
@@ -103,8 +102,7 @@
 ; CHECK-LABEL: test2f:
 ; CHECK:       # BB#0:
 ; CHECK-NEXT:    vcmplepd %xmm0, %xmm1, %xmm0
-; CHECK-NEXT:    vpcmpeqd %xmm1, %xmm1, %xmm1
-; CHECK-NEXT:    vblendvpd %xmm0, %xmm1, %xmm2, %xmm0
+; CHECK-NEXT:    vorpd %xmm2, %xmm0, %xmm0
 ; CHECK-NEXT:    retq
 ;
   %f = fcmp oge <2 x double> %a, %b
@@ -115,9 +113,8 @@
 define <2 x double> @test3f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
 ; CHECK-LABEL: test3f:
 ; CHECK:       # BB#0:
-; CHECK-NEXT:    vcmpltpd %xmm1, %xmm0, %xmm0
-; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm1
-; CHECK-NEXT:    vblendvpd %xmm0, %xmm1, %xmm2, %xmm0
+; CHECK-NEXT:    vcmpnltpd %xmm1, %xmm0, %xmm0
+; CHECK-NEXT:    vandpd %xmm2, %xmm0, %xmm0
 ; CHECK-NEXT:    retq
 ;
   %f = fcmp olt <2 x double> %a, %b
@@ -128,9 +125,8 @@
 define <2 x double> @test4f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
 ; CHECK-LABEL: test4f:
 ; CHECK:       # BB#0:
-; CHECK-NEXT:    vcmplepd %xmm1, %xmm0, %xmm0
-; CHECK-NEXT:    vpcmpeqd %xmm1, %xmm1, %xmm1
-; CHECK-NEXT:    vblendvpd %xmm0, %xmm2, %xmm1, %xmm0
+; CHECK-NEXT:    vcmpnlepd %xmm1, %xmm0, %xmm0
+; CHECK-NEXT:    vorpd %xmm2, %xmm0, %xmm0
 ; CHECK-NEXT:    retq
 ;
   %f = fcmp ole <2 x double> %a, %b
@@ -142,9 +138,6 @@
 ; CHECK-LABEL: test5f:
 ; CHECK:       # BB#0:
 ; CHECK-NEXT:    vcmpnlepd %xmm1, %xmm0, %xmm0
-; CHECK-NEXT:    vpcmpeqd %xmm1, %xmm1, %xmm1
-; CHECK-NEXT:    vxorpd %xmm2, %xmm2, %xmm2
-; CHECK-NEXT:    vblendvpd %xmm0, %xmm1, %xmm2, %xmm0
 ; CHECK-NEXT:    retq
 ;
   %f = fcmp ugt <2 x double> %a, %b
@@ -155,10 +148,7 @@
 define <2 x double> @test6f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
 ; CHECK-LABEL: test6f:
 ; CHECK:       # BB#0:
-; CHECK-NEXT:    vcmpnltpd %xmm0, %xmm1, %xmm0
-; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm1
-; CHECK-NEXT:    vpcmpeqd %xmm2, %xmm2, %xmm2
-; CHECK-NEXT:    vblendvpd %xmm0, %xmm1, %xmm2, %xmm0
+; CHECK-NEXT:    vcmpltpd %xmm0, %xmm1, %xmm0
 ; CHECK-NEXT:    retq
 ;
   %f = fcmp ule <2 x double> %a, %b
@@ -170,8 +160,7 @@
 ; CHECK-LABEL: test7f:
 ; CHECK:       # BB#0:
 ; CHECK-NEXT:    vcmpeqpd %xmm1, %xmm0, %xmm0
-; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm1
-; CHECK-NEXT:    vblendvpd %xmm0, (%rdi), %xmm1, %xmm0
+; CHECK-NEXT:    vandpd (%rdi), %xmm0, %xmm0
 ; CHECK-NEXT:    retq
 ;
   %f = fcmp oeq <2 x double> %a, %b