Rangeanalysis: Fix a bad join-order in boundedPhiRankStep.#20579
Merged
MathiasVP merged 1 commit intogithub:mainfrom Oct 13, 2025
Merged
Rangeanalysis: Fix a bad join-order in boundedPhiRankStep.#20579MathiasVP merged 1 commit intogithub:mainfrom
MathiasVP merged 1 commit intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the join order in the boundedPhiRankStep predicate by refactoring how phi input edges are referenced in range analysis. The key change is replacing the conceptual forall quantification over (inp, edge) pairs with direct rank-based indexing to improve query performance.
Key changes:
- Refactored predicate signatures to use rank indices (
rix) instead of(inp, edge)pairs - Moved the translation from
(inp, edge)to rank index earlier in the analysis pipeline - Updated related predicates to work with the new rank-based approach
MathiasVP
approved these changes
Oct 13, 2025
Contributor
There was a problem hiding this comment.
Thanks for providing this alternative fix. I like this one much better (and it shows the same speedup on the affected DCA projects for C/C++) ❤️ LGTM!
The Coding Standards failures are unrelated, and they should be fixed by merging in main. I'll just merge this now 🤠
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The predicate
boundedPhiRankStephas a non-linear recursion with a sub-optimal join. The key thing to notice is that a bunch of predicates use the pairSem::SsaVariable inp, SsaReadPositionPhiInputEdge edgeto reference phi input along an edge, which is eventually conceptually quantified in aforall. However, this conceptualforallis implemented with the usual ranking trick, so we really just need the rank of the edge input. The translation from(inp, edge)to the rank index is the source of the poor join, so we can simply push this in through all the predicates that need to reference the edge input.This is an alternative fix to #20576.