-
Notifications
You must be signed in to change notification settings - Fork 219
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(ssa): Replace values which have previously been constrained with simplified value #2483
Conversation
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.
Since the scope of the constant_folding pass has expanded, can we add to its doc comment the new optimizations it is expected to do?
0f041ba
to
1f12948
Compare
5b50fb1
to
1590a79
Compare
1590a79
to
2813ad6
Compare
This is ready for a re-review now. CI failure is unrelated to this PR. |
Co-authored-by: jfecher <jake@aztecprotocol.com>
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. I'm assuming the test is still failing though.
* master: fix(aztec): fix compilation of `aztec_library.rs` (#2567) feat(ssa): Replace values which have previously been constrained with simplified value (#2483) fix: Black box func slice handling (#2562) chore: Temporarily disable `noir_wasm` test (#2566) fix: Make def collector ordering more deterministic (#2515) chore: refactor `constant_folding` pass (#2533) chore: Cleanup mem2reg pass (#2531) chore: Replace hashers of hashmaps in dfg with fxhashes (#2490) chore: remove duplicate span from FunctionReturnType (#2546)
Description
Problem*
Resolves
Summary*
This PR adds a mapping for
ValueId
s which are constrained to be equal within the current block. When resolving the inputs of instructions, we can then alternate between the standard resolution and checking for an constrained equivalence in this mapping.This optimization is especially useful for situations where we want to perform slice indexing such as in https://github.com/AztecProtocol/aztec-packages/blob/94053e44f4d2a702fe9066bfff3cdd35e6d1b645/yarn-project/noir-libs/noir-aztec/src/messaging/l1_to_l2_message.nr#L47-L65. Rather than checking the slice length on each access, we can assert the length of the slice once and skip all of the other checks.
We must keep a separate cache rather than inserting these equivalences into the
dfg
as otherwise we'll apply these simplifications before (and inside) the constrain statement which enforces it.Documentation
This PR requires documentation updates when merged.
Additional Context
The bytecode for a number of programs has increased due to previous PRs which didn't update the committed bytecode. The changes from this optimzation are in e4c9634
PR Checklist*
cargo fmt
on default settings.