[llvm] 2d7f34f - [ValueTracking] Don't special case depth for phi of select (#114996)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 01:14:32 PST 2024
Author: Nikita Popov
Date: 2024-11-07T10:14:28+01:00
New Revision: 2d7f34f2a5df9396a33a0ea044cfe3ddf33e1f5c
URL: https://github.com/llvm/llvm-project/commit/2d7f34f2a5df9396a33a0ea044cfe3ddf33e1f5c
DIFF: https://github.com/llvm/llvm-project/commit/2d7f34f2a5df9396a33a0ea044cfe3ddf33e1f5c.diff
LOG: [ValueTracking] Don't special case depth for phi of select (#114996)
As discussed on
https://github.com/llvm/llvm-project/pull/114689#pullrequestreview-2411822612
and following, there is no principled reason why the phi of select case
should have a different recursion limit than the general case. There may
still be fan-out, and there may still be indirect recursion. Revert that
part of #113707.
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 37cd4caaca71df..ed3fa35c5b8610 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1565,20 +1565,12 @@ static void computeKnownBitsFromOperator(const Operator *I,
// Skip direct self references.
if (IncValue == P) continue;
- // Recurse, but cap the recursion to one level, because we don't
- // want to waste time spinning around in loops.
- // TODO: See if we can base recursion limiter on number of incoming phi
- // edges so we don't overly clamp analysis.
- unsigned IncDepth = MaxAnalysisRecursionDepth - 1;
-
// If the Use is a select of this phi, use the knownbit of the other
// operand to break the recursion.
if (auto *SI = dyn_cast<SelectInst>(IncValue)) {
- if (SI->getTrueValue() == P || SI->getFalseValue() == P) {
+ if (SI->getTrueValue() == P || SI->getFalseValue() == P)
IncValue = SI->getTrueValue() == P ? SI->getFalseValue()
: SI->getTrueValue();
- IncDepth = Depth + 1;
- }
}
// Change the context instruction to the "edge" that flows into the
@@ -1589,7 +1581,13 @@ static void computeKnownBitsFromOperator(const Operator *I,
RecQ.CxtI = P->getIncomingBlock(u)->getTerminator();
Known2 = KnownBits(BitWidth);
- computeKnownBits(IncValue, DemandedElts, Known2, IncDepth, RecQ);
+
+ // Recurse, but cap the recursion to one level, because we don't
+ // want to waste time spinning around in loops.
+ // TODO: See if we can base recursion limiter on number of incoming phi
+ // edges so we don't overly clamp analysis.
+ computeKnownBits(IncValue, DemandedElts, Known2,
+ MaxAnalysisRecursionDepth - 1, RecQ);
// See if we can further use a conditional branch into the phi
// to help us determine the range of the value.
More information about the llvm-commits
mailing list