diff options
author | Chris Lattner <clattner@nondot.org> | 2021-09-08 22:13:13 -0700 |
---|---|---|
committer | Chris Lattner <clattner@nondot.org> | 2021-09-09 09:50:24 -0700 |
commit | 735f46715d90fd0ff48dd44d1007302640ab4d11 (patch) | |
tree | b6e83d6168f4c6e7b3427791fe17581f210015ec /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 6355234660551e7562e2ace512ccaefacbbb9065 (diff) | |
download | llvm-735f46715d90fd0ff48dd44d1007302640ab4d11.zip llvm-735f46715d90fd0ff48dd44d1007302640ab4d11.tar.gz llvm-735f46715d90fd0ff48dd44d1007302640ab4d11.tar.bz2 |
[APInt] Normalize naming on keep constructors / predicate methods.
This renames the primary methods for creating a zero value to `getZero`
instead of `getNullValue` and renames predicates like `isAllOnesValue`
to simply `isAllOnes`. This achieves two things:
1) This starts standardizing predicates across the LLVM codebase,
following (in this case) ConstantInt. The word "Value" doesn't
convey anything of merit, and is missing in some of the other things.
2) Calling an integer "null" doesn't make any sense. The original sin
here is mine and I've regretted it for years. This moves us to calling
it "zero" instead, which is correct!
APInt is widely used and I don't think anyone is keen to take massive source
breakage on anything so core, at least not all in one go. As such, this
doesn't actually delete any entrypoints, it "soft deprecates" them with a
comment.
Included in this patch are changes to a bunch of the codebase, but there are
more. We should normalize SelectionDAG and other APIs as well, which would
make the API change more mechanical.
Differential Revision: https://reviews.llvm.org/D109483
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 1e63fc0..53d7ddf 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -165,7 +165,7 @@ static bool getShuffleDemandedElts(const ShuffleVectorInst *Shuf, int NumElts = cast<FixedVectorType>(Shuf->getOperand(0)->getType())->getNumElements(); int NumMaskElts = cast<FixedVectorType>(Shuf->getType())->getNumElements(); - DemandedLHS = DemandedRHS = APInt::getNullValue(NumElts); + DemandedLHS = DemandedRHS = APInt::getZero(NumElts); if (DemandedElts.isNullValue()) return true; // Simple case of a shuffle with zeroinitializer. @@ -206,7 +206,7 @@ static void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth, auto *FVTy = dyn_cast<FixedVectorType>(V->getType()); APInt DemandedElts = - FVTy ? APInt::getAllOnesValue(FVTy->getNumElements()) : APInt(1, 1); + FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); computeKnownBits(V, DemandedElts, Known, Depth, Q); } @@ -378,7 +378,7 @@ static unsigned ComputeNumSignBits(const Value *V, unsigned Depth, auto *FVTy = dyn_cast<FixedVectorType>(V->getType()); APInt DemandedElts = - FVTy ? APInt::getAllOnesValue(FVTy->getNumElements()) : APInt(1, 1); + FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); return ComputeNumSignBits(V, DemandedElts, Depth, Q); } @@ -582,7 +582,7 @@ static bool cmpExcludesZero(CmpInst::Predicate Pred, const Value *RHS) { return false; ConstantRange TrueValues = ConstantRange::makeExactICmpRegion(Pred, *C); - return !TrueValues.contains(APInt::getNullValue(C->getBitWidth())); + return !TrueValues.contains(APInt::getZero(C->getBitWidth())); } static bool isKnownNonZeroFromAssume(const Value *V, const Query &Q) { @@ -1210,7 +1210,7 @@ static void computeKnownBitsFromOperator(const Operator *I, // (dependent on endian) to form the full result of known bits. unsigned NumElts = DemandedElts.getBitWidth(); unsigned SubScale = BitWidth / SubBitWidth; - APInt SubDemandedElts = APInt::getNullValue(NumElts * SubScale); + APInt SubDemandedElts = APInt::getZero(NumElts * SubScale); for (unsigned i = 0; i != NumElts; ++i) { if (DemandedElts[i]) SubDemandedElts.setBit(i * SubScale); @@ -1763,7 +1763,7 @@ static void computeKnownBitsFromOperator(const Operator *I, break; } unsigned NumElts = cast<FixedVectorType>(Vec->getType())->getNumElements(); - APInt DemandedVecElts = APInt::getAllOnesValue(NumElts); + APInt DemandedVecElts = APInt::getAllOnes(NumElts); if (CIdx && CIdx->getValue().ult(NumElts)) DemandedVecElts = APInt::getOneBitSet(NumElts, CIdx->getZExtValue()); computeKnownBits(Vec, DemandedVecElts, Known, Depth + 1, Q); @@ -2532,7 +2532,7 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth, auto *CIdx = dyn_cast<ConstantInt>(Idx); if (auto *VecTy = dyn_cast<FixedVectorType>(Vec->getType())) { unsigned NumElts = VecTy->getNumElements(); - APInt DemandedVecElts = APInt::getAllOnesValue(NumElts); + APInt DemandedVecElts = APInt::getAllOnes(NumElts); if (CIdx && CIdx->getValue().ult(NumElts)) DemandedVecElts = APInt::getOneBitSet(NumElts, CIdx->getZExtValue()); return isKnownNonZero(Vec, DemandedVecElts, Depth, Q); @@ -2559,7 +2559,7 @@ bool isKnownNonZero(const Value* V, unsigned Depth, const Query& Q) { auto *FVTy = dyn_cast<FixedVectorType>(V->getType()); APInt DemandedElts = - FVTy ? APInt::getAllOnesValue(FVTy->getNumElements()) : APInt(1, 1); + FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); return isKnownNonZero(V, DemandedElts, Depth, Q); } @@ -6746,7 +6746,7 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower, case Instruction::LShr: if (match(BO.getOperand(1), m_APInt(C)) && C->ult(Width)) { // 'lshr x, C' produces [0, UINT_MAX >> C]. - Upper = APInt::getAllOnesValue(Width).lshr(*C) + 1; + Upper = APInt::getAllOnes(Width).lshr(*C) + 1; } else if (match(BO.getOperand(0), m_APInt(C))) { // 'lshr C, x' produces [C >> (Width-1), C]. unsigned ShiftAmount = Width - 1; @@ -6956,7 +6956,7 @@ static void setLimitsForSelectPattern(const SelectInst &SI, APInt &Lower, // If the negation part of the abs (in RHS) has the NSW flag, // then the result of abs(X) is [0..SIGNED_MAX], // otherwise it is [0..SIGNED_MIN], as -SIGNED_MIN == SIGNED_MIN. - Lower = APInt::getNullValue(BitWidth); + Lower = APInt::getZero(BitWidth); if (match(RHS, m_Neg(m_Specific(LHS))) && IIQ.hasNoSignedWrap(cast<Instruction>(RHS))) Upper = APInt::getSignedMaxValue(BitWidth) + 1; |