@@ -2300,24 +2300,12 @@ static bool isTruncateOf(SelectionDAG &DAG, SDValue N, SDValue &Op,
2300
2300
return true;
2301
2301
}
2302
2302
2303
- if (N.getOpcode() != ISD::SETCC ||
2304
- N.getValueType().getScalarType() != MVT::i1 ||
2305
- cast<CondCodeSDNode>(N.getOperand(2))->get() != ISD::SETNE)
2306
- return false;
2307
-
2308
- SDValue Op0 = N->getOperand(0);
2309
- SDValue Op1 = N->getOperand(1);
2310
- assert(Op0.getValueType() == Op1.getValueType());
2311
-
2312
- if (isNullOrNullSplat(Op0))
2313
- Op = Op1;
2314
- else if (isNullOrNullSplat(Op1))
2315
- Op = Op0;
2316
- else
2303
+ if (N.getValueType().getScalarType() != MVT::i1 ||
2304
+ !sd_match(
2305
+ N, m_c_SetCC(m_Value(Op), m_Zero(), m_SpecificCondCode(ISD::SETNE))))
2317
2306
return false;
2318
2307
2319
2308
Known = DAG.computeKnownBits(Op);
2320
-
2321
2309
return (Known.Zero | 1).isAllOnes();
2322
2310
}
2323
2311
@@ -2544,26 +2532,22 @@ static SDValue foldAddSubBoolOfMaskedVal(SDNode *N, const SDLoc &DL,
2544
2532
return SDValue();
2545
2533
2546
2534
// Match the zext operand as a setcc of a boolean.
2547
- if (Z.getOperand(0).getOpcode() != ISD::SETCC ||
2548
- Z.getOperand(0).getValueType() != MVT::i1)
2535
+ if (Z.getOperand(0).getValueType() != MVT::i1)
2549
2536
return SDValue();
2550
2537
2551
2538
// Match the compare as: setcc (X & 1), 0, eq.
2552
- SDValue SetCC = Z.getOperand(0);
2553
- ISD::CondCode CC = cast<CondCodeSDNode>(SetCC->getOperand(2))->get();
2554
- if (CC != ISD::SETEQ || !isNullConstant(SetCC.getOperand(1)) ||
2555
- SetCC.getOperand(0).getOpcode() != ISD::AND ||
2556
- !isOneConstant(SetCC.getOperand(0).getOperand(1)))
2539
+ if (!sd_match(Z.getOperand(0), m_SetCC(m_And(m_Value(), m_One()), m_Zero(),
2540
+ m_SpecificCondCode(ISD::SETEQ))))
2557
2541
return SDValue();
2558
2542
2559
2543
// We are adding/subtracting a constant and an inverted low bit. Turn that
2560
2544
// into a subtract/add of the low bit with incremented/decremented constant:
2561
2545
// add (zext i1 (seteq (X & 1), 0)), C --> sub C+1, (zext (X & 1))
2562
2546
// sub C, (zext i1 (seteq (X & 1), 0)) --> add C-1, (zext (X & 1))
2563
2547
EVT VT = C.getValueType();
2564
- SDValue LowBit = DAG.getZExtOrTrunc(SetCC .getOperand(0), DL, VT);
2565
- SDValue C1 = IsAdd ? DAG.getConstant(CN->getAPIntValue() + 1, DL, VT) :
2566
- DAG.getConstant(CN->getAPIntValue() - 1, DL, VT);
2548
+ SDValue LowBit = DAG.getZExtOrTrunc(Z.getOperand(0) .getOperand(0), DL, VT);
2549
+ SDValue C1 = IsAdd ? DAG.getConstant(CN->getAPIntValue() + 1, DL, VT)
2550
+ : DAG.getConstant(CN->getAPIntValue() - 1, DL, VT);
2567
2551
return DAG.getNode(IsAdd ? ISD::SUB : ISD::ADD, DL, VT, C1, LowBit);
2568
2552
}
2569
2553
@@ -11554,13 +11538,12 @@ static SDValue foldVSelectToSignBitSplatMask(SDNode *N, SelectionDAG &DAG) {
11554
11538
SDValue N1 = N->getOperand(1);
11555
11539
SDValue N2 = N->getOperand(2);
11556
11540
EVT VT = N->getValueType(0);
11557
- if (N0.getOpcode() != ISD::SETCC || !N0.hasOneUse())
11558
- return SDValue();
11559
11541
11560
- SDValue Cond0 = N0.getOperand(0);
11561
- SDValue Cond1 = N0.getOperand(1);
11562
- ISD::CondCode CC = cast<CondCodeSDNode>(N0.getOperand(2))->get();
11563
- if (VT != Cond0.getValueType())
11542
+ SDValue Cond0, Cond1;
11543
+ ISD::CondCode CC;
11544
+ if (!sd_match(N0, m_OneUse(m_SetCC(m_Value(Cond0), m_Value(Cond1),
11545
+ m_CondCode(CC)))) ||
11546
+ VT != Cond0.getValueType())
11564
11547
return SDValue();
11565
11548
11566
11549
// Match a signbit check of Cond0 as "Cond0 s<0". Swap select operands if the
0 commit comments