Skip to content

fix(sir-opt): preserve live operands of shared bit-extract shifts - #1981

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/sir-shared-shift-uses/preserve-live-operands-shared-bit-extract-shifts--9e413552
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/fix/sir-shared-shift-uses/preserve-live-operands-shared-bit-extract-shifts--9e413552

Conversation

@tignear

@tignear tignear commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

When two bit-extract replacements share a dead shift, the cleanup visits that
shift twice and decrements its operand use counts twice. This can delete the
shift amount even when another live shift still uses it, producing invalid SSA.

Only decrement a dead instruction's operands when it is first inserted into the
removal set. Add a regression with two masked uses of one shift and a separate
live shift sharing its amount; verify SSA before and after the actual pass.

This isolates the concrete bug fix found during formal-verification work. It
contains no extraction refactors and does not claim a universal pass proof.

Validation: the new regression fails before the fix with
SSA.USE_HAS_DEFINITION (r1 is used but never defined). After the fix,
celox-sir-opt has 469 passing unit tests (1 ignored) and 1 passing doctest;
cargo clippy --locked -p celox-sir-opt --all-targets -- -D warnings and
cargo fmt --all -- --check pass.
The existing masked_shift_fields_keep_expression_width regression also passes
on Wasm, native, Cranelift, native parallel and Cranelift parallel
backends (5 tests). Shared cases and external simulator adapters are unchanged.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T09:36:59.625555Z 1355bbe 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.

When two bit-extract replacements share a dead shift, the cleanup visits that
shift twice and decrements its operand use counts twice. This can delete the
shift amount even when another live shift still uses it, producing invalid SSA.

Only decrement a dead instruction's operands when it is first inserted into the
removal set. Add a regression with two masked uses of one shift and a separate
live shift sharing its amount; verify SSA before and after the actual pass.

This isolates the concrete bug fix found during formal-verification work. It
contains no extraction refactors and does not claim a universal pass proof.

Validation: the new regression fails before the fix with
SSA.USE_HAS_DEFINITION (r1 is used but never defined). After the fix,
celox-sir-opt has 469 passing unit tests (1 ignored) and 1 passing doctest;
cargo clippy --locked -p celox-sir-opt --all-targets -- -D warnings and
cargo fmt --all -- --check pass.
The existing masked_shift_fields_keep_expression_width regression also passes
on Wasm, native, Cranelift, native parallel and Cranelift parallel
backends (5 tests). Shared cases and external simulator adapters are unchanged.

Change-Id: I9e413552cce93def93a0ef57f46d82ac323a8d7f
@tignear
tignear force-pushed the stack/tignear/fix/sir-shared-shift-uses/preserve-live-operands-shared-bit-extract-shifts--9e413552 branch from 1355bbe to 1bd8785 Compare October 25, 2026 09:36
@tignear

tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 1355bbe 2026-10-25 09:36 UTC
2 rebase 1355bbe → 1bd8785 (rebase only) Correct the validation backend name from interpreter to Wasm; no source changes. 2026-10-25 09:36 UTC

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

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 2 minutes 10 seconds in the queue, including 46 minutes 38 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 0ae543c into master Oct 25, 2026
23 checks passed
@mergify
mergify Bot deleted the stack/tignear/fix/sir-shared-shift-uses/preserve-live-operands-shared-bit-extract-shifts--9e413552 branch October 25, 2026 11:23
@mergify mergify Bot removed the queued Mergify queue entry label Oct 25, 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