Skip to content

Commit 96f345d

Browse files
committed
[ValueTracking] Don't special case depth for phi of select
As discussed on llvm#114689 (review) 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 llvm#113707.
1 parent a256e89 commit 96f345d

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,20 +1566,12 @@ static void computeKnownBitsFromOperator(const Operator *I,
15661566
// Skip direct self references.
15671567
if (IncValue == P) continue;
15681568

1569-
// Recurse, but cap the recursion to one level, because we don't
1570-
// want to waste time spinning around in loops.
1571-
// TODO: See if we can base recursion limiter on number of incoming phi
1572-
// edges so we don't overly clamp analysis.
1573-
unsigned IncDepth = MaxAnalysisRecursionDepth - 1;
1574-
15751569
// If the Use is a select of this phi, use the knownbit of the other
15761570
// operand to break the recursion.
15771571
if (auto *SI = dyn_cast<SelectInst>(IncValue)) {
1578-
if (SI->getTrueValue() == P || SI->getFalseValue() == P) {
1572+
if (SI->getTrueValue() == P || SI->getFalseValue() == P)
15791573
IncValue = SI->getTrueValue() == P ? SI->getFalseValue()
15801574
: SI->getTrueValue();
1581-
IncDepth = Depth + 1;
1582-
}
15831575
}
15841576

15851577
// Change the context instruction to the "edge" that flows into the
@@ -1590,7 +1582,13 @@ static void computeKnownBitsFromOperator(const Operator *I,
15901582
RecQ.CxtI = P->getIncomingBlock(u)->getTerminator();
15911583

15921584
Known2 = KnownBits(BitWidth);
1593-
computeKnownBits(IncValue, DemandedElts, Known2, IncDepth, RecQ);
1585+
1586+
// Recurse, but cap the recursion to one level, because we don't
1587+
// want to waste time spinning around in loops.
1588+
// TODO: See if we can base recursion limiter on number of incoming phi
1589+
// edges so we don't overly clamp analysis.
1590+
computeKnownBits(IncValue, DemandedElts, Known2,
1591+
MaxAnalysisRecursionDepth - 1, RecQ);
15941592

15951593
// See if we can further use a conditional branch into the phi
15961594
// to help us determine the range of the value.

0 commit comments

Comments
 (0)