-
Notifications
You must be signed in to change notification settings - Fork 199
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
chore: Add Instruction::MakeArray
to SSA
#6071
base: master
Are you sure you want to change the base?
Conversation
Seems like |
Disabling the normalization of valueids shows that we're deleting instructions in the DIE pass which shouldn't be removed. For example the load instruction when returning This is happening because somehow the return value of this function (the loaded value) becomes a |
I've merged in master so that this branch is up to date so will be handing this PR back now. |
Changes to Brillig bytecode sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
Changes to circuit sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
This is passing all tests now and showing a surprisingly large improvement in the hashmap test but also large regressions in brillig bytecode sizes. |
This is likely due to the fact that constant arrays are no long considered as "constants" by |
@TomAFrench hmm I tried updating |
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.
LGTM
Going to hold off on merging this for a bit due to the brillig size regressions |
Yeah would be good to avoid this regression. |
yes, I think that's the issue. For example, in
Previously, these immediate slices would have been picked up by constant_allocation and hoisted to just 1 single initialization. Now, since array constant initialization has been promoted to a instruction, we actually need to do at the ssa level what constant allocation was doing outside SSA. So in order to avoid any regression we need to identify payloads to make_array that are equal to each other and hoist the make_array to the common dominator of all the arrays that are equal. Also, if all the values are immediates constant_allocation was hoisting them out of loops to avoid extra runtime cost. But that won't affect bytecode size |
3f2e4ef
to
9ca0810
Compare
Changes to number of Brillig opcodes executed
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
How about this for brillig improvements 😅 |
Unfortunately the actual brillig bytecode size is still a bit bigger and most brillig programs still execute more opcodes 🤔 Edit: some of them, like brillig_slices may be because of the lack of the array hoisting optimization. The array deduplication check in constant folding doesn't simplify these since they're all in else branches so there's no single case of these that is in a black which dominates all the others. Fixing this seems somewhat difficult since it'd require checking every element of the array, checking which blocks they were defined in, and trying to hoist to the earliest one. Although doing so could potentially lead to more work if those else blocks were never executed and we hoist out of the if. |
Maybe we could hoist out of loops? that one should always lead to better perf I think |
Description
Problem*
Resolves #1733
Summary*
Adds a
MakeArray
instruction to explicitly create a new array. Now no other ValueIds can contain other ValueIds which simplifies a couple passes.Additional Context
Still working on getting this working in brillig.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.