Skip to content

Reduce SV case-local scalar replay mux allocations - #541

Merged
xtofalex merged 1 commit into
mainfrom
sv-case-scalar-accumulator
Nov 16, 2026
Merged

xtofalex merged 1 commit into
mainfrom
sv-case-scalar-accumulator

Conversation

@xtofalex

Copy link
Copy Markdown
Collaborator

SV case replay currently materializes each arm merge, so repeated scalar selections allocate intermediate muxes that the frontend cleanup later removes. Keep whole-scalar selections in a private accumulator owned by one case statement and reuse SNLHDLMuxSelection to fold compatible common arms before emission.

Arm, selector and item evaluation remains eager against incoming replay values. Pending entries stay outside active replay environments and expression caches, and materialize in declaration order at case exit. Nested cases, vectors, scheduling, loops and uncertain effects retain their existing boundaries. Both SV and VHDL calls to mergeRepeatedMuxSelections remain enabled; primitive semantics are unchanged.

The synthetic allocation fixture finishes with four muxes in both variants, while bitnets decrease from 40 to 32 and abandoned intermediate nets from four to zero. This establishes construction-time avoidance for that fixture; it does not establish coverage of the audit's 207 opportunities or an external-workload speedup. Details are in regress/mux-reduction/case-replay-scalars.md.

Validation on arm64 macOS with Release CMake:

  • Passed 1,367 SV constructor/intent, 269 VHDL constructor, 365 serialization, 15 HDL primitive/helper and 11 mux utility tests.
  • Passed all 45 cross-process determinism tests, including live state, dumps, snapshots, round trips and cold reloads.
  • Added focused coverage for common-arm orientations, equal/distinct guards, nested cases, incoming reads, dependent symbols, sharing, fallback boundaries, eager diagnostics and four-state scalar data with binary controls.
  • Passed REUSE lint and git diff --check.

Bazel parity and BCR readiness were not evaluated. No external-workload allocation or timing campaign was run.

@codecov-commenter

codecov-commenter commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ormats/systemverilog/frontend/SNLSVConstructor.cpp 93.10% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Nov 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 14 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 111 untouched benchmarks


Comparing sv-case-scalar-accumulator (1477042) with main (49bfc05)

Open in CodSpeed

@xtofalex
xtofalex merged commit 1689438 into main Nov 16, 2026
121 of 122 checks passed
@xtofalex
xtofalex deleted the sv-case-scalar-accumulator branch November 16, 2026 23:08
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.

2 participants