if (matchScalarReduction(SDValue(N, 0), ISD::AND, SrcOps) &&
SrcOps.size() == 1) {
SDLoc dl(N);
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
unsigned NumElts = SrcOps[0].getValueType().getVectorNumElements();
EVT MaskVT = EVT::getIntegerVT(*DAG.getContext(), NumElts);
SDValue Mask = combineBitcastvxi1(DAG, MaskVT, SrcOps[0], dl, Subtarget);
+ if (!Mask && TLI.isTypeLegal(SrcOps[0].getValueType()))
+ Mask = DAG.getBitcast(MaskVT, SrcOps[0]);
if (Mask) {
APInt AllBits = APInt::getAllOnesValue(NumElts);
return DAG.getSetCC(dl, MVT::i1, Mask,
if (matchScalarReduction(SDValue(N, 0), ISD::OR, SrcOps) &&
SrcOps.size() == 1) {
SDLoc dl(N);
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
unsigned NumElts = SrcOps[0].getValueType().getVectorNumElements();
EVT MaskVT = EVT::getIntegerVT(*DAG.getContext(), NumElts);
SDValue Mask = combineBitcastvxi1(DAG, MaskVT, SrcOps[0], dl, Subtarget);
+ if (!Mask && TLI.isTypeLegal(SrcOps[0].getValueType()))
+ Mask = DAG.getBitcast(MaskVT, SrcOps[0]);
if (Mask) {
APInt AllBits = APInt::getNullValue(NumElts);
return DAG.getSetCC(dl, MVT::i1, Mask,
; KNL-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
; KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
; KNL-NEXT: vpcmpneqq %zmm1, %zmm0, %k0
-; KNL-NEXT: kshiftrw $1, %k0, %k1
-; KNL-NEXT: kmovw %k1, %ecx
; KNL-NEXT: kmovw %k0, %eax
-; KNL-NEXT: andb %cl, %al
-; KNL-NEXT: # kill: def $al killed $al killed $eax
+; KNL-NEXT: andb $3, %al
+; KNL-NEXT: cmpb $3, %al
+; KNL-NEXT: sete %al
; KNL-NEXT: vzeroupper
; KNL-NEXT: retq
;
; SKX-LABEL: movmsk_and_v2i64:
; SKX: # %bb.0:
; SKX-NEXT: vpcmpneqq %xmm1, %xmm0, %k0
-; SKX-NEXT: kshiftrb $1, %k0, %k1
-; SKX-NEXT: kmovd %k1, %ecx
; SKX-NEXT: kmovd %k0, %eax
-; SKX-NEXT: andb %cl, %al
-; SKX-NEXT: # kill: def $al killed $al killed $eax
+; SKX-NEXT: cmpb $3, %al
+; SKX-NEXT: sete %al
; SKX-NEXT: retq
%cmp = icmp ne <2 x i64> %x, %y
%e1 = extractelement <2 x i1> %cmp, i32 0
; KNL-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
; KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
; KNL-NEXT: vpcmpneqq %zmm1, %zmm0, %k0
-; KNL-NEXT: kshiftrw $1, %k0, %k1
-; KNL-NEXT: kmovw %k1, %ecx
; KNL-NEXT: kmovw %k0, %eax
-; KNL-NEXT: orb %cl, %al
-; KNL-NEXT: # kill: def $al killed $al killed $eax
+; KNL-NEXT: testb $3, %al
+; KNL-NEXT: setne %al
; KNL-NEXT: vzeroupper
; KNL-NEXT: retq
;
; SKX-LABEL: movmsk_or_v2i64:
; SKX: # %bb.0:
; SKX-NEXT: vpcmpneqq %xmm1, %xmm0, %k0
-; SKX-NEXT: kshiftrb $1, %k0, %k1
-; SKX-NEXT: kmovd %k1, %ecx
-; SKX-NEXT: kmovd %k0, %eax
-; SKX-NEXT: orb %cl, %al
-; SKX-NEXT: # kill: def $al killed $al killed $eax
+; SKX-NEXT: kortestb %k0, %k0
+; SKX-NEXT: setne %al
; SKX-NEXT: retq
%cmp = icmp ne <2 x i64> %x, %y
%e1 = extractelement <2 x i1> %cmp, i32 0
; KNL-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
; KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
; KNL-NEXT: vcmplepd %zmm0, %zmm1, %k0
-; KNL-NEXT: kshiftrw $1, %k0, %k1
-; KNL-NEXT: kmovw %k1, %ecx
; KNL-NEXT: kmovw %k0, %eax
-; KNL-NEXT: andb %cl, %al
-; KNL-NEXT: # kill: def $al killed $al killed $eax
+; KNL-NEXT: andb $3, %al
+; KNL-NEXT: cmpb $3, %al
+; KNL-NEXT: sete %al
; KNL-NEXT: vzeroupper
; KNL-NEXT: retq
;
; SKX-LABEL: movmsk_and_v2f64:
; SKX: # %bb.0:
; SKX-NEXT: vcmplepd %xmm0, %xmm1, %k0
-; SKX-NEXT: kshiftrb $1, %k0, %k1
-; SKX-NEXT: kmovd %k1, %ecx
; SKX-NEXT: kmovd %k0, %eax
-; SKX-NEXT: andb %cl, %al
-; SKX-NEXT: # kill: def $al killed $al killed $eax
+; SKX-NEXT: cmpb $3, %al
+; SKX-NEXT: sete %al
; SKX-NEXT: retq
%cmp = fcmp oge <2 x double> %x, %y
%e1 = extractelement <2 x i1> %cmp, i32 0
; KNL-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
; KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
; KNL-NEXT: vcmplepd %zmm0, %zmm1, %k0
-; KNL-NEXT: kshiftrw $1, %k0, %k1
-; KNL-NEXT: kmovw %k1, %ecx
; KNL-NEXT: kmovw %k0, %eax
-; KNL-NEXT: orb %cl, %al
-; KNL-NEXT: # kill: def $al killed $al killed $eax
+; KNL-NEXT: testb $3, %al
+; KNL-NEXT: setne %al
; KNL-NEXT: vzeroupper
; KNL-NEXT: retq
;
; SKX-LABEL: movmsk_or_v2f64:
; SKX: # %bb.0:
; SKX-NEXT: vcmplepd %xmm0, %xmm1, %k0
-; SKX-NEXT: kshiftrb $1, %k0, %k1
-; SKX-NEXT: kmovd %k1, %ecx
-; SKX-NEXT: kmovd %k0, %eax
-; SKX-NEXT: orb %cl, %al
-; SKX-NEXT: # kill: def $al killed $al killed $eax
+; SKX-NEXT: kortestb %k0, %k0
+; SKX-NEXT: setne %al
; SKX-NEXT: retq
%cmp = fcmp oge <2 x double> %x, %y
%e1 = extractelement <2 x i1> %cmp, i32 0