Repository navigation
fix(sir-opt): preserve live operands of shared bit-extract shifts - #1981
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
force-pushed
the
stack/tignear/fix/sir-shared-shift-uses/preserve-live-operands-shared-bit-extract-shifts--9e413552
branch
from
October 25, 2026 09:36
1355bbe to
1bd8785
Compare
Contributor
Author
Revision history
|
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
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.