[llvm] [ValueTracking] Compute known bits from recursive select/phi (PR #113707)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 3 07:10:27 PST 2024
================
@@ -1566,6 +1566,22 @@ 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) {
+ IncValue = SI->getTrueValue() == P ? SI->getFalseValue()
+ : SI->getTrueValue();
+ IncDepth = Depth + 1;
----------------
goldsteinn wrote:
Answered in https://github.com/llvm/llvm-project/pull/114689#issuecomment-2453461016, lets keep the conversion in one place.
https://github.com/llvm/llvm-project/pull/113707
More information about the llvm-commits
mailing list