Skip to content

fix(sv): preserve X/Z in two-state exact comparisons - #2244

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/sv-two-state-case-equality/preserve-x-z-two-state-exact-comparisons--2b96b818
Oct 27, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/sv-two-state-case-equality/preserve-x-z-two-state-exact-comparisons--2b96b818

Conversation

@tignear

@tignear tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Two-state lowering converted X/Z operands to zero before ===, !== and
ordinary case matching. A parity check against X could therefore accept
a known zero and clear an instruction-loader byte (#2136).

Retain literal unknowns inside exact-comparison operands and project their
value and mask into ordinary two-state SLT expressions before backend
lowering. Apply the same rules to combinational/procedural expressions and
case matching, including width extension and conditional/arithmetic
operands. Storage stays two-state, calls keep their effects, and known-only
comparisons reuse their interned graph (IEEE 1800-2023 11.4.5 and 12.5).

Preserve actual startup unknowns too: encode default four-state function
locals as X rather than Z (6.8, Table 6-7), and keep partially driven nets
out of constant-variable inlining when any read touches undriven bits.
Merge sparse driver intervals to check coverage without a full-width bit
mask. Fully covered constant reads remain eligible for inlining. Test
interior gaps, high undriven bits, contiguous fragments and dependency
preservation. The existing startup API regressions now explicitly check
both state modes and verify that comparison results have no unknown bits.

Add five shared regressions for operand order, signed/wide patterns,
X versus Z, conversion, FF/timed execution, loaded bytes, call effects and
unknown intermediates. Icarus passes all five unchanged cases. Verilator
passes the timed effects case and rejects four with unsupported tristate
constructs; retain the actual diagnostics, check their named cases,
status, phase and diagnostic, and keep them executable without exclusions.

Validation: 5,868 SV integration tests passed (20 existing ignored tests),
4,619 Veryl shared executions across native, native-parallel, Cranelift,
Cranelift-parallel, WASM and the interpreter passed, as did 186 SLT unit
tests, 9 frontend unit tests and all 4 retained-report integration tests.
Changed crates/test targets pass clippy, formatting and workspace checks.
The native NAPI addon builds and all 116 JS boundary tests pass.

The companion performance-stack PR #2233 maintains the correction for
the base's CodegenError::message feature gating in host-runtime-disabled
SV builds. A pre-existing case-coverage false positive remains: an
exhaustive case on {b, 1'bx} with only 2'b0x and 2'b1x labels is diagnosed
as a latch. Both reproduce on the unchanged base and are not duplicated
or broadened into this patch.

The repository-script checks also enumerate the same four SV Verilator
tristate compile failures. All 316 Node script tests, three benchmark-shell
fixture suites and three updatecli unit tests pass on master 89b46b1.

Fixes #2136

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T11:53:51.350733Z 1ada59c New commits
ℹ️ 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 27, 2026
@tignear
tignear force-pushed the stack/tignear/fix/sv-two-state-case-equality/preserve-x-z-two-state-exact-comparisons--2b96b818 branch from 61b4657 to 2d4738e Compare October 27, 2026 07:27
@tignear

tignear commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 61b4657 2026-10-27 07:26 UTC
2 content 61b4657 → 2d4738e Resolve master conflicts by retaining both logical-equivalence and X/Z comparison fixtures and limitations. Rebased onto 07ec9d9; 330 operator backend tests, 9 frontend and 32 suite units, clippy … 2026-10-27 07:26 UTC
3 content 2d4738e → 80fe8ba Fix CI regressions: explicitly verify startup comparisons in both state modes; correct default local X encoding and unsafe constant inlining of undriven bits; validate the four retained Verilator tri… 2026-10-27 09:11 UTC
4 content 80fe8ba → 1ada59c Fix merge-queue Lint & Format: enumerate the four recorded SV Verilator tristate failures in the JS report-gate test. All 316 repository Node tests, three benchmark shell suites and three updatecli u… 2026-10-27 11:50 UTC

@tignear
tignear force-pushed the stack/tignear/fix/sv-two-state-case-equality/preserve-x-z-two-state-exact-comparisons--2b96b818 branch from 2d4738e to 80fe8ba Compare October 27, 2026 09:11
@mergify mergify Bot added the queued Mergify queue entry label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

❌ Left the queue · Lint & Format fails with this pull request

1 h 51 min in the queue, 14 min of it CI.

So far

The failure is in this pull request. When Mergify split its batch, it failed alone on top of master.

Reason

The merge conditions cannot be satisfied due to failing checks

  • Lint & Format

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, comment @mergifyio queue to queue it again as it is.
Merge conditions: 2 of 9 met

The batch, tested on draft #2267

Condition Required by
❌ check-success = Queue validation —
❌ any of: check-neutral = @github-actions/Lint & Format, check-skipped = @github-actions/Lint & Format, check-success = @github-actions/Lint & Format GitHub repository ruleset rule master
❌ any of: check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU), check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU), check-success = @github-actions/NAPI Build (Linux ARM64 GNU) GitHub repository ruleset rule master
❌ any of: check-neutral = @github-actions/NAPI Build (Windows), check-skipped = @github-actions/NAPI Build (Windows), check-success = @github-actions/NAPI Build (Windows) GitHub repository ruleset rule master
❌ any of: check-neutral = @github-actions/Rust Test & NAPI Build, check-skipped = @github-actions/Rust Test & NAPI Build, check-success = @github-actions/Rust Test & NAPI Build GitHub repository ruleset rule master
❌ any of: check-neutral = @github-actions/JS Test (Ubuntu), check-skipped = @github-actions/JS Test (Ubuntu), check-success = @github-actions/JS Test (Ubuntu) GitHub repository ruleset rule master
❌ any of: check-neutral = @github-actions/JS Test (Windows), check-skipped = @github-actions/JS Test (Windows), check-success = @github-actions/JS Test (Windows) GitHub repository ruleset rule master
✅ check-success = Conventional Commit title —
✅ any of: check-success = @github-actions/Conventional Commit title, check-neutral = @github-actions/Conventional Commit title, check-skipped = @github-actions/Conventional Commit title GitHub repository ruleset rule master

Requeued — the merge queue status continues in this comment ↓.

Times in UTC · dashboard · how the merge queue works

Two-state lowering converted X/Z operands to zero before ===, !== and
ordinary case matching. A parity check against X could therefore accept
a known zero and clear an instruction-loader byte (#2136).

Retain literal unknowns inside exact-comparison operands and project their
value and mask into ordinary two-state SLT expressions before backend
lowering. Apply the same rules to combinational/procedural expressions and
case matching, including width extension and conditional/arithmetic
operands. Storage stays two-state, calls keep their effects, and known-only
comparisons reuse their interned graph (IEEE 1800-2023 11.4.5 and 12.5).

Preserve actual startup unknowns too: encode default four-state function
locals as X rather than Z (6.8, Table 6-7), and keep partially driven nets
out of constant-variable inlining when any read touches undriven bits.
Merge sparse driver intervals to check coverage without a full-width bit
mask. Fully covered constant reads remain eligible for inlining. Test
interior gaps, high undriven bits, contiguous fragments and dependency
preservation. The existing startup API regressions now explicitly check
both state modes and verify that comparison results have no unknown bits.

Add five shared regressions for operand order, signed/wide patterns,
X versus Z, conversion, FF/timed execution, loaded bytes, call effects and
unknown intermediates. Icarus passes all five unchanged cases. Verilator
passes the timed effects case and rejects four with unsupported tristate
constructs; retain the actual diagnostics, check their named cases,
status, phase and diagnostic, and keep them executable without exclusions.

Validation: 5,868 SV integration tests passed (20 existing ignored tests),
4,619 Veryl shared executions across native, native-parallel, Cranelift,
Cranelift-parallel, WASM and the interpreter passed, as did 186 SLT unit
tests, 9 frontend unit tests and all 4 retained-report integration tests.
Changed crates/test targets pass clippy, formatting and workspace checks.
The native NAPI addon builds and all 116 JS boundary tests pass.

The companion performance-stack PR #2233 maintains the correction for
the base's CodegenError::message feature gating in host-runtime-disabled
SV builds. A pre-existing case-coverage false positive remains: an
exhaustive case on {b, 1'bx} with only 2'b0x and 2'b1x labels is diagnosed
as a latch. Both reproduce on the unchanged base and are not duplicated
or broadened into this patch.

The repository-script checks also enumerate the same four SV Verilator
tristate compile failures. All 316 Node script tests, three benchmark-shell
fixture suites and three updatecli unit tests pass on master 89b46b1.

Fixes #2136

Change-Id: I2b96b81844d9977a40668002b257c8bf845a249b
@tignear
tignear force-pushed the stack/tignear/fix/sv-two-state-case-equality/preserve-x-z-two-state-exact-comparisons--2b96b818 branch from 80fe8ba to 1ada59c Compare October 27, 2026 11:50
@mergify mergify Bot added queued Mergify queue entry and removed dequeued Mergify stopped this queue entry; investigate before retrying labels Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into master as 9cd3910 at 12:29 UTC

10 min in the queue, 8 min of it CI.

So far

Merge conditions: 7 of 7 met

The batch, tested on draft #2273

Condition Required by
✅ check-success = Conventional Commit title —
✅ check-success = Queue validation —
✅ any of: check-success = @github-actions/Lint & Format, check-neutral = @github-actions/Lint & Format, check-skipped = @github-actions/Lint & Format GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Rust Test & NAPI Build, check-neutral = @github-actions/Rust Test & NAPI Build, check-skipped = @github-actions/Rust Test & NAPI Build GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/JS Test (Ubuntu), check-neutral = @github-actions/JS Test (Ubuntu), check-skipped = @github-actions/JS Test (Ubuntu) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Conventional Commit title, check-neutral = @github-actions/Conventional Commit title, check-skipped = @github-actions/Conventional Commit title GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Queue validation, check-neutral = @github-actions/Queue validation, check-skipped = @github-actions/Queue validation GitHub repository ruleset rule master

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot mentioned this pull request Oct 27, 2026
32 of 55 tasks
@mergify
mergify Bot merged commit 9cd3910 into master Oct 27, 2026
24 checks passed
@mergify
mergify Bot deleted the stack/tignear/fix/sv-two-state-case-equality/preserve-x-z-two-state-exact-comparisons--2b96b818 branch October 27, 2026 12:29
@mergify mergify Bot removed the queued Mergify queue entry label Oct 27, 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.

SV two-state: case equality and case labels match X/Z literal bits as zero

1 participant