Skip to content

Commit 7132847

Browse files
nikicbanach-space
authored andcommitted
[ValueTracking] Don't special case depth for phi of select (llvm#114996)
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 d2aff18 commit 7132847

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
@@ -1565,20 +1565,12 @@ static void computeKnownBitsFromOperator(const Operator *I,
15651565
// Skip direct self references.
15661566
if (IncValue == P) continue;
15671567

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

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

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

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

0 commit comments

Comments
 (0)