-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(perf): Remove unused last loads in mem2reg #5905
feat(perf): Remove unused last loads in mem2reg #5905
Conversation
@@ -7,10 +7,8 @@ struct EnumEmulation { | |||
unconstrained fn main() -> pub Field { | |||
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Changes to Brillig bytecode sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
Closing in favor of #5925 |
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 fmt
on default settings.