diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -54481,21 +54481,24 @@ if (SDValue AndN = MatchAndCmpEq(RHS, LHS)) return DAG.getSetCC(DL, VT, AndN, DAG.getConstant(0, DL, OpVT), CC); - // cmpeq(trunc(x),0) --> cmpeq(x,0) - // cmpne(trunc(x),0) --> cmpne(x,0) + // cmpeq(trunc(x),C) --> cmpeq(x,C) + // cmpne(trunc(x),C) --> cmpne(x,C) // iff x upper bits are zero. - // TODO: Add support for RHS to be truncate as well? if (LHS.getOpcode() == ISD::TRUNCATE && LHS.getOperand(0).getScalarValueSizeInBits() >= 32 && - isNullConstant(RHS) && !DCI.isBeforeLegalize()) { + isa(RHS) && !DCI.isBeforeLegalize()) { EVT SrcVT = LHS.getOperand(0).getValueType(); APInt UpperBits = APInt::getBitsSetFrom(SrcVT.getScalarSizeInBits(), OpVT.getScalarSizeInBits()); const TargetLowering &TLI = DAG.getTargetLoweringInfo(); + auto *C = cast(RHS); if (DAG.MaskedValueIsZero(LHS.getOperand(0), UpperBits) && TLI.isTypeLegal(LHS.getOperand(0).getValueType())) return DAG.getSetCC(DL, VT, LHS.getOperand(0), - DAG.getConstant(0, DL, SrcVT), CC); + DAG.getConstant(C->getAPIntValue().zextOrTrunc( + SrcVT.getScalarSizeInBits()), + DL, SrcVT), + CC); } // With C as a power of 2 and C != 0 and C != INT_MIN: diff --git a/llvm/test/CodeGen/X86/movmsk-cmp.ll b/llvm/test/CodeGen/X86/movmsk-cmp.ll --- a/llvm/test/CodeGen/X86/movmsk-cmp.ll +++ b/llvm/test/CodeGen/X86/movmsk-cmp.ll @@ -10,14 +10,14 @@ ; SSE-LABEL: allones_v16i8_sign: ; SSE: # %bb.0: ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; ; AVX-LABEL: allones_v16i8_sign: ; AVX: # %bb.0: ; AVX-NEXT: vpmovmskb %xmm0, %eax -; AVX-NEXT: cmpw $-1, %ax +; AVX-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX-NEXT: sete %al ; AVX-NEXT: retq %tmp = icmp slt <16 x i8> %arg, zeroinitializer @@ -51,7 +51,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: pand %xmm1, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -60,7 +60,7 @@ ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1 ; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -133,7 +133,7 @@ ; SSE-NEXT: pand %xmm3, %xmm1 ; SSE-NEXT: pand %xmm0, %xmm1 ; SSE-NEXT: pmovmskb %xmm1, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -145,7 +145,7 @@ ; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 ; AVX1-NEXT: vpand %xmm0, %xmm2, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -322,7 +322,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: packsswb %xmm1, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -331,7 +331,7 @@ ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1 ; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -341,7 +341,7 @@ ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1 ; AVX2-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX2-NEXT: vpmovmskb %xmm0, %eax -; AVX2-NEXT: cmpw $-1, %ax +; AVX2-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX2-NEXT: sete %al ; AVX2-NEXT: vzeroupper ; AVX2-NEXT: retq @@ -428,7 +428,7 @@ ; SSE-NEXT: packsswb %xmm3, %xmm2 ; SSE-NEXT: pand %xmm0, %xmm2 ; SSE-NEXT: pmovmskb %xmm2, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -440,7 +440,7 @@ ; AVX1-NEXT: vpacksswb %xmm2, %xmm1, %xmm1 ; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -549,7 +549,7 @@ ; SSE-LABEL: allones_v4i32_sign: ; SSE: # %bb.0: ; SSE-NEXT: movmskps %xmm0, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -652,7 +652,7 @@ ; SSE-NEXT: packssdw %xmm1, %xmm0 ; SSE-NEXT: packsswb %xmm2, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -664,7 +664,7 @@ ; AVX1-NEXT: vpackssdw %xmm2, %xmm0, %xmm0 ; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -766,7 +766,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: packssdw %xmm1, %xmm0 ; SSE-NEXT: movmskps %xmm0, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -937,7 +937,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: psllw $7, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -945,7 +945,7 @@ ; AVX1OR2: # %bb.0: ; AVX1OR2-NEXT: vpsllw $7, %xmm0, %xmm0 ; AVX1OR2-NEXT: vpmovmskb %xmm0, %eax -; AVX1OR2-NEXT: cmpw $-1, %ax +; AVX1OR2-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1OR2-NEXT: sete %al ; AVX1OR2-NEXT: retq ; @@ -953,7 +953,7 @@ ; KNL: # %bb.0: ; KNL-NEXT: vpsllw $7, %xmm0, %xmm0 ; KNL-NEXT: vpmovmskb %xmm0, %eax -; KNL-NEXT: cmpw $-1, %ax +; KNL-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; KNL-NEXT: sete %al ; KNL-NEXT: retq ; @@ -1138,7 +1138,7 @@ ; SSE-NEXT: pand %xmm1, %xmm0 ; SSE-NEXT: psllw $7, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1148,7 +1148,7 @@ ; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 ; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -1223,7 +1223,7 @@ ; SSE-NEXT: pand %xmm0, %xmm1 ; SSE-NEXT: psllw $7, %xmm1 ; SSE-NEXT: pmovmskb %xmm1, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1236,7 +1236,7 @@ ; AVX1-NEXT: vpand %xmm0, %xmm2, %xmm0 ; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -1405,7 +1405,7 @@ ; SSE-NEXT: psllw $15, %xmm0 ; SSE-NEXT: packsswb %xmm1, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1416,7 +1416,7 @@ ; AVX1-NEXT: vpsllw $15, %xmm0, %xmm0 ; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -1427,7 +1427,7 @@ ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1 ; AVX2-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX2-NEXT: vpmovmskb %xmm0, %eax -; AVX2-NEXT: cmpw $-1, %ax +; AVX2-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX2-NEXT: sete %al ; AVX2-NEXT: vzeroupper ; AVX2-NEXT: retq @@ -1468,7 +1468,7 @@ ; SSE-NEXT: packsswb %xmm3, %xmm2 ; SSE-NEXT: pand %xmm0, %xmm2 ; SSE-NEXT: pmovmskb %xmm2, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1484,7 +1484,7 @@ ; AVX1-NEXT: vpacksswb %xmm2, %xmm1, %xmm1 ; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -1619,7 +1619,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: pslld $31, %xmm0 ; SSE-NEXT: movmskps %xmm0, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1809,7 +1809,7 @@ ; SSE-NEXT: packssdw %xmm1, %xmm0 ; SSE-NEXT: packsswb %xmm2, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1825,7 +1825,7 @@ ; AVX1-NEXT: vpackssdw %xmm2, %xmm0, %xmm0 ; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -1914,7 +1914,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: psllq $63, %xmm0 ; SSE-NEXT: movmskpd %xmm0, %eax -; SSE-NEXT: cmpb $3, %al +; SSE-NEXT: cmpl $3, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1998,7 +1998,7 @@ ; SSE-NEXT: psllq $63, %xmm0 ; SSE-NEXT: packssdw %xmm1, %xmm0 ; SSE-NEXT: movmskps %xmm0, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2218,7 +2218,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: psllw $5, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2226,7 +2226,7 @@ ; AVX1OR2: # %bb.0: ; AVX1OR2-NEXT: vpsllw $5, %xmm0, %xmm0 ; AVX1OR2-NEXT: vpmovmskb %xmm0, %eax -; AVX1OR2-NEXT: cmpw $-1, %ax +; AVX1OR2-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1OR2-NEXT: sete %al ; AVX1OR2-NEXT: retq ; @@ -2234,7 +2234,7 @@ ; KNL: # %bb.0: ; KNL-NEXT: vpsllw $5, %xmm0, %xmm0 ; KNL-NEXT: vpmovmskb %xmm0, %eax -; KNL-NEXT: cmpw $-1, %ax +; KNL-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; KNL-NEXT: sete %al ; KNL-NEXT: retq ; @@ -2284,7 +2284,7 @@ ; SSE-NEXT: pand %xmm1, %xmm0 ; SSE-NEXT: psllw $5, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2294,7 +2294,7 @@ ; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 ; AVX1-NEXT: vpsllw $5, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -2369,7 +2369,7 @@ ; SSE-NEXT: pand %xmm0, %xmm1 ; SSE-NEXT: psllw $5, %xmm1 ; SSE-NEXT: pmovmskb %xmm1, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2382,7 +2382,7 @@ ; AVX1-NEXT: vpand %xmm0, %xmm2, %xmm0 ; AVX1-NEXT: vpsllw $5, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -2551,7 +2551,7 @@ ; SSE-NEXT: psllw $13, %xmm0 ; SSE-NEXT: packsswb %xmm1, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2562,7 +2562,7 @@ ; AVX1-NEXT: vpsllw $13, %xmm0, %xmm0 ; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -2573,7 +2573,7 @@ ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1 ; AVX2-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX2-NEXT: vpmovmskb %xmm0, %eax -; AVX2-NEXT: cmpw $-1, %ax +; AVX2-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX2-NEXT: sete %al ; AVX2-NEXT: vzeroupper ; AVX2-NEXT: retq @@ -2614,7 +2614,7 @@ ; SSE-NEXT: packsswb %xmm3, %xmm2 ; SSE-NEXT: pand %xmm0, %xmm2 ; SSE-NEXT: pmovmskb %xmm2, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2630,7 +2630,7 @@ ; AVX1-NEXT: vpacksswb %xmm2, %xmm1, %xmm1 ; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -2765,7 +2765,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: pslld $29, %xmm0 ; SSE-NEXT: movmskps %xmm0, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2955,7 +2955,7 @@ ; SSE-NEXT: packssdw %xmm1, %xmm0 ; SSE-NEXT: packsswb %xmm2, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -2971,7 +2971,7 @@ ; AVX1-NEXT: vpackssdw %xmm2, %xmm0, %xmm0 ; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0 ; AVX1-NEXT: vpmovmskb %xmm0, %eax -; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1-NEXT: sete %al ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -3060,7 +3060,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: psllq $61, %xmm0 ; SSE-NEXT: movmskpd %xmm0, %eax -; SSE-NEXT: cmpb $3, %al +; SSE-NEXT: cmpl $3, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -3144,7 +3144,7 @@ ; SSE-NEXT: psllq $61, %xmm0 ; SSE-NEXT: packssdw %xmm1, %xmm0 ; SSE-NEXT: movmskps %xmm0, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -3723,8 +3723,7 @@ ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,0,3,2] ; SSE2-NEXT: pand %xmm0, %xmm1 ; SSE2-NEXT: movmskpd %xmm1, %eax -; SSE2-NEXT: xorl $3, %eax -; SSE2-NEXT: cmpb $3, %al +; SSE2-NEXT: testl %eax, %eax ; SSE2-NEXT: sete %al ; SSE2-NEXT: retq ; @@ -3732,17 +3731,14 @@ ; SSE41: # %bb.0: ; SSE41-NEXT: pcmpeqq %xmm1, %xmm0 ; SSE41-NEXT: movmskpd %xmm0, %eax -; SSE41-NEXT: xorl $3, %eax -; SSE41-NEXT: cmpb $3, %al +; SSE41-NEXT: testl %eax, %eax ; SSE41-NEXT: sete %al ; SSE41-NEXT: retq ; ; AVX1OR2-LABEL: movmsk_and_v2i64: ; AVX1OR2: # %bb.0: ; AVX1OR2-NEXT: vpcmpeqq %xmm1, %xmm0, %xmm0 -; AVX1OR2-NEXT: vmovmskpd %xmm0, %eax -; AVX1OR2-NEXT: xorl $3, %eax -; AVX1OR2-NEXT: cmpb $3, %al +; AVX1OR2-NEXT: vtestpd %xmm0, %xmm0 ; AVX1OR2-NEXT: sete %al ; AVX1OR2-NEXT: retq ; @@ -3854,7 +3850,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: cmplepd %xmm0, %xmm1 ; SSE-NEXT: movmskpd %xmm1, %eax -; SSE-NEXT: cmpb $3, %al +; SSE-NEXT: cmpl $3, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -4282,7 +4278,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: cmpltpd %xmm0, %xmm1 ; SSE-NEXT: movmskpd %xmm1, %eax -; SSE-NEXT: cmpb $3, %al +; SSE-NEXT: cmpl $3, %eax ; SSE-NEXT: movl $42, %ecx ; SSE-NEXT: movl $99, %eax ; SSE-NEXT: cmovel %ecx, %eax diff --git a/llvm/test/CodeGen/X86/setcc-logic.ll b/llvm/test/CodeGen/X86/setcc-logic.ll --- a/llvm/test/CodeGen/X86/setcc-logic.ll +++ b/llvm/test/CodeGen/X86/setcc-logic.ll @@ -324,7 +324,7 @@ ; CHECK-NEXT: xorpd %xmm1, %xmm1 ; CHECK-NEXT: cmpltpd %xmm0, %xmm1 ; CHECK-NEXT: movmskpd %xmm1, %eax -; CHECK-NEXT: cmpb $3, %al +; CHECK-NEXT: cmpl $3, %eax ; CHECK-NEXT: jne .LBB16_2 ; CHECK-NEXT: # %bb.1: # %true ; CHECK-NEXT: movl $42, %eax diff --git a/llvm/test/CodeGen/X86/vector-compare-all_of.ll b/llvm/test/CodeGen/X86/vector-compare-all_of.ll --- a/llvm/test/CodeGen/X86/vector-compare-all_of.ll +++ b/llvm/test/CodeGen/X86/vector-compare-all_of.ll @@ -957,7 +957,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: cmpltpd %xmm0, %xmm1 ; SSE-NEXT: movmskpd %xmm1, %eax -; SSE-NEXT: cmpb $3, %al +; SSE-NEXT: cmpl $3, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -988,7 +988,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: cmpeqps %xmm1, %xmm0 ; SSE-NEXT: movmskps %xmm0, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1023,7 +1023,7 @@ ; SSE-NEXT: cmplepd %xmm0, %xmm2 ; SSE-NEXT: packssdw %xmm3, %xmm2 ; SSE-NEXT: movmskps %xmm2, %eax -; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: cmpl $15, %eax ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1120,8 +1120,7 @@ ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,0,3,2] ; SSE2-NEXT: pand %xmm0, %xmm1 ; SSE2-NEXT: movmskpd %xmm1, %eax -; SSE2-NEXT: xorl $3, %eax -; SSE2-NEXT: cmpb $3, %al +; SSE2-NEXT: testl %eax, %eax ; SSE2-NEXT: sete %al ; SSE2-NEXT: retq ; @@ -1129,17 +1128,14 @@ ; SSE42: # %bb.0: ; SSE42-NEXT: pcmpeqq %xmm1, %xmm0 ; SSE42-NEXT: movmskpd %xmm0, %eax -; SSE42-NEXT: xorl $3, %eax -; SSE42-NEXT: cmpb $3, %al +; SSE42-NEXT: testl %eax, %eax ; SSE42-NEXT: sete %al ; SSE42-NEXT: retq ; ; AVX1OR2-LABEL: bool_reduction_v2i64: ; AVX1OR2: # %bb.0: ; AVX1OR2-NEXT: vpcmpeqq %xmm1, %xmm0, %xmm0 -; AVX1OR2-NEXT: vmovmskpd %xmm0, %eax -; AVX1OR2-NEXT: xorl $3, %eax -; AVX1OR2-NEXT: cmpb $3, %al +; AVX1OR2-NEXT: vtestpd %xmm0, %xmm0 ; AVX1OR2-NEXT: sete %al ; AVX1OR2-NEXT: retq ; @@ -1165,7 +1161,7 @@ ; SSE2-NEXT: pxor %xmm2, %xmm0 ; SSE2-NEXT: pcmpgtd %xmm1, %xmm0 ; SSE2-NEXT: movmskps %xmm0, %eax -; SSE2-NEXT: cmpb $15, %al +; SSE2-NEXT: cmpl $15, %eax ; SSE2-NEXT: sete %al ; SSE2-NEXT: retq ; @@ -1174,8 +1170,7 @@ ; SSE42-NEXT: pminud %xmm0, %xmm1 ; SSE42-NEXT: pcmpeqd %xmm0, %xmm1 ; SSE42-NEXT: movmskps %xmm1, %eax -; SSE42-NEXT: xorl $15, %eax -; SSE42-NEXT: cmpb $15, %al +; SSE42-NEXT: testl %eax, %eax ; SSE42-NEXT: sete %al ; SSE42-NEXT: retq ; @@ -1183,9 +1178,7 @@ ; AVX1OR2: # %bb.0: ; AVX1OR2-NEXT: vpminud %xmm1, %xmm0, %xmm1 ; AVX1OR2-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0 -; AVX1OR2-NEXT: vmovmskps %xmm0, %eax -; AVX1OR2-NEXT: xorl $15, %eax -; AVX1OR2-NEXT: cmpb $15, %al +; AVX1OR2-NEXT: vtestps %xmm0, %xmm0 ; AVX1OR2-NEXT: sete %al ; AVX1OR2-NEXT: retq ; @@ -1247,7 +1240,7 @@ ; SSE: # %bb.0: ; SSE-NEXT: pcmpgtb %xmm1, %xmm0 ; SSE-NEXT: pmovmskb %xmm0, %eax -; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; SSE-NEXT: sete %al ; SSE-NEXT: retq ; @@ -1255,7 +1248,7 @@ ; AVX1OR2: # %bb.0: ; AVX1OR2-NEXT: vpcmpgtb %xmm1, %xmm0, %xmm0 ; AVX1OR2-NEXT: vpmovmskb %xmm0, %eax -; AVX1OR2-NEXT: cmpw $-1, %ax +; AVX1OR2-NEXT: cmpl $65535, %eax # imm = 0xFFFF ; AVX1OR2-NEXT: sete %al ; AVX1OR2-NEXT: retq ; @@ -1300,7 +1293,7 @@ ; SSE2-NEXT: por %xmm2, %xmm0 ; SSE2-NEXT: packssdw %xmm1, %xmm0 ; SSE2-NEXT: movmskps %xmm0, %eax -; SSE2-NEXT: cmpb $15, %al +; SSE2-NEXT: cmpl $15, %eax ; SSE2-NEXT: sete %al ; SSE2-NEXT: retq ; @@ -1310,7 +1303,7 @@ ; SSE42-NEXT: pcmpgtq %xmm0, %xmm2 ; SSE42-NEXT: packssdw %xmm3, %xmm2 ; SSE42-NEXT: movmskps %xmm2, %eax -; SSE42-NEXT: cmpb $15, %al +; SSE42-NEXT: cmpl $15, %eax ; SSE42-NEXT: sete %al ; SSE42-NEXT: retq ; diff --git a/llvm/test/CodeGen/X86/vector-reduce-and-bool.ll b/llvm/test/CodeGen/X86/vector-reduce-and-bool.ll --- a/llvm/test/CodeGen/X86/vector-reduce-and-bool.ll +++ b/llvm/test/CodeGen/X86/vector-reduce-and-bool.ll @@ -16,7 +16,7 @@ ; SSE2: # %bb.0: ; SSE2-NEXT: psllq $63, %xmm0 ; SSE2-NEXT: movmskpd %xmm0, %eax -; SSE2-NEXT: cmpb $3, %al +; SSE2-NEXT: cmpl $3, %eax ; SSE2-NEXT: sete %al ; SSE2-NEXT: retq ; @@ -151,7 +151,7 @@ ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[0,2] ; SSE2-NEXT: pslld $31, %xmm0 ; SSE2-NEXT: movmskps %xmm0, %eax -; SSE2-NEXT: cmpb $15, %al +; SSE2-NEXT: cmpl $15, %eax ; SSE2-NEXT: sete %al ; SSE2-NEXT: retq ;