[asm] Memory offset optimization: split oversized constants#967
Open
Hardcode84 wants to merge 2 commits intoiree-org:mainfrom
Open
[asm] Memory offset optimization: split oversized constants#967Hardcode84 wants to merge 2 commits intoiree-org:mainfrom
Hardcode84 wants to merge 2 commits intoiree-org:mainfrom
Conversation
Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
panditsa
approved these changes
Feb 24, 2026
ftynse
reviewed
Feb 25, 2026
Contributor
ftynse
left a comment
There was a problem hiding this comment.
It is much better when the commit message explains why a change is made, we can see what it is from reading the code.
| return std::nullopt; | ||
|
|
||
| // Check shift overflow before creating any new ops | ||
| // Check shift overflow before creating any new ops. |
Contributor
There was a problem hiding this comment.
I usually avoid making irrelevant stylistic changes in a load-bearing commit. These show up in git history with unrelated commit message and you will be the one to blame for this code. Putting them in a separate NFC is a better idea.
Contributor
Author
It does
|
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.
Summary
MemoryOffsetOptimizationpass to handle constants that exceed the hardware offset limit by splitting them into an aligned high part (K_hi) kept in thev_add_u32and a low residual (K_lo) folded into the static offset field.v_add_u32(base, 68608)withoffset:0— full constant in VALU.v_add_u32(base, 65536)withoffset:3072— residual absorbed into hardware.ScopedCSEpass mergesv_add_u32ops that now share the sameK_hiand base, eliminating redundant VALU instructions across nearby loads.