feat(perf): Remove unused last loads in mem2reg#5905
Closed
vezenovm wants to merge 13 commits intomv/simplify-immediate-storesfrom
Closed
feat(perf): Remove unused last loads in mem2reg#5905vezenovm wants to merge 13 commits intomv/simplify-immediate-storesfrom
vezenovm wants to merge 13 commits intomv/simplify-immediate-storesfrom
Conversation
vezenovm
commented
Sep 3, 2024
| let mut emulated_enum = EnumEmulation { a: Option::some(1), b: Option::none(), c: Option::none() }; | ||
|
|
||
| // Do a copy to optimize out loads in the loop | ||
| let copy_enum = emulated_enum; |
Contributor
Author
There was a problem hiding this comment.
After this PR:
Even after removing this copy optimization we get a Brillig bytecode size improvement from 55 -> 44.
Keeping the copy optimization we get the following final SSA which produces 24 brillig opcodes:
After Array Set Optimizations:
brillig fn main f0 {
b0():
jmp b1(u32 0)
b1(v6: u32):
v27 = eq v6, u32 0
jmpif v27 then: b2, else: b3
b2():
v28 = add v6, u32 1
jmp b1(v28)
b3():
return Field 2
}
Contributor
Author
There was a problem hiding this comment.
Ok this PR now produces the optimal SSA specified above without the copy optimization. Just getting a failure on uhashmap that is the same as #5897.
Contributor
Changes to Brillig bytecode sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
This was referenced Sep 4, 2024
5 tasks
Contributor
Author
|
Closing in favor of #5925 |
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.
Description
Problem*
Resolves
Summary*
Follow-up to #5865
Make the last loads removal smarter by checking whether that last loads is actually used anywhere. If it is not, remove the loads and allow stores to that loads address to be removed as well.
Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmton default settings.