[llvm] [ValueTracking] Handle recursive select/PHI in ComputeKnownBits (PR #114689)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 3 08:05:35 PST 2024
nikic wrote:
> > I don't fully understand the recursion limit handling here, both in the old and the new code. Why is it safe to use the full depth for the select case? Can't you have multiple phi incoming values that are all selects and perform a full-depth walk on all of them?
>
> I think that the pathological case is a recursive phi is `Num_Phi_Nodes^(MaxDepth - CurDepth)`, if we know we aren't hitting a case that doesn't scale exponentially with `Depth` its seems reasonable enough. Also it seems highly unlikely even in a PHI with a thousand arms to have ALL of them be select-referential selects.
But doesn't that scale potentially exponentially? Especially if you take into account the fact that the other select operand may in fact also be based on the phi (just take something like `c ? phi + 1 : phi`), so we get the usual recursive fan-out problem, just with a select interleaved in between.
https://github.com/llvm/llvm-project/pull/114689
More information about the llvm-commits
mailing list