@@ -55447,6 +55447,9 @@ static SDValue truncateAVX512SetCCNoBWI(EVT VT, EVT OpVT, SDValue LHS,
55447
55447
return SDValue();
55448
55448
}
55449
55449
55450
+ // The pattern (setcc (and (broadcast x), (2^n, 2^{n+1}, ...)), (0, 0, ...),
55451
+ // eq/ne) is generated when using an integer as a mask. Instead of generating a
55452
+ // broadcast + vptest, we can directly move the integer to a mask register.
55450
55453
static SDValue combineAVX512SetCCToKMOV(EVT VT, SDValue Op0, ISD::CondCode CC,
55451
55454
const SDLoc &DL, SelectionDAG &DAG,
55452
55455
const X86Subtarget &Subtarget) {
@@ -55476,6 +55479,9 @@ static SDValue combineAVX512SetCCToKMOV(EVT VT, SDValue Op0, ISD::CondCode CC,
55476
55479
UndefElts[0] || !EltBits[0].isPowerOf2())
55477
55480
return SDValue();
55478
55481
55482
+ // Check if the constant pool contains only powers of 2 starting from some
55483
+ // 2^N. The table may also contain undefs because of widening of vector
55484
+ // operands.
55479
55485
unsigned N = EltBits[0].logBase2();
55480
55486
unsigned Len = UndefElts.getBitWidth();
55481
55487
for (unsigned I = 1; I != Len; ++I) {
@@ -55501,9 +55507,7 @@ static SDValue combineAVX512SetCCToKMOV(EVT VT, SDValue Op0, ISD::CondCode CC,
55501
55507
Masked = DAG.getNode(ISD::AND, DL, BroadcastOpVT, ShiftedValue,
55502
55508
DAG.getConstant(Mask, DL, BroadcastOpVT));
55503
55509
}
55504
- SDValue Trunc = DAG.getNode(BroadcastOpVT.bitsGT(MVT::i16) ? ISD::TRUNCATE
55505
- : ISD::ANY_EXTEND,
55506
- DL, MVT::i16, Masked);
55510
+ SDValue Trunc = DAG.getAnyExtOrTrunc(Masked, DL, MVT::i16);
55507
55511
SDValue Bitcast = DAG.getNode(ISD::BITCAST, DL, MVT::v16i1, Trunc);
55508
55512
MVT PtrTy = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
55509
55513
0 commit comments