diff options
author | Jay Foad <jay.foad@amd.com> | 2021-09-30 09:54:57 +0100 |
---|---|---|
committer | Jay Foad <jay.foad@amd.com> | 2021-10-04 08:57:44 +0100 |
commit | a9bceb2b059dc24870882a71baece895fe430107 (patch) | |
tree | df54e088f349b1acf32e20d3819ee000ec0a0677 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 0873b9bef4e03b4cfc44a4946c11103c763055df (diff) | |
download | llvm-a9bceb2b059dc24870882a71baece895fe430107.zip llvm-a9bceb2b059dc24870882a71baece895fe430107.tar.gz llvm-a9bceb2b059dc24870882a71baece895fe430107.tar.bz2 |
[APInt] Stop using soft-deprecated constructors and methods in llvm. NFC.
Stop using APInt constructors and methods that were soft-deprecated in
D109483. This fixes all the uses I found in llvm, except for the APInt
unit tests which should still test the deprecated methods.
Differential Revision: https://reviews.llvm.org/D110807
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index daecd70..a21a7a8 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -166,7 +166,7 @@ static bool getShuffleDemandedElts(const ShuffleVectorInst *Shuf, cast<FixedVectorType>(Shuf->getOperand(0)->getType())->getNumElements(); int NumMaskElts = cast<FixedVectorType>(Shuf->getType())->getNumElements(); DemandedLHS = DemandedRHS = APInt::getZero(NumElts); - if (DemandedElts.isNullValue()) + if (DemandedElts.isZero()) return true; // Simple case of a shuffle with zeroinitializer. if (all_of(Shuf->getShuffleMask(), [](int Elt) { return Elt == 0; })) { @@ -1378,7 +1378,7 @@ static void computeKnownBitsFromOperator(const Operator *I, Known = KnownBits::computeForAddSub( /*Add=*/true, /*NSW=*/false, Known, IndexBits); } - if (!Known.isUnknown() && !AccConstIndices.isNullValue()) { + if (!Known.isUnknown() && !AccConstIndices.isZero()) { KnownBits Index = KnownBits::makeConstant(AccConstIndices); Known = KnownBits::computeForAddSub( /*Add=*/true, /*NSW=*/false, Known, Index); @@ -2270,7 +2270,7 @@ static bool isNonZeroRecurrence(const PHINode *PN) { Value *Start = nullptr, *Step = nullptr; const APInt *StartC, *StepC; if (!matchSimpleRecurrence(PN, BO, Start, Step) || - !match(Start, m_APInt(StartC)) || StartC->isNullValue()) + !match(Start, m_APInt(StartC)) || StartC->isZero()) return false; switch (BO->getOpcode()) { @@ -2282,7 +2282,7 @@ static bool isNonZeroRecurrence(const PHINode *PN) { StartC->isNegative() == StepC->isNegative()); case Instruction::Mul: return (BO->hasNoUnsignedWrap() || BO->hasNoSignedWrap()) && - match(Step, m_APInt(StepC)) && !StepC->isNullValue(); + match(Step, m_APInt(StepC)) && !StepC->isZero(); case Instruction::Shl: return BO->hasNoUnsignedWrap() || BO->hasNoSignedWrap(); case Instruction::AShr: @@ -2716,8 +2716,7 @@ static bool isNonEqualMul(const Value *V1, const Value *V2, unsigned Depth, const APInt *C; return match(OBO, m_Mul(m_Specific(V1), m_APInt(C))) && (OBO->hasNoUnsignedWrap() || OBO->hasNoSignedWrap()) && - !C->isNullValue() && !C->isOneValue() && - isKnownNonZero(V1, Depth + 1, Q); + !C->isZero() && !C->isOne() && isKnownNonZero(V1, Depth + 1, Q); } return false; } @@ -2730,7 +2729,7 @@ static bool isNonEqualShl(const Value *V1, const Value *V2, unsigned Depth, const APInt *C; return match(OBO, m_Shl(m_Specific(V1), m_APInt(C))) && (OBO->hasNoUnsignedWrap() || OBO->hasNoSignedWrap()) && - !C->isNullValue() && isKnownNonZero(V1, Depth + 1, Q); + !C->isZero() && isKnownNonZero(V1, Depth + 1, Q); } return false; } @@ -3073,7 +3072,7 @@ static unsigned ComputeNumSignBitsImpl(const Value *V, // 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 TyBits; // If we are subtracting one from a positive number, there is no carry @@ -3097,7 +3096,7 @@ static unsigned ComputeNumSignBitsImpl(const Value *V, computeKnownBits(U->getOperand(1), Known, Depth + 1, Q); // 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 TyBits; // If the input is known to be positive (the sign bit is known clear), @@ -4642,7 +4641,7 @@ bool llvm::isSafeToSpeculativelyExecute(const Value *V, if (*Denominator == 0) return false; // It's safe to hoist if the denominator is not 0 or -1. - if (!Denominator->isAllOnesValue()) + if (!Denominator->isAllOnes()) return true; // At this point we know that the denominator is -1. It is safe to hoist as // long we know that the numerator is not INT_MIN. @@ -5863,15 +5862,13 @@ static SelectPatternResult matchMinMax(CmpInst::Predicate Pred, // Is the sign bit set? // (X <s 0) ? X : MAXVAL ==> (X >u MAXVAL) ? X : MAXVAL ==> UMAX // (X <s 0) ? MAXVAL : X ==> (X >u MAXVAL) ? MAXVAL : X ==> UMIN - if (Pred == CmpInst::ICMP_SLT && C1->isNullValue() && - C2->isMaxSignedValue()) + if (Pred == CmpInst::ICMP_SLT && C1->isZero() && C2->isMaxSignedValue()) return {CmpLHS == TrueVal ? SPF_UMAX : SPF_UMIN, SPNB_NA, false}; // Is the sign bit clear? // (X >s -1) ? MINVAL : X ==> (X <u MINVAL) ? MINVAL : X ==> UMAX // (X >s -1) ? X : MINVAL ==> (X <u MINVAL) ? X : MINVAL ==> UMIN - if (Pred == CmpInst::ICMP_SGT && C1->isAllOnesValue() && - C2->isMinSignedValue()) + if (Pred == CmpInst::ICMP_SGT && C1->isAllOnes() && C2->isMinSignedValue()) return {CmpLHS == FalseVal ? SPF_UMAX : SPF_UMIN, SPNB_NA, false}; } @@ -6719,7 +6716,7 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower, const APInt *C; switch (BO.getOpcode()) { case Instruction::Add: - if (match(BO.getOperand(1), m_APInt(C)) && !C->isNullValue()) { + if (match(BO.getOperand(1), m_APInt(C)) && !C->isZero()) { // FIXME: If we have both nuw and nsw, we should reduce the range further. if (IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(&BO))) { // 'add nuw x, C' produces [C, UINT_MAX]. @@ -6757,7 +6754,7 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower, Upper = APInt::getSignedMaxValue(Width).ashr(*C) + 1; } else if (match(BO.getOperand(0), m_APInt(C))) { unsigned ShiftAmount = Width - 1; - if (!C->isNullValue() && IIQ.isExact(&BO)) + if (!C->isZero() && IIQ.isExact(&BO)) ShiftAmount = C->countTrailingZeros(); if (C->isNegative()) { // 'ashr C, x' produces [C, C >> (Width-1)] @@ -6778,7 +6775,7 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower, } else if (match(BO.getOperand(0), m_APInt(C))) { // 'lshr C, x' produces [C >> (Width-1), C]. unsigned ShiftAmount = Width - 1; - if (!C->isNullValue() && IIQ.isExact(&BO)) + if (!C->isZero() && IIQ.isExact(&BO)) ShiftAmount = C->countTrailingZeros(); Lower = C->lshr(ShiftAmount); Upper = *C + 1; @@ -6811,7 +6808,7 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower, if (match(BO.getOperand(1), m_APInt(C))) { APInt IntMin = APInt::getSignedMinValue(Width); APInt IntMax = APInt::getSignedMaxValue(Width); - if (C->isAllOnesValue()) { + if (C->isAllOnes()) { // 'sdiv x, -1' produces [INT_MIN + 1, INT_MAX] // where C != -1 and C != 0 and C != 1 Lower = IntMin + 1; @@ -6840,7 +6837,7 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower, break; case Instruction::UDiv: - if (match(BO.getOperand(1), m_APInt(C)) && !C->isNullValue()) { + if (match(BO.getOperand(1), m_APInt(C)) && !C->isZero()) { // 'udiv x, C' produces [0, UINT_MAX / C]. Upper = APInt::getMaxValue(Width).udiv(*C) + 1; } else if (match(BO.getOperand(0), m_APInt(C))) { |