diff options
author | Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com> | 2025-06-03 17:12:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-03 17:12:24 +0100 |
commit | b40e4ceaa61c5f14ca261e2952e7f85a066403e2 (patch) | |
tree | 22a01d10255678e3a57fae6fc962c3325bbebd00 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | cb4a407e5c2a8a5972781d2a3be362f437602fae (diff) | |
download | llvm-b40e4ceaa61c5f14ca261e2952e7f85a066403e2.zip llvm-b40e4ceaa61c5f14ca261e2952e7f85a066403e2.tar.gz llvm-b40e4ceaa61c5f14ca261e2952e7f85a066403e2.tar.bz2 |
[ValueTracking] Make Depth last default arg (NFC) (#142384)
Having a finite Depth (or recursion limit) for computeKnownBits is very
limiting, but is currently a load-bearing necessity, as all KnownBits
are recomputed on each call and there is no caching. As a prerequisite
for an effort to remove the recursion limit altogether, either using a
clever caching technique, or writing a easily-invalidable KnownBits
analysis, make the Depth argument in APIs in ValueTracking uniformly the
last argument with a default value. This would aid in removing the
argument when the time comes, as many callers that currently pass 0
explicitly are now updated to omit the argument altogether.
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 56cdfab..2dfe625 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -6367,7 +6367,7 @@ APInt ScalarEvolution::getConstantMultipleImpl(const SCEV *S) { // ask ValueTracking for known bits const SCEVUnknown *U = cast<SCEVUnknown>(S); unsigned Known = - computeKnownBits(U->getValue(), getDataLayout(), 0, &AC, nullptr, &DT) + computeKnownBits(U->getValue(), getDataLayout(), &AC, nullptr, &DT) .countMinTrailingZeros(); return GetShiftedByZeros(Known); } @@ -6485,8 +6485,8 @@ getRangeForUnknownRecurrence(const SCEVUnknown *U) { if (!TC || TC >= BitWidth) return FullSet; - auto KnownStart = computeKnownBits(Start, DL, 0, &AC, nullptr, &DT); - auto KnownStep = computeKnownBits(Step, DL, 0, &AC, nullptr, &DT); + auto KnownStart = computeKnownBits(Start, DL, &AC, nullptr, &DT); + auto KnownStep = computeKnownBits(Step, DL, &AC, nullptr, &DT); assert(KnownStart.getBitWidth() == BitWidth && KnownStep.getBitWidth() == BitWidth); @@ -6863,13 +6863,13 @@ const ConstantRange &ScalarEvolution::getRangeRef( // See if ValueTracking can give us a useful range. const DataLayout &DL = getDataLayout(); - KnownBits Known = computeKnownBits(V, DL, 0, &AC, nullptr, &DT); + KnownBits Known = computeKnownBits(V, DL, &AC, nullptr, &DT); if (Known.getBitWidth() != BitWidth) Known = Known.zextOrTrunc(BitWidth); // ValueTracking may be able to compute a tighter result for the number of // sign bits than for the value of those sign bits. - unsigned NS = ComputeNumSignBits(V, DL, 0, &AC, nullptr, &DT); + unsigned NS = ComputeNumSignBits(V, DL, &AC, nullptr, &DT); if (U->getType()->isPointerTy()) { // If the pointer size is larger than the index size type, this can cause // NS to be larger than BitWidth. So compensate for this. @@ -7818,8 +7818,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) { unsigned TZ = A.countr_zero(); unsigned BitWidth = A.getBitWidth(); KnownBits Known(BitWidth); - computeKnownBits(BO->LHS, Known, getDataLayout(), - 0, &AC, nullptr, &DT); + computeKnownBits(BO->LHS, Known, getDataLayout(), &AC, nullptr, &DT); APInt EffectiveMask = APInt::getLowBitsSet(BitWidth, BitWidth - LZ - TZ).shl(TZ); @@ -9485,7 +9484,7 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeShiftCompareExitLimit( // {K,ashr,<positive-constant>} stabilizes to signum(K) in at most // bitwidth(K) iterations. Value *FirstValue = PN->getIncomingValueForBlock(Predecessor); - KnownBits Known = computeKnownBits(FirstValue, DL, 0, &AC, + KnownBits Known = computeKnownBits(FirstValue, DL, &AC, Predecessor->getTerminator(), &DT); auto *Ty = cast<IntegerType>(RHS->getType()); if (Known.isNonNegative()) |