Skip to content

chore: don't optimize ArrayGet from previous ArraySet#11586

Merged
asterite merged 29 commits intomasterfrom
ab/array_get_optimization
Feb 20, 2026
Merged

chore: don't optimize ArrayGet from previous ArraySet#11586
asterite merged 29 commits intomasterfrom
ab/array_get_optimization

Conversation

@asterite
Copy link
Copy Markdown
Collaborator

@asterite asterite commented Feb 13, 2026

Description

Problem

Fixes a potential issue in the way we are currently simplifying array_get by looking at previous instructions.

See #11529 (comment)

Summary

Before this PR, an array_get with a constant index was simplified to the value set at the same index of a previous array_set. However, this is only okay to do if the array_set is under the same side effects var as the array_get.

This PR then does several things:

  1. the basic array_get simplification doesn't do the above anymore. However, it will still look through array_set with a constant index that's different than the index of the array_get, which could eventually lead to a make_array or param, to perform a simplification
  2. there's a new SSA optimization pass that keeps tracks of side effects vars associated to array_set, in order to do the original optimization. It usually runs after mem2reg.
  3. in the RemoveIfElse optimization, where we use a ValueMerger, we now keep track of side effects vars associated to each array_set. In that way when arrays are merged we can be sure we are doing this optimization correctly. This is essentially running the optimization in point 2 while merging arrays in RemoveIfElse

Additional Context

User Documentation

Check one:

  • No user documentation needed.
  • Changes in docs/ included in this PR.
  • [For Experimental Features] Changes in docs/ to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'ACVM Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 0acc2d1 Previous: efc4e62 Ratio
perfectly_parallel_batch_inversion_opcodes 2724388 ns/iter (± 1394) 2203755 ns/iter (± 8009) 1.24

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Compilation Memory'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 9810fea Previous: bd5f9f0 Ratio
semaphore_depth_10 188.85 MB 98.09 MB 1.93

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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: 6028306 Previous: 32d579f Ratio
rollup-checkpoint-root 12.6 s 10.3 s 1.22

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Compilation Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 0acc2d1 Previous: efc4e62 Ratio
rollup-tx-base-public 98.28 s 80.14 s 1.23

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Opcode count'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 9810fea Previous: bd5f9f0 Ratio
semaphore-depth-10 8045 opcodes 5699 opcodes 1.41

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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: 26d937e Previous: 460c017 Ratio
test_report_zkpassport_noir_rsa_ 2 s 1 s 2

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Brillig Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 9a5dd41 Previous: 32d579f Ratio
rollup-tx-merge 0.002 s 0.001 s 2

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

@TomAFrench
Copy link
Copy Markdown
Member

Ah interesting. I was hoping that we didn't rely on this as much. Of we can't solve this with an ssa pass then we can gove the simplification logic knowledge about whether the cfg is flattened.

@asterite asterite marked this pull request as ready for review February 14, 2026 02:36
@asterite
Copy link
Copy Markdown
Collaborator Author

I got it working! That said, I'd like to comment the code or refactor it because there are some duplications... well, not exactly duplications but codes that are similar.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Elaboration Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 1391771 Previous: cca6747 Ratio
rollup-root 1.676 s 1.352 s 1.24

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

@asterite asterite requested a review from a team February 18, 2026 16:20
Copy link
Copy Markdown
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just some nits 👏

@asterite asterite enabled auto-merge February 20, 2026 19:19
Copy link
Copy Markdown
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@asterite asterite added this pull request to the merge queue Feb 20, 2026
Merged via the queue into master with commit 7ce98ab Feb 20, 2026
137 checks passed
@asterite asterite deleted the ab/array_get_optimization branch February 20, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants