Skip to content

fix(sv): preserve guarded division types through casts - #1766

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/sv-guarded-division-casts/preserve-guarded-division-types-casts--560b79b5
Oct 22, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/sv-guarded-division-casts/preserve-guarded-division-types-casts--560b79b5

Conversation

@tignear

@tignear tignear commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Casts of divisions and remainders could fail with unknown operand signedness
because the internal zero-divisor guard has an untyped unknown arm. Infer the
guard's signedness and width from its operation, and avoid inserting guards
again when binding an enclosing expression. This also preserves signed
arithmetic in four-state lowering instead of creating nested unsigned muxes.

Evaluate signing-cast operands in their original type before changing the
result sign, so unsigned'(a / b) does not turn a signed division unsigned.
Add two shared regressions for mixed signs, parameter divisors, narrowing,
nested divisions, signing/type casts, and four-state zero-divisor results.

Validation:

  • Full SV suite: 3952 passed, 20 existing ignored across five backends.
  • Analyzer unit tests: 791 passed, 3 existing ignored.
  • Shared suite unit tests: 46 passed, 2 existing ignored.
  • Icarus: both new cases passed. Verilator: ordinary case passed; the adapter
    reports the four-state case unsupported due to four-state expectations.
  • Affected library/harness Clippy (-D warnings), cargo fmt and diff checks pass.
  • Unchanged Taxi sources with O1/two-state pass 29 cocotb tests across
    mac_ctrl_rx[8], mac_ctrl_tx[8], and zircon_ip_len_cksum[32], with zero skips.
    Three other previously cast-blocked configurations now reach existing
    $size or SERDES array-range blockers. All 52 resolved SV source fingerprints
    match the original audit; no optimization settings or exclusions changed.

Casts of divisions and remainders could fail with unknown operand signedness
because the internal zero-divisor guard has an untyped unknown arm. Infer the
guard's signedness and width from its operation, and avoid inserting guards
again when binding an enclosing expression. This also preserves signed
arithmetic in four-state lowering instead of creating nested unsigned muxes.

Evaluate signing-cast operands in their original type before changing the
result sign, so unsigned'(a / b) does not turn a signed division unsigned.
Add two shared regressions for mixed signs, parameter divisors, narrowing,
nested divisions, signing/type casts, and four-state zero-divisor results.

Validation:
- Full SV suite: 3952 passed, 20 existing ignored across five backends.
- Analyzer unit tests: 791 passed, 3 existing ignored.
- Shared suite unit tests: 46 passed, 2 existing ignored.
- Icarus: both new cases passed. Verilator: ordinary case passed; the adapter
  reports the four-state case unsupported due to four-state expectations.
- Affected library/harness Clippy (-D warnings), cargo fmt and diff checks pass.
- Unchanged Taxi sources with O1/two-state pass 29 cocotb tests across
  mac_ctrl_rx[8], mac_ctrl_tx[8], and zircon_ip_len_cksum[32], with zero skips.
  Three other previously cast-blocked configurations now reach existing
  $size or SERDES array-range blockers. All 52 resolved SV source fingerprints
  match the original audit; no optimization settings or exclusions changed.

Change-Id: I560b79b58966e9083629921a4dbf6563ff5d09f3
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

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 ✅ Completed 2026-10-22T17:29:14.681114Z fa06cd7 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.

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

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 53 minutes 57 seconds in the queue, including 1 hour 10 minutes 18 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • 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

@mergify
mergify Bot merged commit 39f6650 into master Oct 22, 2026
30 checks passed
@mergify
mergify Bot deleted the stack/tignear/fix/sv-guarded-division-casts/preserve-guarded-division-types-casts--560b79b5 branch October 22, 2026 20:23
@mergify mergify Bot removed the queued Mergify queue entry label Oct 22, 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