diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1577,8 +1577,12 @@ Align getAlignValue() const { return Value->getAlignValue(); } bool isOne() const { return Value->isOne(); } - bool isNullValue() const { return Value->isZero(); } - bool isAllOnesValue() const { return Value->isMinusOne(); } + bool isZero() const { return Value->isZero(); } + // NOTE: This is soft-deprecated. Please use `isZero()` instead. + bool isNullValue() const { return isZero(); } + bool isAllOnes() const { return Value->isMinusOne(); } + // NOTE: This is soft-deprecated. Please use `isAllOnes()` instead. + bool isAllOnesValue() const { return isAllOnes(); } bool isMaxSignedValue() const { return Value->isMaxValue(true); } bool isMinSignedValue() const { return Value->isMinValue(true); } diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2781,7 +2781,7 @@ IsFlip = Const->isOne(); break; case TargetLowering::ZeroOrNegativeOneBooleanContent: - IsFlip = Const->isAllOnesValue(); + IsFlip = Const->isAllOnes(); break; case TargetLowering::UndefinedBooleanContent: IsFlip = (Const->getAPIntValue() & 0x01) == 1; @@ -3808,18 +3808,18 @@ return DAG.getNode(ISD::MUL, SDLoc(N), VT, N1, N0); // fold (mul x, 0) -> 0 - if (N1IsConst && ConstValue1.isNullValue()) + if (N1IsConst && ConstValue1.isZero()) return N1; // fold (mul x, 1) -> x - if (N1IsConst && ConstValue1.isOneValue()) + if (N1IsConst && ConstValue1.isOne()) return N0; if (SDValue NewSel = foldBinOpIntoSelect(N)) return NewSel; // fold (mul x, -1) -> 0-x - if (N1IsConst && ConstValue1.isAllOnesValue()) { + if (N1IsConst && ConstValue1.isAllOnes()) { SDLoc DL(N); return DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), N0); @@ -3966,7 +3966,7 @@ SmallBitVector ClearMask; ClearMask.reserve(NumElts); auto IsClearMask = [&ClearMask](ConstantSDNode *V) { - if (!V || V->isNullValue()) { + if (!V || V->isZero()) { ClearMask.push_back(true); return true; } @@ -4111,7 +4111,7 @@ // 0 / X -> 0 // 0 % X -> 0 ConstantSDNode *N0C = isConstOrConstSplat(N0); - if (N0C && N0C->isNullValue()) + if (N0C && N0C->isZero()) return N0; // X / X -> 1 @@ -4150,7 +4150,7 @@ return C; // fold (sdiv X, -1) -> 0-X - if (N1C && N1C->isAllOnesValue()) + if (N1C && N1C->isAllOnes()) return DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), N0); // fold (sdiv X, MIN_SIGNED) -> select(X == MIN_SIGNED, 1, 0) @@ -4204,7 +4204,7 @@ // Helper for determining whether a value is a power-2 constant scalar or a // vector of such elements. auto IsPowerOfTwo = [](ConstantSDNode *C) { - if (C->isNullValue() || C->isOpaque()) + if (C->isZero() || C->isOpaque()) return false; if (C->getAPIntValue().isPowerOf2()) return true; @@ -4295,7 +4295,7 @@ return C; // fold (udiv X, -1) -> select(X == -1, 1, 0) - if (N1C && N1C->getAPIntValue().isAllOnesValue()) + if (N1C && N1C->isAllOnes()) return DAG.getSelect(DL, VT, DAG.getSetCC(DL, CCVT, N0, N1, ISD::SETEQ), DAG.getConstant(1, DL, VT), DAG.getConstant(0, DL, VT)); @@ -4391,7 +4391,7 @@ return C; // fold (urem X, -1) -> select(X == -1, 0, x) - if (!isSigned && N1C && N1C->getAPIntValue().isAllOnesValue()) + if (!isSigned && N1C && N1C->isAllOnes()) return DAG.getSelect(DL, VT, DAG.getSetCC(DL, CCVT, N0, N1, ISD::SETEQ), DAG.getConstant(0, DL, VT), N0); @@ -5815,7 +5815,7 @@ case ISD::NON_EXTLOAD: B = true; break; } - if (B && Constant.isAllOnesValue()) { + if (B && Constant.isAllOnes()) { // If the load type was an EXTLOAD, convert to ZEXTLOAD in order to // preserve semantics once we get rid of the AND. SDValue NewLoad(Load, 0); @@ -9371,27 +9371,27 @@ // is also a target-independent combine here in DAGCombiner in the other // direction for (select Cond, -1, 0) when the condition is not i1. if (CondVT == MVT::i1 && !LegalOperations) { - if (C1->isNullValue() && C2->isOne()) { + if (C1->isZero() && C2->isOne()) { // select Cond, 0, 1 --> zext (!Cond) SDValue NotCond = DAG.getNOT(DL, Cond, MVT::i1); if (VT != MVT::i1) NotCond = DAG.getNode(ISD::ZERO_EXTEND, DL, VT, NotCond); return NotCond; } - if (C1->isNullValue() && C2->isAllOnesValue()) { + if (C1->isZero() && C2->isAllOnes()) { // select Cond, 0, -1 --> sext (!Cond) SDValue NotCond = DAG.getNOT(DL, Cond, MVT::i1); if (VT != MVT::i1) NotCond = DAG.getNode(ISD::SIGN_EXTEND, DL, VT, NotCond); return NotCond; } - if (C1->isOne() && C2->isNullValue()) { + if (C1->isOne() && C2->isZero()) { // select Cond, 1, 0 --> zext (Cond) if (VT != MVT::i1) Cond = DAG.getNode(ISD::ZERO_EXTEND, DL, VT, Cond); return Cond; } - if (C1->isAllOnesValue() && C2->isNullValue()) { + if (C1->isAllOnes() && C2->isZero()) { // select Cond, -1, 0 --> sext (Cond) if (VT != MVT::i1) Cond = DAG.getNode(ISD::SIGN_EXTEND, DL, VT, Cond); @@ -9447,7 +9447,7 @@ TargetLowering::ZeroOrOneBooleanContent && TLI.getBooleanContents(/*isVec*/false, /*isFloat*/false) == TargetLowering::ZeroOrOneBooleanContent && - C1->isNullValue() && C2->isOne()) { + C1->isZero() && C2->isOne()) { SDValue NotCond = DAG.getNode(ISD::XOR, DL, CondVT, Cond, DAG.getConstant(1, DL, CondVT)); if (VT.bitsEq(CondVT)) @@ -9716,8 +9716,8 @@ "same value. This should have been addressed before this function."); return DAG.getNode( ISD::CONCAT_VECTORS, DL, VT, - BottomHalf->isNullValue() ? RHS->getOperand(0) : LHS->getOperand(0), - TopHalf->isNullValue() ? RHS->getOperand(1) : LHS->getOperand(1)); + BottomHalf->isZero() ? RHS->getOperand(0) : LHS->getOperand(0), + TopHalf->isZero() ? RHS->getOperand(1) : LHS->getOperand(1)); } bool refineUniformBase(SDValue &BasePtr, SDValue &Index, SelectionDAG &DAG) { @@ -10203,7 +10203,7 @@ AddToWorklist(SCC.getNode()); if (ConstantSDNode *SCCC = dyn_cast(SCC.getNode())) { - if (!SCCC->isNullValue()) + if (!SCCC->isZero()) return N2; // cond always true -> true val else return N3; // cond always false -> false val @@ -10261,13 +10261,13 @@ // Is 'X Cond C' always true or false? auto IsAlwaysTrueOrFalse = [](ISD::CondCode Cond, ConstantSDNode *C) { - bool False = (Cond == ISD::SETULT && C->isNullValue()) || + bool False = (Cond == ISD::SETULT && C->isZero()) || (Cond == ISD::SETLT && C->isMinSignedValue()) || - (Cond == ISD::SETUGT && C->isAllOnesValue()) || + (Cond == ISD::SETUGT && C->isAllOnes()) || (Cond == ISD::SETGT && C->isMaxSignedValue()); - bool True = (Cond == ISD::SETULE && C->isAllOnesValue()) || + bool True = (Cond == ISD::SETULE && C->isAllOnes()) || (Cond == ISD::SETLE && C->isMaxSignedValue()) || - (Cond == ISD::SETUGE && C->isNullValue()) || + (Cond == ISD::SETUGE && C->isZero()) || (Cond == ISD::SETGE && C->isMinSignedValue()); return True || False; }; @@ -17395,7 +17395,7 @@ SDValue StoredVal = ST->getValue(); bool IsElementZero = false; if (ConstantSDNode *C = dyn_cast(StoredVal)) - IsElementZero = C->isNullValue(); + IsElementZero = C->isZero(); else if (ConstantFPSDNode *C = dyn_cast(StoredVal)) IsElementZero = C->getConstantFPValue()->isNullValue(); if (IsElementZero) { @@ -22748,7 +22748,7 @@ if (auto *SCCC = dyn_cast(SCC)) { // fold select_cc true, x, y -> x // fold select_cc false, x, y -> y - return !(SCCC->isNullValue()) ? N2 : N3; + return !(SCCC->isZero()) ? N2 : N3; } } @@ -22847,7 +22847,7 @@ // select_cc setne X, 0, ctlz_zero_undef(X), sizeof(X) -> ctlz(X) // select_cc setne X, 0, cttz(X), sizeof(X) -> cttz(X) // select_cc setne X, 0, cttz_zero_undef(X), sizeof(X) -> cttz(X) - if (N1C && N1C->isNullValue() && (CC == ISD::SETEQ || CC == ISD::SETNE)) { + if (N1C && N1C->isZero() && (CC == ISD::SETEQ || CC == ISD::SETNE)) { SDValue ValueOnZero = N2; SDValue Count = N3; // If the condition is NE instead of E, swap the operands. @@ -22878,8 +22878,8 @@ // Fold select_cc setlt X, 0, C, ~C -> xor (ashr X, BW-1), ~C if (!NotExtCompare && N1C && N2C && N3C && N2C->getAPIntValue() == ~N3C->getAPIntValue() && - ((N1C->isAllOnesValue() && CC == ISD::SETGT) || - (N1C->isNullValue() && CC == ISD::SETLT)) && + ((N1C->isAllOnes() && CC == ISD::SETGT) || + (N1C->isZero() && CC == ISD::SETLT)) && !TLI.shouldAvoidTransformToShift(VT, CmpOpVT.getScalarSizeInBits() - 1)) { SDValue ASR = DAG.getNode( ISD::SRA, DL, CmpOpVT, N0, @@ -22928,7 +22928,7 @@ return SDValue(); // Avoid division by zero. - if (C->isNullValue()) + if (C->isZero()) return SDValue(); SmallVector Built; diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -4251,8 +4251,7 @@ SDValue Op = Node->getOperand(IsStrict ? 1 : 0); SDValue Chain = IsStrict ? Node->getOperand(0) : SDValue(); EVT VT = Node->getValueType(0); - assert(cast(Node->getOperand(IsStrict ? 2 : 1)) - ->isNullValue() && + assert(cast(Node->getOperand(IsStrict ? 2 : 1))->isZero() && "Unable to expand as libcall if it is not normal rounding"); RTLIB::Libcall LC = RTLIB::getFPROUND(Op.getValueType(), VT); diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -4375,7 +4375,7 @@ if (CCCode == ISD::SETEQ || CCCode == ISD::SETNE) { if (RHSLo == RHSHi) { if (ConstantSDNode *RHSCST = dyn_cast(RHSLo)) { - if (RHSCST->isAllOnesValue()) { + if (RHSCST->isAllOnes()) { // Equality comparison to -1. NewLHS = DAG.getNode(ISD::AND, dl, LHSLo.getValueType(), LHSLo, LHSHi); @@ -4395,8 +4395,8 @@ // If this is a comparison of the sign bit, just look at the top part. // X > -1, x < 0 if (ConstantSDNode *CST = dyn_cast(NewRHS)) - if ((CCCode == ISD::SETLT && CST->isNullValue()) || // X < 0 - (CCCode == ISD::SETGT && CST->isAllOnesValue())) { // X > -1 + if ((CCCode == ISD::SETLT && CST->isZero()) || // X < 0 + (CCCode == ISD::SETGT && CST->isAllOnes())) { // X > -1 NewLHS = LHSHi; NewRHS = RHSHi; return; @@ -4447,9 +4447,11 @@ bool EqAllowed = (CCCode == ISD::SETLE || CCCode == ISD::SETGE || CCCode == ISD::SETUGE || CCCode == ISD::SETULE); - if ((EqAllowed && (HiCmpC && HiCmpC->isNullValue())) || - (!EqAllowed && ((HiCmpC && (HiCmpC->getAPIntValue() == 1)) || - (LoCmpC && LoCmpC->isNullValue())))) { + // FIXME: Is the HiCmpC->isOne() here correct for + // ZeroOrNegativeOneBooleanContent. + if ((EqAllowed && (HiCmpC && HiCmpC->isZero())) || + (!EqAllowed && + ((HiCmpC && HiCmpC->isOne()) || (LoCmpC && LoCmpC->isZero())))) { // For LE / GE, if high part is known false, ignore the low part. // For LT / GT: if low part is known false, return the high part. // if high part is known true, ignore the low part. diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -529,7 +529,7 @@ SDValue Arg = N->getOperand(2).getOperand(0); if (Arg.isUndef()) return DAG.getUNDEF(N->getValueType(0).getVectorElementType()); - unsigned Op = !cast(Arg)->isNullValue(); + unsigned Op = !cast(Arg)->isZero(); return GetScalarizedVector(N->getOperand(Op)); } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1926,7 +1926,7 @@ if (SameNumElts) return N1; if (auto *C = dyn_cast(Splat)) - if (C->isNullValue()) + if (C->isZero()) return N1; } @@ -3977,13 +3977,13 @@ // Special case decrementing a value (ADD X, -1): if (ConstantSDNode *CRHS = isConstOrConstSplat(Op.getOperand(1), DemandedElts)) - if (CRHS->isAllOnesValue()) { + if (CRHS->isAllOnes()) { KnownBits Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1); // If the input is known to be 0 or 1, the output is 0/-1, which is all // sign bits set. - if ((Known.Zero | 1).isAllOnesValue()) + if ((Known.Zero | 1).isAllOnes()) return VTBits; // If we are subtracting one from a positive number, there is no carry @@ -4002,12 +4002,12 @@ // Handle NEG. if (ConstantSDNode *CLHS = isConstOrConstSplat(Op.getOperand(0), DemandedElts)) - if (CLHS->isNullValue()) { + if (CLHS->isZero()) { KnownBits Known = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1); // If the input is known to be 0 or 1, the output is 0/-1, which is all // sign bits set. - if ((Known.Zero | 1).isAllOnesValue()) + if ((Known.Zero | 1).isAllOnes()) return VTBits; // If the input is known to be positive (the sign bit is known clear), @@ -4490,8 +4490,8 @@ "Floating point types unsupported - use isKnownNeverZeroFloat"); // If the value is a constant, we can obviously see if it is a zero or not. - if (ISD::matchUnaryPredicate( - Op, [](ConstantSDNode *C) { return !C->isNullValue(); })) + if (ISD::matchUnaryPredicate(Op, + [](ConstantSDNode *C) { return !C->isZero(); })) return true; // TODO: Recognize more cases here. @@ -4531,7 +4531,7 @@ static SDValue FoldSTEP_VECTOR(const SDLoc &DL, EVT VT, SDValue Step, SelectionDAG &DAG) { - if (cast(Step)->isNullValue()) + if (cast(Step)->isZero()) return DAG.getConstant(0, DL, VT); return SDValue(); @@ -5632,9 +5632,9 @@ N1.getValueType() == VT && "Binary operator types must match!"); // (X & 0) -> 0. This commonly occurs when legalizing i64 values, so it's // worth handling here. - if (N2C && N2C->isNullValue()) + if (N2C && N2C->isZero()) return N2; - if (N2C && N2C->isAllOnesValue()) // X & -1 -> X + if (N2C && N2C->isAllOnes()) // X & -1 -> X return N1; break; case ISD::OR: @@ -5646,7 +5646,7 @@ N1.getValueType() == VT && "Binary operator types must match!"); // (X ^|+- 0) -> X. This commonly occurs when legalizing i64 values, so // it's worth handling here. - if (N2C && N2C->isNullValue()) + if (N2C && N2C->isZero()) return N1; if ((Opcode == ISD::ADD || Opcode == ISD::SUB) && VT.isVector() && VT.getVectorElementType() == MVT::i1) @@ -5752,7 +5752,7 @@ // size of the value, the shift/rotate count is guaranteed to be zero. if (VT == MVT::i1) return N1; - if (N2C && N2C->isNullValue()) + if (N2C && N2C->isZero()) return N1; break; case ISD::FP_ROUND: @@ -6761,7 +6761,7 @@ if (FI && !MFI.isFixedObjectIndex(FI->getIndex())) DstAlignCanChange = true; bool IsZeroVal = - isa(Src) && cast(Src)->isNullValue(); + isa(Src) && cast(Src)->isZero(); if (!TLI.findOptimalMemOpLowering( MemOps, TLI.getMaxStoresPerMemset(OptSize), MemOp::Set(Size, DstAlignCanChange, Alignment, IsZeroVal, isVol), @@ -6850,7 +6850,7 @@ ConstantSDNode *ConstantSize = dyn_cast(Size); if (ConstantSize) { // Memcpy with size zero? Just return the original chain. - if (ConstantSize->isNullValue()) + if (ConstantSize->isZero()) return Chain; SDValue Result = getMemcpyLoadsAndStores( @@ -6965,7 +6965,7 @@ ConstantSDNode *ConstantSize = dyn_cast(Size); if (ConstantSize) { // Memmove with size zero? Just return the original chain. - if (ConstantSize->isNullValue()) + if (ConstantSize->isZero()) return Chain; SDValue Result = getMemmoveLoadsAndStores( @@ -7067,7 +7067,7 @@ ConstantSDNode *ConstantSize = dyn_cast(Size); if (ConstantSize) { // Memset with size zero? Just return the original chain. - if (ConstantSize->isNullValue()) + if (ConstantSize->isZero()) return Chain; SDValue Result = getMemsetStores(*this, dl, Chain, Dst, Src, @@ -8227,7 +8227,7 @@ // select true, T, F --> T // select false, T, F --> F if (auto *CondC = dyn_cast(Cond)) - return CondC->isNullValue() ? F : T; + return CondC->isZero() ? F : T; // TODO: This should simplify VSELECT with constant condition using something // like this (but check boolean contents to be complete?): @@ -9935,7 +9935,7 @@ bool llvm::isNullConstant(SDValue V) { ConstantSDNode *Const = dyn_cast(V); - return Const != nullptr && Const->isNullValue(); + return Const != nullptr && Const->isZero(); } bool llvm::isNullFPConstant(SDValue V) { @@ -9945,7 +9945,7 @@ bool llvm::isAllOnesConstant(SDValue V) { ConstantSDNode *Const = dyn_cast(V); - return Const != nullptr && Const->isAllOnesValue(); + return Const != nullptr && Const->isAllOnes(); } bool llvm::isOneConstant(SDValue V) { @@ -10079,7 +10079,7 @@ // TODO: may want to use peekThroughBitcast() here. ConstantSDNode *C = isConstOrConstSplat(N, AllowUndefs, /*AllowTruncation=*/true); - return C && C->isNullValue(); + return C && C->isZero(); } bool llvm::isOneOrOneSplat(SDValue N, bool AllowUndefs) { @@ -10093,7 +10093,7 @@ N = peekThroughBitcasts(N); unsigned BitWidth = N.getScalarValueSizeInBits(); ConstantSDNode *C = isConstOrConstSplat(N, AllowUndefs); - return C && C->isAllOnesValue() && C->getValueSizeInBits(0) == BitWidth; + return C && C->isAllOnes() && C->getValueSizeInBits(0) == BitWidth; } HandleSDNode::~HandleSDNode() { diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1359,8 +1359,7 @@ // If the RHS is a constant, see if we can change it. Don't alter a -1 // constant because that's a 'not' op, and that is better for combining // and codegen. - if (!C->isAllOnesValue() && - DemandedBits.isSubsetOf(C->getAPIntValue())) { + if (!C->isAllOnes() && DemandedBits.isSubsetOf(C->getAPIntValue())) { // We're flipping all demanded bits. Flip the undemanded bits too. SDValue New = TLO.DAG.getNOT(dl, Op0, VT); return TLO.CombineTo(Op, New); @@ -1368,7 +1367,7 @@ } // If we can't turn this into a 'not', try to shrink the constant. - if (!C || !C->isAllOnesValue()) + if (!C || !C->isAllOnes()) if (ShrinkDemandedConstant(Op, DemandedBits, DemandedElts, TLO)) return true; @@ -2252,7 +2251,7 @@ // is probably not useful (and could be detrimental). ConstantSDNode *C = isConstOrConstSplat(Op1); APInt HighMask = APInt::getHighBitsSet(BitWidth, DemandedBitsLZ); - if (C && !C->isAllOnesValue() && !C->isOne() && + if (C && !C->isAllOnes() && !C->isOne() && (C->getAPIntValue() | HighMask).isAllOnes()) { SDValue Neg1 = TLO.DAG.getAllOnesConstant(dl, VT); // Disable the nsw and nuw flags. We can no longer guarantee that we @@ -3146,7 +3145,7 @@ if (getBooleanContents(N->getValueType(0)) == UndefinedBooleanContent) return !CN->getAPIntValue()[0]; - return CN->isNullValue(); + return CN->isZero(); } bool TargetLowering::isExtendedTrueVal(const ConstantSDNode *N, EVT VT, @@ -3162,7 +3161,7 @@ return (N->isOne() && !SExt) || (SExt && (N->getValueType(0) != MVT::i1)); case TargetLowering::UndefinedBooleanContent: case TargetLowering::ZeroOrNegativeOneBooleanContent: - return N->isAllOnesValue() && SExt; + return N->isAllOnes() && SExt; } llvm_unreachable("Unexpected enumeration."); } @@ -3216,7 +3215,7 @@ // Bail out if the compare operand that we want to turn into a zero is // already a zero (otherwise, infinite loop). auto *YConst = dyn_cast(Y); - if (YConst && YConst->isNullValue()) + if (YConst && YConst->isZero()) return SDValue(); // Transform this into: ~X & Y == 0. @@ -3654,8 +3653,8 @@ (isConstFalseVal(N1C) || isExtendedTrueVal(N1C, N0->getValueType(0), SExt))) { - bool Inverse = (N1C->isNullValue() && Cond == ISD::SETEQ) || - (!N1C->isNullValue() && Cond == ISD::SETNE); + bool Inverse = (N1C->isZero() && Cond == ISD::SETEQ) || + (!N1C->isZero() && Cond == ISD::SETNE); if (!Inverse) return TopSetCC; @@ -3806,8 +3805,8 @@ // Otherwise, make this a use of a zext. return DAG.getSetCC(dl, VT, ZextOp, DAG.getConstant(C1 & Imm, dl, ExtDstTy), Cond); - } else if ((N1C->isNullValue() || N1C->isOne()) && - (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { + } else if ((N1C->isZero() || N1C->isOne()) && + (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { // SETCC (SETCC), [0|1], [EQ|NE] -> SETCC if (N0.getOpcode() == ISD::SETCC && isTypeLegal(VT) && VT.bitsLE(N0.getValueType()) && @@ -3900,7 +3899,7 @@ // icmp eq/ne (urem %x, %y), 0 // Iff %x has 0 or 1 bits set, and %y has at least 2 bits set, omit 'urem': // icmp eq/ne %x, 0 - if (N0.getOpcode() == ISD::UREM && N1C->isNullValue() && + if (N0.getOpcode() == ISD::UREM && N1C->isZero() && (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { KnownBits XKnown = DAG.computeKnownBits(N0.getOperand(0)); KnownBits YKnown = DAG.computeKnownBits(N0.getOperand(1)); @@ -3913,7 +3912,7 @@ if ((Cond == ISD::SETEQ || Cond == ISD::SETNE) && N0.getOpcode() == ISD::SRA && isa(N0.getOperand(1)) && N0.getConstantOperandAPInt(1) == OpVT.getScalarSizeInBits() - 1 && - N1C && N1C->isAllOnesValue()) { + N1C && N1C->isAllOnes()) { return DAG.getSetCC(dl, VT, N0.getOperand(0), DAG.getConstant(0, dl, OpVT), Cond == ISD::SETEQ ? ISD::SETLT : ISD::SETGE); @@ -5067,7 +5066,7 @@ SmallVector Shifts, Factors; auto BuildSDIVPattern = [&](ConstantSDNode *C) { - if (C->isNullValue()) + if (C->isZero()) return false; APInt Divisor = C->getAPIntValue(); unsigned Shift = Divisor.countTrailingZeros(); @@ -5275,7 +5274,7 @@ SmallVector MagicFactors, Factors, Shifts, ShiftMasks; auto BuildSDIVPattern = [&](ConstantSDNode *C) { - if (C->isNullValue()) + if (C->isZero()) return false; const APInt &Divisor = C->getAPIntValue(); @@ -5420,7 +5419,7 @@ SmallVector PreShifts, PostShifts, MagicFactors, NPQFactors; auto BuildUDIVPattern = [&](ConstantSDNode *C) { - if (C->isNullValue()) + if (C->isZero()) return false; // FIXME: We should use a narrower constant when the upper // bits are known to be zero. @@ -5634,7 +5633,7 @@ auto BuildUREMPattern = [&](ConstantSDNode *CDiv, ConstantSDNode *CCmp) { // Division by 0 is UB. Leave it to be constant-folded elsewhere. - if (CDiv->isNullValue()) + if (CDiv->isZero()) return false; const APInt &D = CDiv->getAPIntValue(); @@ -5875,7 +5874,7 @@ // TODO: Could support comparing with non-zero too. ConstantSDNode *CompTarget = isConstOrConstSplat(CompTargetNode); - if (!CompTarget || !CompTarget->isNullValue()) + if (!CompTarget || !CompTarget->isZero()) return SDValue(); bool HadIntMinDivisor = false; @@ -5888,7 +5887,7 @@ auto BuildSREMPattern = [&](ConstantSDNode *C) { // Division by 0 is UB. Leave it to be constant-folded elsewhere. - if (C->isNullValue()) + if (C->isZero()) return false; // FIXME: we don't fold `rem %X, -C` to `rem %X, C` in DAGCombine. @@ -8041,7 +8040,7 @@ ISD::CondCode CC = cast(Op.getOperand(2))->get(); SDLoc dl(Op); if (ConstantSDNode *C = dyn_cast(Op.getOperand(1))) { - if (C->isNullValue() && CC == ISD::SETEQ) { + if (C->isZero() && CC == ISD::SETEQ) { EVT VT = Op.getOperand(0).getValueType(); SDValue Zext = Op.getOperand(0); if (VT.bitsLT(MVT::i32)) { diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -167,7 +167,7 @@ case ISD::SPLAT_VECTOR: { auto Opnd0 = N->getOperand(0); if (auto CN = dyn_cast(Opnd0)) - if (CN->isNullValue()) + if (CN->isZero()) return true; if (auto CN = dyn_cast(Opnd0)) if (CN->isZero()) @@ -187,7 +187,7 @@ case ISD::SPLAT_VECTOR: { auto Opnd0 = N->getOperand(0); if (auto CN = dyn_cast(Opnd0)) - if (CN->isNullValue()) + if (CN->isZero()) return true; if (auto CN = dyn_cast(Opnd0)) if (CN->isZero()) @@ -3520,7 +3520,7 @@ // Materialize zero constants as copies from WZR/XZR. This allows // the coalescer to propagate these into other instructions. ConstantSDNode *ConstNode = cast(Node); - if (ConstNode->isNullValue()) { + if (ConstNode->isZero()) { if (VT == MVT::i32) { SDValue New = CurDAG->getCopyFromReg( CurDAG->getEntryNode(), SDLoc(Node), AArch64::WZR, MVT::i32); diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -2308,7 +2308,7 @@ auto Opnd0 = N->getOperand(0); auto *CINT = dyn_cast(Opnd0); auto *CFP = dyn_cast(Opnd0); - return (CINT && CINT->isNullValue()) || (CFP && CFP->isZero()); + return (CINT && CINT->isZero()) || (CFP && CFP->isZero()); } /// changeIntCCToAArch64CC - Convert a DAG integer condition code to an AArch64 @@ -2990,9 +2990,9 @@ } } - if (!Cmp && (RHSC->isNullValue() || RHSC->isOne())) { + if (!Cmp && (RHSC->isZero() || RHSC->isOne())) { if ((Cmp = emitConjunction(DAG, LHS, AArch64CC))) { - if ((CC == ISD::SETNE) ^ RHSC->isNullValue()) + if ((CC == ISD::SETNE) ^ RHSC->isZero()) AArch64CC = AArch64CC::getInvertedCondCode(AArch64CC); } } @@ -3157,14 +3157,14 @@ // We can commute the SELECT_CC by inverting the condition. This // might be needed to make this fit into a CSINV pattern. - if (CTVal->isAllOnesValue() && CFVal->isNullValue()) { + if (CTVal->isAllOnes() && CFVal->isZero()) { std::swap(TVal, FVal); std::swap(CTVal, CFVal); CC = ISD::getSetCCInverse(CC, LHS.getValueType()); } // If the constants line up, perform the transform! - if (CTVal->isNullValue() && CFVal->isAllOnesValue()) { + if (CTVal->isZero() && CFVal->isAllOnes()) { SDValue CCVal; SDValue Cmp = getAArch64Cmp(LHS, RHS, CC, CCVal, DAG, dl); @@ -7433,8 +7433,8 @@ // Check for sign pattern (SELECT_CC setgt, iN lhs, -1, 1, -1) and transform // into (OR (ASR lhs, N-1), 1), which requires less instructions for the // supported types. - if (CC == ISD::SETGT && RHSC && RHSC->isAllOnesValue() && CTVal && CFVal && - CTVal->isOne() && CFVal->isAllOnesValue() && + if (CC == ISD::SETGT && RHSC && RHSC->isAllOnes() && CTVal && CFVal && + CTVal->isOne() && CFVal->isAllOnes() && LHS.getValueType() == TVal.getValueType()) { EVT VT = LHS.getValueType(); SDValue Shift = @@ -7447,11 +7447,11 @@ // If both the TVal and the FVal are constants, see if we can swap them in // order to for a CSINV or CSINC out of them. - if (CTVal && CFVal && CTVal->isAllOnesValue() && CFVal->isNullValue()) { + if (CTVal && CFVal && CTVal->isAllOnes() && CFVal->isZero()) { std::swap(TVal, FVal); std::swap(CTVal, CFVal); CC = ISD::getSetCCInverse(CC, LHS.getValueType()); - } else if (CTVal && CFVal && CTVal->isOne() && CFVal->isNullValue()) { + } else if (CTVal && CFVal && CTVal->isOne() && CFVal->isZero()) { std::swap(TVal, FVal); std::swap(CTVal, CFVal); CC = ISD::getSetCCInverse(CC, LHS.getValueType()); @@ -7530,7 +7530,7 @@ // FVal, respectively. ConstantSDNode *RHSVal = dyn_cast(RHS); if (Opcode == AArch64ISD::CSEL && RHSVal && !RHSVal->isOne() && - !RHSVal->isNullValue() && !RHSVal->isAllOnesValue()) { + !RHSVal->isZero() && !RHSVal->isAllOnes()) { AArch64CC::CondCode AArch64CC = changeIntCCToAArch64CC(CC); // Transform "a == C ? C : x" to "a == C ? a : x" and "a != C ? x : C" to // "a != C ? x : a" to avoid materializing C. @@ -9643,7 +9643,7 @@ // The only legal i1 vectors are SVE vectors, so we can use SVE-specific // lowering code. if (auto *ConstVal = dyn_cast(SplatVal)) { - if (ConstVal->isNullValue()) + if (ConstVal->isZero()) return SDValue(DAG.getMachineNode(AArch64::PFALSE, dl, VT), 0); if (ConstVal->isOne()) return getPTrue(DAG, dl, VT, AArch64SVEPredPattern::all); @@ -13967,7 +13967,7 @@ SetCCInfo.Info.AArch64.CC = AArch64CC::getInvertedCondCode(SetCCInfo.Info.AArch64.CC); } - return TValue->isOne() && FValue->isNullValue(); + return TValue->isOne() && FValue->isZero(); } // Returns true if Op is setcc or zext of setcc. @@ -14045,7 +14045,7 @@ auto *LHSN1 = dyn_cast(LHS->getOperand(1)); auto *RHSN1 = dyn_cast(RHS->getOperand(1)); - if (!LHSN1 || LHSN1 != RHSN1 || !RHSN1->isNullValue()) + if (!LHSN1 || LHSN1 != RHSN1 || !RHSN1->isZero()) return SDValue(); SDValue Op1 = LHS->getOperand(0); diff --git a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp --- a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp @@ -24,8 +24,10 @@ ConstantSDNode *SizeValue = dyn_cast(Size); const AArch64Subtarget &STI = DAG.getMachineFunction().getSubtarget(); - const char *bzeroName = (V && V->isNullValue()) - ? DAG.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO) : nullptr; + const char *bzeroName = + (V && V->isZero()) + ? DAG.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO) + : nullptr; // For small size (< 256), it is not beneficial to use bzero // instead of memset. if (bzeroName && (!SizeValue || SizeValue->getZExtValue() > 256)) { diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -52,7 +52,7 @@ return true; ConstantSDNode *Const = dyn_cast(V); - return Const != nullptr && Const->isNullValue(); + return Const != nullptr && Const->isZero(); } static bool getConstantValue(SDValue N, uint32_t &Out) { @@ -354,7 +354,7 @@ static SDValue stripExtractLoElt(SDValue In) { if (In.getOpcode() == ISD::EXTRACT_VECTOR_ELT) { if (ConstantSDNode *Idx = dyn_cast(In.getOperand(1))) { - if (Idx->isNullValue() && In.getValueSizeInBits() <= 32) + if (Idx->isZero() && In.getValueSizeInBits() <= 32) return In.getOperand(0); } } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -3532,7 +3532,7 @@ static bool isNegativeOne(SDValue Val) { if (ConstantSDNode *C = dyn_cast(Val)) - return C->isAllOnesValue(); + return C->isAllOnes(); return false; } @@ -3567,7 +3567,7 @@ SDValue LHS, SDValue RHS, DAGCombinerInfo &DCI) const { ConstantSDNode *CmpRhs = dyn_cast(Cond.getOperand(1)); - if (!CmpRhs || !CmpRhs->isNullValue()) + if (!CmpRhs || !CmpRhs->isZero()) return SDValue(); SelectionDAG &DAG = DCI.DAG; diff --git a/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp b/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp --- a/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/R600ISelLowering.cpp @@ -828,7 +828,7 @@ bool R600TargetLowering::isZero(SDValue Op) const { if(ConstantSDNode *Cst = dyn_cast(Op)) { - return Cst->isNullValue(); + return Cst->isZero(); } else if(ConstantFPSDNode *CstFP = dyn_cast(Op)){ return CstFP->isZero(); } else { diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -4844,7 +4844,7 @@ } if (const ConstantSDNode *Arg = dyn_cast(Src)) { // (ballot 0) -> 0 - if (Arg->isNullValue()) + if (Arg->isZero()) return DAG.getConstant(0, SL, VT); // (ballot 1) -> EXEC/EXEC_LO @@ -6153,7 +6153,7 @@ if (MIPMappingInfo) { if (auto *ConstantLod = dyn_cast( Op.getOperand(ArgOffset + Intr->MipIndex))) { - if (ConstantLod->isNullValue()) { + if (ConstantLod->isZero()) { IntrOpcode = MIPMappingInfo->NONMIP; // set new opcode to variant without _mip VAddrEnd--; // remove 'mip' } @@ -6688,7 +6688,7 @@ // intrinsic has the numerator as the first operand to match a normal // division operation. - SDValue Src0 = Param->isAllOnesValue() ? Numerator : Denominator; + SDValue Src0 = Param->isAllOnes() ? Numerator : Denominator; return DAG.getNode(AMDGPUISD::DIV_SCALE, DL, Op->getVTList(), Src0, Denominator, Numerator); @@ -6822,7 +6822,7 @@ } if (VIndex && (!isa(VIndex) || - !cast(VIndex)->isNullValue())) { + !cast(VIndex)->isZero())) { // The strided index component of the address is not known to be zero, so we // cannot represent it in the MMO. Give up. MMO->setValue((Value *)nullptr); @@ -7667,7 +7667,7 @@ Op.getOperand(0) // Chain }; - unsigned Opc = Done->isNullValue() ? AMDGPU::EXP : AMDGPU::EXP_DONE; + unsigned Opc = Done->isZero() ? AMDGPU::EXP : AMDGPU::EXP_DONE; return SDValue(DAG.getMachineNode(Opc, DL, Op->getVTList(), Ops), 0); } case Intrinsic::amdgcn_s_barrier: { @@ -9512,7 +9512,7 @@ // fp_class x, 0 -> false if (const ConstantSDNode *CMask = dyn_cast(Mask)) { - if (CMask->isNullValue()) + if (CMask->isZero()) return DAG.getConstant(0, SDLoc(N), MVT::i1); } @@ -10501,7 +10501,7 @@ if (LHS.getOpcode() == ISD::SUBCARRY) { // sub (subcarry x, 0, cc), y => subcarry x, y, cc auto C = dyn_cast(LHS.getOperand(1)); - if (!C || !C->isNullValue()) + if (!C || !C->isZero()) return SDValue(); SDValue Args[] = { LHS.getOperand(0), RHS, LHS.getOperand(2) }; return DAG.getNode(ISD::SUBCARRY, SDLoc(N), LHS->getVTList(), Args); @@ -10724,15 +10724,15 @@ // setcc (sext from i1 cc), -1, eq|sle|uge) => cc // setcc (sext from i1 cc), 0, eq|sge|ule) => not cc => xor cc, -1 // setcc (sext from i1 cc), 0, ne|ugt|slt) => cc - if ((CRHS->isAllOnesValue() && + if ((CRHS->isAllOnes() && (CC == ISD::SETNE || CC == ISD::SETGT || CC == ISD::SETULT)) || - (CRHS->isNullValue() && + (CRHS->isZero() && (CC == ISD::SETEQ || CC == ISD::SETGE || CC == ISD::SETULE))) return DAG.getNode(ISD::XOR, SL, MVT::i1, LHS.getOperand(0), DAG.getConstant(-1, SL, MVT::i1)); - if ((CRHS->isAllOnesValue() && + if ((CRHS->isAllOnes() && (CC == ISD::SETEQ || CC == ISD::SETLE || CC == ISD::SETUGE)) || - (CRHS->isNullValue() && + (CRHS->isZero() && (CC == ISD::SETNE || CC == ISD::SETUGT || CC == ISD::SETLT))) return LHS.getOperand(0); } diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp --- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -1125,7 +1125,7 @@ SDValue &Offset) { if (N.getOpcode() != ISD::ADD && !CurDAG->isBaseWithConstantOffset(N)) { ConstantSDNode *NC = dyn_cast(N); - if (!NC || !NC->isNullValue()) + if (!NC || !NC->isZero()) return false; Base = Offset = N; @@ -3556,7 +3556,7 @@ return; SDValue Zero = N->getOperand(1); - if (!isa(Zero) || !cast(Zero)->isNullValue() || + if (!isa(Zero) || !cast(Zero)->isZero() || And->getOpcode() != ISD::AND) return; SDValue X = And.getOperand(0); diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -9139,7 +9139,7 @@ Hi1->getSExtValue() == Lo1->getSExtValue() >> 32) return true; } else { - if (Hi0->isNullValue() && Hi1->isNullValue()) + if (Hi0->isZero() && Hi1->isZero()) return true; } return false; @@ -17261,7 +17261,7 @@ auto *Const = dyn_cast(N.getOperand(1)); if (!Const) return SDValue(); - if (Const->isNullValue()) + if (Const->isZero()) Imm = 0; else if (Const->isOne()) Imm = 1; @@ -17313,7 +17313,7 @@ Cond = N->getOperand(2); Dest = N->getOperand(4); if (auto *Const = dyn_cast(N->getOperand(3))) { - if (!Const->isOne() && !Const->isNullValue()) + if (!Const->isOne() && !Const->isZero()) return SDValue(); Imm = Const->getZExtValue(); } else diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp --- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp @@ -990,7 +990,7 @@ auto IsZero = [] (const SDValue &V) -> bool { if (ConstantSDNode *SC = dyn_cast(V.getNode())) - return SC->isNullValue(); + return SC->isZero(); return false; }; auto IsSelect0 = [IsZero] (const SDValue &Op) -> bool { diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp --- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp @@ -2556,7 +2556,7 @@ // Extracting the lowest bit is a no-op, but it changes the type, // so it must be kept as an operation to avoid errors related to // type mismatches. - if (IdxN->isNullValue() && ValTy.getSizeInBits() == 1) + if (IdxN->isZero() && ValTy.getSizeInBits() == 1) return DAG.getNode(HexagonISD::TYPECAST, dl, MVT::i1, VecV); } diff --git a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp --- a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp @@ -525,7 +525,7 @@ if (IsSplat) { assert(SplatV.getNode()); auto *IdxN = dyn_cast(SplatV.getNode()); - if (IdxN && IdxN->isNullValue()) + if (IdxN && IdxN->isZero()) return getZero(dl, VecTy, DAG); MVT WordTy = MVT::getVectorVT(MVT::i32, HwLen/4); SDValue S = DAG.getNode(ISD::SPLAT_VECTOR, dl, WordTy, SplatV); @@ -743,12 +743,12 @@ auto IsTrue = [] (SDValue V) { if (const auto *N = dyn_cast(V.getNode())) - return !N->isNullValue(); + return !N->isZero(); return false; }; auto IsFalse = [] (SDValue V) { if (const auto *N = dyn_cast(V.getNode())) - return N->isNullValue(); + return N->isZero(); return false; }; @@ -1065,7 +1065,7 @@ assert(SubTy.getSizeInBits() == 32 || SubTy.getSizeInBits() == 64); // Convert IdxV to be index in bytes. auto *IdxN = dyn_cast(IdxV.getNode()); - if (!IdxN || !IdxN->isNullValue()) { + if (!IdxN || !IdxN->isZero()) { IdxV = DAG.getNode(ISD::MUL, dl, MVT::i32, IdxV, DAG.getConstant(ElemWidth/8, dl, MVT::i32)); SingleV = DAG.getNode(HexagonISD::VROR, dl, SingleTy, SingleV, IdxV); @@ -1088,7 +1088,7 @@ RolBase = HwLen-4; } // If the vector wasn't ror'ed, don't ror it back. - if (RolBase != 4 || !IdxN || !IdxN->isNullValue()) { + if (RolBase != 4 || !IdxN || !IdxN->isZero()) { SDValue RolV = DAG.getNode(ISD::SUB, dl, MVT::i32, DAG.getConstant(RolBase, dl, MVT::i32), IdxV); SingleV = DAG.getNode(HexagonISD::VROR, dl, SingleTy, SingleV, RolV); @@ -1125,7 +1125,7 @@ SDValue ByteIdx; auto *IdxN = dyn_cast(IdxV.getNode()); - if (!IdxN || !IdxN->isNullValue()) { + if (!IdxN || !IdxN->isZero()) { ByteIdx = DAG.getNode(ISD::MUL, dl, MVT::i32, IdxV, DAG.getConstant(BitBytes, dl, MVT::i32)); ByteVec = DAG.getNode(HexagonISD::VROR, dl, ByteTy, ByteVec, ByteIdx); @@ -1140,7 +1140,7 @@ {DAG.getConstant(BlockLen, dl, MVT::i32)}, DAG); ByteVec = getInstr(Hexagon::V6_vmux, dl, ByteTy, {Q, ByteSub, ByteVec}, DAG); // Rotate ByteVec back, and convert to a vector predicate. - if (!IdxN || !IdxN->isNullValue()) { + if (!IdxN || !IdxN->isZero()) { SDValue HwLenV = DAG.getConstant(HwLen, dl, MVT::i32); SDValue ByteXdi = DAG.getNode(ISD::SUB, dl, MVT::i32, HwLenV, ByteIdx); ByteVec = DAG.getNode(HexagonISD::VROR, dl, ByteTy, ByteVec, ByteXdi); @@ -2255,8 +2255,8 @@ case HexagonISD::V2Q: if (Ops[0].getOpcode() == ISD::SPLAT_VECTOR) { if (const auto *C = dyn_cast(Ops[0].getOperand(0))) - return C->isNullValue() ? DAG.getNode(HexagonISD::QFALSE, dl, ty(Op)) - : DAG.getNode(HexagonISD::QTRUE, dl, ty(Op)); + return C->isZero() ? DAG.getNode(HexagonISD::QFALSE, dl, ty(Op)) + : DAG.getNode(HexagonISD::QTRUE, dl, ty(Op)); } break; case HexagonISD::Q2V: diff --git a/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp b/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp --- a/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp +++ b/llvm/lib/Target/Lanai/LanaiISelDAGToDAG.cpp @@ -287,14 +287,14 @@ ConstantSDNode *ConstNode = cast(Node); // Materialize zero constants as copies from R0. This allows the coalescer // to propagate these into other instructions. - if (ConstNode->isNullValue()) { + if (ConstNode->isZero()) { SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), SDLoc(Node), Lanai::R0, MVT::i32); return ReplaceNode(Node, New.getNode()); } // Materialize all ones constants as copies from R1. This allows the // coalescer to propagate these into other instructions. - if (ConstNode->isAllOnesValue()) { + if (ConstNode->isAllOnes()) { SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), SDLoc(Node), Lanai::R1, MVT::i32); return ReplaceNode(Node, New.getNode()); diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp --- a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp +++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp @@ -1150,7 +1150,7 @@ // lowering & isel wouldn't diverge. bool andCC = false; if (ConstantSDNode *RHSC = dyn_cast(RHS)) { - if (RHSC->isNullValue() && LHS.hasOneUse() && + if (RHSC->isZero() && LHS.hasOneUse() && (LHS.getOpcode() == ISD::AND || (LHS.getOpcode() == ISD::TRUNCATE && LHS.getOperand(0).getOpcode() == ISD::AND))) { diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -3186,7 +3186,7 @@ // by swapping inputs and falling through. std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); LLVM_FALLTHROUGH; } case ISD::SETLE: { @@ -3236,7 +3236,7 @@ // (%b < %a) by swapping inputs and falling through. std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); IsRHSOne = RHSConst && RHSConst->getSExtValue() == 1; LLVM_FALLTHROUGH; } @@ -3370,7 +3370,7 @@ // by swapping inputs and falling through. std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); LLVM_FALLTHROUGH; } case ISD::SETLE: { @@ -3415,7 +3415,7 @@ // (%b < %a) by swapping inputs and falling through. std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); IsRHSOne = RHSConst && RHSConst->getSExtValue() == 1; LLVM_FALLTHROUGH; } @@ -3528,7 +3528,7 @@ return getCompoundZeroComparisonInGPR(LHS, dl, ZeroCompare::GEZExt); std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); LLVM_FALLTHROUGH; } case ISD::SETLE: { @@ -3570,7 +3570,7 @@ } std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); IsRHSOne = RHSConst && RHSConst->getSExtValue() == 1; LLVM_FALLTHROUGH; } @@ -3687,7 +3687,7 @@ return getCompoundZeroComparisonInGPR(LHS, dl, ZeroCompare::GESExt); std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); LLVM_FALLTHROUGH; } case ISD::SETLE: { @@ -3730,7 +3730,7 @@ } std::swap(LHS, RHS); ConstantSDNode *RHSConst = dyn_cast(RHS); - IsRHSZero = RHSConst && RHSConst->isNullValue(); + IsRHSZero = RHSConst && RHSConst->isZero(); IsRHSOne = RHSConst && RHSConst->getSExtValue() == 1; LLVM_FALLTHROUGH; } @@ -5423,8 +5423,8 @@ if (ConstantSDNode *N1C = dyn_cast(N->getOperand(1))) if (ConstantSDNode *N2C = dyn_cast(N->getOperand(2))) if (ConstantSDNode *N3C = dyn_cast(N->getOperand(3))) - if (N1C->isNullValue() && N3C->isNullValue() && - N2C->getZExtValue() == 1ULL && CC == ISD::SETNE && + if (N1C->isZero() && N3C->isZero() && N2C->getZExtValue() == 1ULL && + CC == ISD::SETNE && // FIXME: Implement this optzn for PPC64. N->getValueType(0) == MVT::i32) { SDNode *Tmp = @@ -6180,7 +6180,7 @@ if (!C) return false; - if (!C->isNullValue()) + if (!C->isZero()) return false; } diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -3509,7 +3509,7 @@ // Leave comparisons against 0 and -1 alone for now, since they're usually // optimized. FIXME: revisit this when we can custom lower all setcc // optimizations. - if (C->isAllOnesValue() || C->isNullValue()) + if (C->isAllOnes() || C->isZero()) return SDValue(); } @@ -14853,8 +14853,8 @@ break; case PPCISD::SRA: if (ConstantSDNode *C = dyn_cast(N->getOperand(0))) { - if (C->isNullValue() || // 0 >>s V -> 0. - C->isAllOnesValue()) // -1 >>s V -> -1. + if (C->isZero() || // 0 >>s V -> 0. + C->isAllOnes()) // -1 >>s V -> -1. return N->getOperand(0); } break; diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -467,7 +467,7 @@ switch (Opcode) { case ISD::Constant: { auto *ConstNode = cast(Node); - if (VT == XLenVT && ConstNode->isNullValue()) { + if (VT == XLenVT && ConstNode->isZero()) { SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, RISCV::X0, XLenVT); ReplaceNode(Node, New.getNode()); 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 @@ -5239,16 +5239,16 @@ SelectionDAG &DAG) { if (!isFP) { if (ConstantSDNode *RHSC = dyn_cast(RHS)) { - if (SetCCOpcode == ISD::SETGT && RHSC->isAllOnesValue()) { + if (SetCCOpcode == ISD::SETGT && RHSC->isAllOnes()) { // X > -1 -> X == 0, jump !sign. RHS = DAG.getConstant(0, DL, RHS.getValueType()); return X86::COND_NS; } - if (SetCCOpcode == ISD::SETLT && RHSC->isNullValue()) { + if (SetCCOpcode == ISD::SETLT && RHSC->isZero()) { // X < 0 -> X == 0, jump on sign. return X86::COND_S; } - if (SetCCOpcode == ISD::SETGE && RHSC->isNullValue()) { + if (SetCCOpcode == ISD::SETGE && RHSC->isZero()) { // X >= 0 -> X == 0, jump on !sign. return X86::COND_NS; } @@ -41038,9 +41038,9 @@ VT.isVector() && VT.getVectorElementType() == MVT::i1 && isa(N0)) { auto *C = cast(N0); - if (C->isAllOnesValue()) + if (C->isAllOnes()) return DAG.getConstant(1, SDLoc(N0), VT); - if (C->isNullValue()) + if (C->isZero()) return DAG.getConstant(0, SDLoc(N0), VT); } @@ -42267,7 +42267,7 @@ R = DAG.getNode(ISD::MUL, DL, VT, R, DAG.getConstant(AbsDiff, DL, VT)); // Add the base if non-zero. - if (!FalseC->isNullValue()) + if (!FalseC->isZero()) R = DAG.getNode(ISD::ADD, DL, VT, R, SDValue(FalseC, 0)); return R; @@ -50409,8 +50409,8 @@ // the general case below. auto *ConstantX = dyn_cast(X); if (ConstantX) { - if ((!IsSub && CC == X86::COND_AE && ConstantX->isAllOnesValue()) || - (IsSub && CC == X86::COND_B && ConstantX->isNullValue())) { + if ((!IsSub && CC == X86::COND_AE && ConstantX->isAllOnes()) || + (IsSub && CC == X86::COND_B && ConstantX->isZero())) { // This is a complicated way to get -1 or 0 from the carry flag: // -1 + SETAE --> -1 + (!CF) --> CF ? -1 : 0 --> SBB %eax, %eax // 0 - SETB --> 0 - (CF) --> CF ? -1 : 0 --> SBB %eax, %eax @@ -50419,8 +50419,8 @@ Y.getOperand(1)); } - if ((!IsSub && CC == X86::COND_BE && ConstantX->isAllOnesValue()) || - (IsSub && CC == X86::COND_A && ConstantX->isNullValue())) { + if ((!IsSub && CC == X86::COND_BE && ConstantX->isAllOnes()) || + (IsSub && CC == X86::COND_A && ConstantX->isZero())) { SDValue EFLAGS = Y->getOperand(1); if (EFLAGS.getOpcode() == X86ISD::SUB && EFLAGS.hasOneUse() && EFLAGS.getValueType().isInteger() && @@ -50518,8 +50518,8 @@ // fake operands: // 0 - (Z != 0) --> sbb %eax, %eax, (neg Z) // -1 + (Z == 0) --> sbb %eax, %eax, (neg Z) - if ((IsSub && CC == X86::COND_NE && ConstantX->isNullValue()) || - (!IsSub && CC == X86::COND_E && ConstantX->isAllOnesValue())) { + if ((IsSub && CC == X86::COND_NE && ConstantX->isZero()) || + (!IsSub && CC == X86::COND_E && ConstantX->isAllOnes())) { SDValue Zero = DAG.getConstant(0, DL, ZVT); SDVTList X86SubVTs = DAG.getVTList(ZVT, MVT::i32); SDValue Neg = DAG.getNode(X86ISD::SUB, DL, X86SubVTs, Zero, Z); @@ -50532,8 +50532,8 @@ // with fake operands: // 0 - (Z == 0) --> sbb %eax, %eax, (cmp Z, 1) // -1 + (Z != 0) --> sbb %eax, %eax, (cmp Z, 1) - if ((IsSub && CC == X86::COND_E && ConstantX->isNullValue()) || - (!IsSub && CC == X86::COND_NE && ConstantX->isAllOnesValue())) { + if ((IsSub && CC == X86::COND_E && ConstantX->isZero()) || + (!IsSub && CC == X86::COND_NE && ConstantX->isAllOnes())) { SDValue One = DAG.getConstant(1, DL, ZVT); SDVTList X86SubVTs = DAG.getVTList(ZVT, MVT::i32); SDValue Cmp1 = DAG.getNode(X86ISD::SUB, DL, X86SubVTs, Z, One); @@ -51681,7 +51681,7 @@ Src.hasOneUse() && Src.getOperand(0).getValueType().isVector() && Src.getOperand(0).getValueType().getVectorElementType() == MVT::i1) if (auto *C = dyn_cast(Src.getOperand(1))) - if (C->isNullValue()) + if (C->isZero()) return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Src.getOperand(0), Src.getOperand(1)); diff --git a/llvm/lib/Target/X86/X86SelectionDAGInfo.cpp b/llvm/lib/Target/X86/X86SelectionDAGInfo.cpp --- a/llvm/lib/Target/X86/X86SelectionDAGInfo.cpp +++ b/llvm/lib/Target/X86/X86SelectionDAGInfo.cpp @@ -71,9 +71,10 @@ // Check to see if there is a specialized entry-point for memory zeroing. ConstantSDNode *ValC = dyn_cast(Val); - if (const char *bzeroName = (ValC && ValC->isNullValue()) - ? DAG.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO) - : nullptr) { + if (const char *bzeroName = + (ValC && ValC->isZero()) + ? DAG.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO) + : nullptr) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout()); Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext()); diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.cpp b/llvm/lib/Target/XCore/XCoreISelLowering.cpp --- a/llvm/lib/Target/XCore/XCoreISelLowering.cpp +++ b/llvm/lib/Target/XCore/XCoreISelLowering.cpp @@ -1643,7 +1643,7 @@ return DAG.getNode(XCoreISD::LADD, dl, DAG.getVTList(VT, VT), N1, N0, N2); // fold (ladd 0, 0, x) -> 0, x & 1 - if (N0C && N0C->isNullValue() && N1C && N1C->isNullValue()) { + if (N0C && N0C->isZero() && N1C && N1C->isZero()) { SDValue Carry = DAG.getConstant(0, dl, VT); SDValue Result = DAG.getNode(ISD::AND, dl, VT, N2, DAG.getConstant(1, dl, VT)); @@ -1653,7 +1653,7 @@ // fold (ladd x, 0, y) -> 0, add x, y iff carry is unused and y has only the // low bit set - if (N1C && N1C->isNullValue() && N->hasNUsesOfValue(0, 1)) { + if (N1C && N1C->isZero() && N->hasNUsesOfValue(0, 1)) { APInt Mask = APInt::getHighBitsSet(VT.getSizeInBits(), VT.getSizeInBits() - 1); KnownBits Known = DAG.computeKnownBits(N2); @@ -1675,7 +1675,7 @@ EVT VT = N0.getValueType(); // fold (lsub 0, 0, x) -> x, -x iff x has only the low bit set - if (N0C && N0C->isNullValue() && N1C && N1C->isNullValue()) { + if (N0C && N0C->isZero() && N1C && N1C->isZero()) { APInt Mask = APInt::getHighBitsSet(VT.getSizeInBits(), VT.getSizeInBits() - 1); KnownBits Known = DAG.computeKnownBits(N2); @@ -1690,7 +1690,7 @@ // fold (lsub x, 0, y) -> 0, sub x, y iff borrow is unused and y has only the // low bit set - if (N1C && N1C->isNullValue() && N->hasNUsesOfValue(0, 1)) { + if (N1C && N1C->isZero() && N->hasNUsesOfValue(0, 1)) { APInt Mask = APInt::getHighBitsSet(VT.getSizeInBits(), VT.getSizeInBits() - 1); KnownBits Known = DAG.computeKnownBits(N2); @@ -1719,7 +1719,7 @@ N1, N0, N2, N3); // lmul(x, 0, a, b) - if (N1C && N1C->isNullValue()) { + if (N1C && N1C->isZero()) { // If the high result is unused fold to add(a, b) if (N->hasNUsesOfValue(0, 0)) { SDValue Lo = DAG.getNode(ISD::ADD, dl, VT, N2, N3);