compiler: Restore lifting cache in SROA perform_lifting!#61020
Open
compiler: Restore lifting cache in SROA perform_lifting!#61020
perform_lifting!#61020Conversation
When multiple `getfield` calls access the same field of the same phi node, the SROA pass creates duplicate lifted phi nodes. A lifting cache was originally intended to prevent this (#43927), but had been broken and later removed in PR #51014. This restores a working lifting cache. The cache key includes both the field index and `stmt_val` (the original `getfield` argument) to distinguish liftings through the same phi node with different type constraints (e.g. direct access vs access through a PiNode that narrows the type). Without `stmt_val` in the key, a narrower type-constrained lifting could be incorrectly reused for a wider constraint, producing phi nodes with missing edges. Separate caches are used for `getfield` and `isdefined` liftings since they produce phi nodes with different value types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
Does this have any performance improvements? |
Member
Author
|
Since the number of generated |
Member
|
Would be nice to see some benchmarks to ensure this is positive/neutral. |
Member
Author
|
@nanosoldier |
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.
When multiple
getfieldcalls access the same field of the same phi node, the SROA pass creates duplicate lifted phi nodes. A lifting cache was originally intended to prevent this (#43927), but had been broken and later removed in PR #51014.This restores a working lifting cache. The cache key includes both the field index and
stmt_val(the originalgetfieldargument) to distinguish liftings through the same phi node with different type constraints (e.g. direct access vs access through a PiNode that narrows the type). Withoutstmt_valin the key, a narrower type-constrained lifting could be incorrectly reused for a wider constraint, producing phi nodes with missing edges. Separate caches are used forgetfieldandisdefinedliftings since they produce phi nodes with different value types.