[Mem2Reg] Skip load [take] of cast projections. #41751
Merged
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.
Already,
load [take]
s ofstruct_element_addr|tuple_element_addr
projections resulted in Mem2Reg bailing. Expand that to includeload [take]
s involvingunchecked_addr_cast
.To handle
load [take]
s of(struct|tuple)_element_addr
projections, it would be necessary to replace the running value with a value obtained from the original product by recursive destructuring, replacing the value at theload [take]
n address withundef
, and then restructuring.To handle
load [take]
s of cast projections, it would be necessary to useunchecked_value_cast
instead ofunchecked_bitwise_cast
. But we would need to still useunchecked_bitwise_cast
in the case ofload [copy]
because otherwise we would lose the original value--unchecked_value_cast
forwards ownership, and not all casts can be reversed (because they may narrow).For now, just bail out in the face of these complex
load [take]
s.