Skip to content

perf(sv): reuse constants when expression contexts match - #1669

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/taxi-compatibility/reuse-constants-expression-contexts-match--2bdbf133
Oct 21, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/taxi-compatibility/reuse-constants-expression-contexts-match--2bdbf133

Conversation

@tignear

@tignear tignear commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Constant evaluation first computed each operand in its own context and then
walked the same subtree again even when width and signedness were unchanged.
Nested casts repeated this work, causing pathological growth in deep trees.
Reuse the computed value for matching contexts and for casts that do not
widen their operand. Reevaluate operands when width or signedness changes,
preserving context-dependent carries, division and four-state values under
IEEE 1800-2023 11.8.2.

Taxi BASE-R compilation with the debug host and generated O1 code decreases
from 174 seconds to 55 seconds. The release host improves from 30.9 seconds
to 8.4 seconds (user CPU 25.95s to 8.01s); generated code remains at O1.
The release baseline attributes about 60% of sampled CPU time to
context_binary_operands. The unchanged selected upstream
cocotb cases both pass after the optimization (2 executed, 238 skipped).
The full BASE-R matrix still needs the upstream 1fs precision override,
which the current CLI harness does not support; no all-matrix pass is claimed.

Validation: deep 48-layer constant casts including X/Z, widening carries and
signedness-changing division; 36 focused literal tests; full analyzer tests
(762 passed, 3 ignored); full SystemVerilog suite across five backends
(3242 passed, 90 ignored); formatting and affected-crate Clippy.

Depends-On: #1668

Constant evaluation first computed each operand in its own context and then
walked the same subtree again even when width and signedness were unchanged.
Nested casts repeated this work, causing pathological growth in deep trees.
Reuse the computed value for matching contexts and for casts that do not
widen their operand. Reevaluate operands when width or signedness changes,
preserving context-dependent carries, division and four-state values under
IEEE 1800-2023 11.8.2.

Taxi BASE-R compilation with the debug host and generated O1 code decreases
from 174 seconds to 55 seconds. The release host improves from 30.9 seconds
to 8.4 seconds (user CPU 25.95s to 8.01s); generated code remains at O1.
The release baseline attributes about 60% of sampled CPU time to
context_binary_operands. The unchanged selected upstream
cocotb cases both pass after the optimization (2 executed, 238 skipped).
The full BASE-R matrix still needs the upstream 1fs precision override,
which the current CLI harness does not support; no all-matrix pass is claimed.

Validation: deep 48-layer constant casts including X/Z, widening carries and
signedness-changing division; 36 focused literal tests; full analyzer tests
(762 passed, 3 ignored); full SystemVerilog suite across five backends
(3242 passed, 90 ignored); formatting and affected-crate Clippy.

Change-Id: I2bdbf133a10a898df17646cf566fa5a24496ff15
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-21T00:07:31.193432Z
We couldn’t complete this review. Comment @codex review to try again.
0bbfaa1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tignear

tignear commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(cli): configure SV parameter literals and simulation state modes #1646
2 fix(sv): preserve Taxi aggregates and sparse FF memories #1659
3 fix(vpi): expose unpacked arrays through lazy element handles #1660
4 fix(cli): reject empty cocotb test selections #1661
5 perf(vpi): avoid metadata cloning during value access #1668
6 perf(sv): reuse constants when expression contexts match #1669 👈
7 feat(cli): configure SV simulation timescales #1672

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 21, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 21, 2026
@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 38 minutes 12 seconds in the queue, including 44 minutes 17 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • depends-on = celox-sim/celox#1668 [⛓️ perf(vpi): avoid metadata cloning during value access #1668]
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

Base automatically changed from stack/tignear/fix/taxi-compatibility/avoid-metadata-cloning-value-access--64bd0bd3 to master October 21, 2026 02:38
@mergify
mergify Bot merged commit 3078a32 into master Oct 21, 2026
31 checks passed
@mergify
mergify Bot deleted the stack/tignear/fix/taxi-compatibility/reuse-constants-expression-contexts-match--2bdbf133 branch October 21, 2026 02:40
@mergify mergify Bot removed the queued Mergify queue entry label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant