Skip to content

[mono-vm][specializer] Move a fusing operation from lowering to destacking phase#19431

Merged
vineethk merged 2 commits intomainfrom
vk/move-fuse-to-destack
Apr 22, 2026
Merged

[mono-vm][specializer] Move a fusing operation from lowering to destacking phase#19431
vineethk merged 2 commits intomainfrom
vk/move-fuse-to-destack

Conversation

@vineethk
Copy link
Copy Markdown
Contributor

@vineethk vineethk commented Apr 13, 2026

Description

There was a mismatch where cmp+branch fusion was performed, because those micro-ops came later.

In this PR, we move this fusion from lowering to the destacking phase.

It results in fewer stackless exec IR instructions in some cases, and fewer slots (e.g., on the fibonacci example).

How Has This Been Tested?

Existing tests have been upgraded.

Type of Change

  • Refactoring

Note

Medium Risk
Touches control-flow semantics across IR fusion, lowering, and runtime execution/verification; errors here could miscompile branches or change loop termination behavior despite test updates.

Overview
Moves compare+branch fusion out of lowering and into the destacking/SSA fusion pipeline by introducing CmpOp, representing comparisons as BinaryOp::Cmp(_), and fusing BinaryOp{Cmp} + BrTrue/BrFalse into new IR terminators BrCmp / BrCmpImm.

Updates lowering to consume BrCmp* directly (and to lower standalone BrFalse), adding new micro-ops JumpGreaterU64Imm and JumpLessEqualU64Imm plus corresponding interpreter, verifier, CFG/gas, and display support. Golden tests are refreshed to reflect fewer temporary slots and newly-lowered control-flow cases that were previously skipped.

Reviewed by Cursor Bugbot for commit 2f56ed6. Bugbot is set up for automated code reviews on this repo. Configure here.

@vineethk vineethk changed the title Move a fusing operation from lowering to destacking, where it belongs. [mono-vm][specializer] Move a fusing operation from lowering to destacking phase Apr 13, 2026
@vineethk vineethk marked this pull request as ready for review April 13, 2026 21:03
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2712de9. Configure here.

Comment thread third_party/move/mono-move/specializer/src/lower/translate.rs
@vineethk vineethk force-pushed the vk/basic-block-refactor branch from 03dc67c to f4f8ba7 Compare April 13, 2026 22:21
@vineethk vineethk force-pushed the vk/move-fuse-to-destack branch from 2712de9 to 26e7830 Compare April 13, 2026 22:21
Comment thread third_party/move/mono-move/specializer/src/lower/translate.rs Outdated
Comment thread third_party/move/mono-move/specializer/src/lower/translate.rs Outdated
@vineethk vineethk changed the base branch from vk/basic-block-refactor to graphite-base/19431 April 14, 2026 20:11
@vineethk vineethk force-pushed the graphite-base/19431 branch from f4f8ba7 to 50efd4c Compare April 14, 2026 21:10
@vineethk vineethk force-pushed the vk/move-fuse-to-destack branch from 26e7830 to eca58bf Compare April 14, 2026 21:10
@vineethk vineethk changed the base branch from graphite-base/19431 to main April 14, 2026 21:10
@zeropath-aptos

This comment was marked as resolved.

@vineethk vineethk enabled auto-merge (squash) April 22, 2026 15:49
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

✅ Forge suite compat success on ca049383dd80675149ef2d0042668964f9f9107a ==> 2f56ed63d42c7cbc8cb6f5db12c1a5a9d6713749

Compatibility test results for ca049383dd80675149ef2d0042668964f9f9107a ==> 2f56ed63d42c7cbc8cb6f5db12c1a5a9d6713749 (PR)
1. Check liveness of validators at old version: ca049383dd80675149ef2d0042668964f9f9107a
compatibility::simple-validator-upgrade::liveness-check : committed: 14316.68 txn/s, latency: 2406.55 ms, (p50: 2400 ms, p70: 2700, p90: 3100 ms, p99: 3700 ms), latency samples: 470880
2. Upgrading first Validator to new version: 2f56ed63d42c7cbc8cb6f5db12c1a5a9d6713749
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6276.21 txn/s, latency: 5384.34 ms, (p50: 5900 ms, p70: 6000, p90: 6100 ms, p99: 6200 ms), latency samples: 217100
3. Upgrading rest of first batch to new version: 2f56ed63d42c7cbc8cb6f5db12c1a5a9d6713749
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 6408.09 txn/s, latency: 5299.79 ms, (p50: 5800 ms, p70: 5900, p90: 6000 ms, p99: 6200 ms), latency samples: 220500
4. upgrading second batch to new version: 2f56ed63d42c7cbc8cb6f5db12c1a5a9d6713749
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 10940.31 txn/s, latency: 2960.77 ms, (p50: 3100 ms, p70: 3300, p90: 3500 ms, p99: 3700 ms), latency samples: 359120
5. check swarm health
Compatibility test for ca049383dd80675149ef2d0042668964f9f9107a ==> 2f56ed63d42c7cbc8cb6f5db12c1a5a9d6713749 passed
Test Ok

@github-actions
Copy link
Copy Markdown
Contributor

✅ Forge suite realistic_env_max_load success on 2f56ed63d42c7cbc8cb6f5db12c1a5a9d6713749

two traffics test: inner traffic : committed: 15712.80 txn/s, latency: 1089.75 ms, (p50: 1000 ms, p70: 1100, p90: 1200 ms, p99: 1500 ms), latency samples: 5869280
two traffics test : committed: 100.01 txn/s, latency: 822.89 ms, (p50: 800 ms, p70: 900, p90: 1000 ms, p99: 1200 ms), latency samples: 1760
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 0.292, avg: 0.248", "ConsensusProposalToOrdered: max: 0.114, avg: 0.111", "ConsensusOrderedToCommit: max: 0.194, avg: 0.175", "ConsensusProposalToCommit: max: 0.306, avg: 0.286"]
Max non-epoch-change gap was: 2 rounds at version 48782 (avg 0.00) [limit 4], 2.15s no progress at version 48782 (avg 0.06s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.21s no progress at version 2731760 (avg 0.21s) [limit 16].
Test Ok

@vineethk vineethk merged commit 62412e7 into main Apr 22, 2026
118 of 120 checks passed
@vineethk vineethk deleted the vk/move-fuse-to-destack branch April 22, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants