Skip to content

feat: Replace converging jmpif with empty block destinations with a single jmp#8613

Merged
vezenovm merged 10 commits intomasterfrom
mv/simplify-converging-jmpif
May 28, 2025
Merged

feat: Replace converging jmpif with empty block destinations with a single jmp#8613
vezenovm merged 10 commits intomasterfrom
mv/simplify-converging-jmpif

Conversation

@vezenovm
Copy link
Copy Markdown
Contributor

@vezenovm vezenovm commented May 21, 2025

Description

Problem*

No issue but something I noticed originally when making the pruning dead parameters PR and was surprised to not see certain jumps simplified.

Summary*

Attempt to simplify a jmpif terminator if both branches converge.

We define convergence as when two branches of a jmpif ultimately lead to the same
destination block, after following chains of empty blocks. If they do, the conditional
jump is unnecessary and can be replaced with a simple jmp.

There is room for follow-up PRs that do not restrict jump chains to empty blocks. For example, if we had entirely pure instructions in a block it would also be safe to follow the jump chain as we do in this PR. For now, we restrict a jump chain to only be empty blocks with no parameters.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation 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.

@vezenovm vezenovm requested a review from a team May 21, 2025 21:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 21, 2025

Changes to Brillig bytecode sizes

Generated at commit: 1590ada225d3c5195fd73e8e71e5b9251f0336d5, compared to commit: 9b7320908e74377bfd55a8760f16974ef1d07c05

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
to_le_bytes_inliner_max -2 ✅ -1.72%
to_le_bytes_inliner_zero -2 ✅ -1.72%

Full diff report 👇
Program Brillig opcodes (+/-) %
slices_inliner_min 2,163 (-3) -0.14%
slices_inliner_max 1,693 (-3) -0.18%
slices_inliner_zero 1,625 (-3) -0.18%
to_le_bytes_inliner_min 123 (-2) -1.60%
to_le_bytes_inliner_max 114 (-2) -1.72%
to_le_bytes_inliner_zero 114 (-2) -1.72%

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 21, 2025

Changes to number of Brillig opcodes executed

Generated at commit: 1590ada225d3c5195fd73e8e71e5b9251f0336d5, compared to commit: 9b7320908e74377bfd55a8760f16974ef1d07c05

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
slices_inliner_zero -3 ✅ -0.11%
slices_inliner_max -3 ✅ -0.12%

Full diff report 👇
Program Brillig opcodes (+/-) %
slices_inliner_min 3,802 (-3) -0.08%
to_le_bytes_inliner_min 1,016 (-1) -0.10%
to_le_bytes_inliner_max 1,003 (-1) -0.10%
to_le_bytes_inliner_zero 1,003 (-1) -0.10%
slices_inliner_zero 2,736 (-3) -0.11%
slices_inliner_max 2,493 (-3) -0.12%

@TomAFrench
Copy link
Copy Markdown
Member

Be aware that this can break flattening (I think).

@TomAFrench
Copy link
Copy Markdown
Member

TomAFrench commented May 21, 2025

Ah, I misunderstood what you meant by converging nvm, misread as I was on mobile. This is the case that can break things.

@TomAFrench TomAFrench changed the title feat(simplify_cfg): Replace converging jmpif with empty block destinations with a single jmp feat: Replace converging jmpif with empty block destinations with a single jmp May 22, 2025
Copy link
Copy Markdown
Contributor

@michaeljklein michaeljklein left a comment

Choose a reason for hiding this comment

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

Small doc change but LGTM

Co-authored-by: Michael J Klein <michaeljklein@users.noreply.github.com>
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: ff10b51 Previous: 9b73209 Ratio
semaphore-depth-10 0.024 s 0.019 s 1.26

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

CC: @TomAFrench

@vezenovm vezenovm enabled auto-merge May 28, 2025 22:10
@vezenovm vezenovm added this pull request to the merge queue May 28, 2025
github-merge-queue bot pushed a commit that referenced this pull request May 28, 2025
…ingle jmp (#8613)

Co-authored-by: Michael J Klein <michaeljklein@users.noreply.github.com>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2025
@vezenovm vezenovm added this pull request to the merge queue May 28, 2025
Merged via the queue into master with commit 00d636c May 28, 2025
118 checks passed
@vezenovm vezenovm deleted the mv/simplify-converging-jmpif branch May 28, 2025 23:26
defkit pushed a commit that referenced this pull request May 29, 2025
…ingle jmp (#8613)

Co-authored-by: Michael J Klein <michaeljklein@users.noreply.github.com>
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jun 1, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix(fmt): correctly format mixed secondary attributes and doc comments
(noir-lang/noir#8735)
fix!: require types for trait impl associated constants
(noir-lang/noir#8734)
fix!: Prevent returning references from if expressions
(noir-lang/noir#8731)
fix: cast signed to u1 follow-up
(noir-lang/noir#8730)
fix: cast signed to u1 (noir-lang/noir#8720)
fix: do not mutate arrays later copied inside other arrays
(noir-lang/noir#8701)
chore: box `AsTraitPath` and `TypePath` in `ExpressionKind`
(noir-lang/noir#8716)
fix: general solution for accessing associated constants
(noir-lang/noir#8417)
fix(ssa): Validate checked signed add/sub is followed by a truncate
(noir-lang/noir#8706)
chore: add pre- and post-check on `array_set` optimization pass
(noir-lang/noir#8714)
fix: merge expr bindings with instantiations bindings during
monomorphization (noir-lang/noir#8713)
fix: better way to do LSP file overrides
(noir-lang/noir#8702)
fix(fmt): correct indentation when formatting long struct patterns
(noir-lang/noir#8711)
fix(fuzz): Prevent breaking/continuing out from let blocks in the AST
fuzzer (noir-lang/noir#8708)
chore: remove override for zero length inputs
(noir-lang/noir#8709)
feat: Replace converging jmpif with empty block destinations with a
single jmp (noir-lang/noir#8613)
feat(cli): Add `nargo interpret` command
(noir-lang/noir#8700)
chore: more 1-tuple printing fixes
(noir-lang/noir#8699)
chore(fuzz): Fuzz the SSA parser
(noir-lang/noir#8647)
fix: (SSA parser) translate blocks in logical order rather than syntax
order (noir-lang/noir#8668)
fix(SSA): show and parse range_check's assert_message
(noir-lang/noir#8652)
chore: Show the step number in the SSA message
(noir-lang/noir#8698)
chore(docs): Add pointers to tests
(noir-lang/noir#8695)
chore(fuzz): Capture comptime print output
(noir-lang/noir#8635)
fix: nargo expand reexports correctly implemented
(noir-lang/noir#8693)
feat(cli): Show multiple SSA passes
(noir-lang/noir#8692)
chore(test): Add regression test for defunctionalize
(noir-lang/noir#8691)
chore: add an assertion when parsing SSA that all functions are
well-formed (noir-lang/noir#8671)
feat!: prevent compiling blake3 hashes which barretenberg cannot prove
(noir-lang/noir#8690)
fix(ssa): Remove the array cache from the function inserter
(noir-lang/noir#8607)
chore: bump external pinned commits
(noir-lang/noir#8684)
chore: reenable fuzzing tests in CI
(noir-lang/noir#8688)
fix: Handle `&mut function` in defunctionalize
(noir-lang/noir#8665)
fix(defunctionalize): Higher order functions (HOF) dynamic dispatch and
HOFs in arrays (noir-lang/noir#8672)
chore(ci): avoid running fuzzer tests in the merge queue
(noir-lang/noir#8664)
fix: Make casts in `comptime` consistent with runtime casts
(noir-lang/noir#8669)
fix: relax connectedness requirement on purity analysis pass
(noir-lang/noir#8667)
fix: always use `u32` for indexing arrays in SSA
(noir-lang/noir#8633)
chore: explicitly pull from `next` branch in aztec-packages
(noir-lang/noir#8660)
chore(fuzz): Build the dictionary from the SSA
(noir-lang/noir#8591)
chore(docs): Remove old versioned docs
(noir-lang/noir#8061)
chore: bump external pinned commits
(noir-lang/noir#8634)
fix(SSA): don't use string literal if byte is "form feed" ('\f')
(noir-lang/noir#8653)
chore(defunctionalize): Add regression test for missing lambda variants
panic (noir-lang/noir#8642)
chore(ci): Do not run ast_fuzzer orig vs. morph in ci
(noir-lang/noir#8646)
fix: disable underflow fix for fields
(noir-lang/noir#8631)
fix: revert "fix: error on unused generic in trait impl
(noir-lang/noir#8395)"
(noir-lang/noir#8636)
fix(ssa interpreter): Default to zero when we have an overflowing shl
(noir-lang/noir#8638)
fix: ensure that purity analysis pass explores all functions
(noir-lang/noir#8452)
feat: acir_formal_proofs (noir-lang/noir#8140)
fix: error on unused generic in trait impl
(noir-lang/noir#8395)
fix(expand): use re-exports for non-visibile items
(noir-lang/noir#8374)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <tech@aztecprotocol.com>
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Co-authored-by: Ary Borenszweig <asterite@gmail.com>
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