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 @@ -1578,9 +1578,11 @@ bool isOne() const { return Value->isOne(); } bool isZero() const { return Value->isZero(); } - //bool isNullValue() const { return Value->isZero(); } + // NOTE: This is soft-deprecated. Please use `isZero()` instead. + bool isNullValue() const { return Value->isZero(); } bool isAllOnes() const { return Value->isMinusOne(); } - //bool isAllOnesValue() const { return Value->isMinusOne(); } + // NOTE: This is soft-deprecated. Please use `isAllOnes()` instead. + bool isAllOnesValue() const { return Value->isMinusOne(); } 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 @@ -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 @@ -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; @@ -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, 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) { 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/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/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/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/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);