diff options
author | Nikita Popov <npopov@redhat.com> | 2024-11-07 10:14:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-07 10:14:28 +0100 |
commit | 2d7f34f2a5df9396a33a0ea044cfe3ddf33e1f5c (patch) | |
tree | 0561b05bf9ccc79128e93d18a2eaf0a5469c49c2 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | d2aff182d379c9b84cebe0fdf58907f4de768f1e (diff) | |
download | llvm-2d7f34f2a5df9396a33a0ea044cfe3ddf33e1f5c.zip llvm-2d7f34f2a5df9396a33a0ea044cfe3ddf33e1f5c.tar.gz llvm-2d7f34f2a5df9396a33a0ea044cfe3ddf33e1f5c.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 37cd4ca..ed3fa35 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. |