fix(ssa_gen): Generate code for index before the collection#9332
Merged
fix(ssa_gen): Generate code for index before the collection#9332
Conversation
Contributor
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.
| Benchmark suite | Current: 5a69cbf | Previous: 2282832 | Ratio |
|---|---|---|---|
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_private-kernel-lib |
2 s |
1 s |
2 |
test_report_zkpassport_noir-ecdsa_ |
3 s |
1 s |
3 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
6735d82 to
5cfb736
Compare
Contributor
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.
| Benchmark suite | Current: 41067ab | Previous: 9b1b10f | Ratio |
|---|---|---|---|
sha512-100-bytes |
0.134 s |
0.104 s |
1.29 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
github-merge-queue bot
pushed a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Aug 11, 2025
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE chore: Release Noir(1.0.0-beta.10) (noir-lang/noir#9311) feat(ssa_fuzzer): arrays support (noir-lang/noir#9427) chore: add link to issue on TODOs (noir-lang/noir#8307) fix(ownership): Increment reference count for nested array get in LHS assignment (noir-lang/noir#9347) chore: add some mem2reg unit tests (noir-lang/noir#9405) chore(as_slice_length): Various unit tests (noir-lang/noir#9419) chore(simplify_cfg): Additional unit tests (noir-lang/noir#9426) chore: create directory when writing witness artefact (noir-lang/noir#9383) fix: throw error if foreign call returns the wrong number of fields (noir-lang/noir#9286) chore: update ex in docs (noir-lang/noir#9385) chore: add some `assert_constant` tests (noir-lang/noir#9413) chore: error on non constant inputs for Pedersen generators (noir-lang/noir#9389) chore(inlining): Unit tests for global values and conditional inlining (noir-lang/noir#9411) chore(ssa_fuzzer): refactor fuzzing modes + add fuzzing mode without DIE pass (noir-lang/noir#9401) chore(inlining): Various unit tests (noir-lang/noir#9388) feat(ssa_fuzzer): pushing generated program and witness to redis queue (noir-lang/noir#9375) fix(ssa_gen): Generate code for index before the collection (noir-lang/noir#9332) chore: Regression test for calling a mutable closure inside a mutable closure (noir-lang/noir#9384) fix: some nargo expand fixes (noir-lang/noir#9324) fix: disable comptime printing when requesting json output (noir-lang/noir#9381) chore: address TODO comments (noir-lang/noir#9379) feat: type alias for numeric generics (noir-lang/noir#7583) chore: bump external pinned commits (noir-lang/noir#9291) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
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 #9329
Summary*
Swaps the order in
codegen_indexto generate theindexfirst and then thecollection, so that if the collection is mutable and the index modifies it, the loading of the reference happens after the index is calculated.Additional Context
This is what the initial SSA looked like originally:
Notice how we allocate a reference
v2to store the input arrayv0, which is immediately loaded intov3. Then we go into the loop where we loadv2, modify it asv14and store the new value. However in the final blockb3, we get the return valuev7from the arrayv3which we loaded inb0.The reason it worked in Brillig was that Brillig modified the array in place, so even though we used
v3, it reflected the effects ofarray_set v13. In ACIR we modified a copy instead, and then never loaded it again from the reference.After the change in the PR, the new SSA moves the
loadintob3:Documentation*
Check one:
PR Checklist*
cargo fmton default settings.