feat(vcr-sel-riscv): RV32 cmp→select fusion peephole, flag-off (#472)#568
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Jul 2, 2026
avrabe
added a commit
that referenced
this pull request
Jul 2, 2026
…ag-off) + gimli 0.34 (#571) Cuts the accumulated increment: the last RV32 lever port (#568), the VCR-RA-001 spill spike with the CI-locked flat_flight Belady target (#569), and the gimli 0.34 bump (#535). VCR-RA-001 stays `implemented` (NOT strengthened to verified — the spike verified its increment, not the full allocator claim) and is re-scoped to v0.23.0. Pin sweep + lock + CHANGELOG. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.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.
Ports the ARM cmp→select lever (VCR-SEL-004) to the RV32 backend for #472: an i32 comparison whose boolean DIRECTLY feeds a
selectfuses into the select's branch — the boolean materialization (slt/sltu/xor+sltiu/xori) is deleted and the branch tests the comparison itself (blt a, binstead ofslt t, a, b; bne t, zero), saving 1–2 instructions per select. RV32's B-type branch comparators (beq/bne/blt/bge/bltu/bgeu) play the role ARM's IT-predicated flags do.Flag-off by default:
SYNTH_RV_CMP_SELECT. With the flag unset,record_pending_cmpis a no-op sopending_cmpis never populated andlower_selectemits the exact baselinebne cond, zero— unchanged by construction.Safety of the fusion
lower_onetake()s the pending record at the start of EVERY op — it only survives from a comparison to the immediately following op.lower_selectadditionally requires the popped condition register to be exactly the recordedbool_regANDout.len()unchanged since the comparison (also declines if a pop emitted a reload), so a stale record can never smuggle through.bool_regis a fresh temp pushed exactly once and popped by the select — nothing else observes it;rs1/rs2are unchanged because no instruction was emitted in between. The fused branch is emitted before anymv, sodstaliasing a comparison operand is harmless.Gates (all foreground, exit-code 0)
cargo test -p synth-cli --test frozen_codegen_bytes— 3/3 including the RV32 anchor (frozen_fixtures_rv32_text_is_bit_identical_oracle_001).scripts/repro/rv32_cmp_select_472_riscv_differential.py, unicorn RV32 vs wasmtime, symbols via ELF.symtab): all 11 fusible comparison kinds + i32-cmp-selecting-i64 + i64-cmp (out of scope, baseline path) + back-to-back selects + clamp, 13 vector pairs incl. sign boundaries (0x80000000 / 0xFFFFFFF0):.text1176 → 1096 bytes (−80 B, −6.8%).cargo test -p synth-backend-riscv— 206 passed, incl. 8 new_472tests (flag-off ≡ default path, per-kind fused sequences for lt_s/eq/ge_u/eqz, i64-operand select, adjacency invalidation vialocal.tee, i64-comparison exclusion).cargo fmt --checkexit 0;cargo clippy -p synth-backend-riscv --all-targets -- -D warningsexit 0.Closes #472.
🤖 Generated with Claude Code