Repository navigation
[AUTOMATED] Set C from the shifter in Thumb-2 ands, bics, movs and mvns - #1909
Merged
Merged
Conversation
The Thumb-2 flag-setting and/bic/mov/mvn with a modified immediate, and and/mvn with a shifted register, used thSBIT_ZN and so set only N and Z. The architecture sets C to the shifter's carry-out, which ThumbExpandImm12 and thshift2 already compute as shift_carry; orrs, eors and tst use it. A bcs after `ands.w r0,r1,r2,lsr #1` read the carry from before it. These constructors now set C from shift_carry; movs.w of an unshifted register still leaves C alone. Found by comparing kuna's lift with Unicorn instruction by instruction: on Cortex-M firmware three such forms differed on C, and on an assembled set of 76 logical forms 14 differed; all now match. The ARM8_le compiler-oracle digest is regenerated with slacomp, which reproduces the old digest on the old sources. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sjkim1127
force-pushed
the
fix/thumb2-logical-carry
branch
from
November 23, 2026 13:04
f9c70f8 to
05d6a7b
Compare
Conflicts: the stage-corpus count in xml.rs (main 883 + this PR's file = 884) and docs/baseline-stages.json (synthesized: main's assertions plus this PR's 3). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
Conflicts: the stage-corpus count in xml.rs (main 884 + this PR's file = 885) and docs/baseline-stages.json (synthesized: main's assertions plus this PR's 3). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
Contributor
|
[AUTOMATED] Pushed merge commits on top of 05d6a7b to bring the branch up to main (60b8400). Only the stage-corpus count in |
Conflicts: the stage-corpus count in xml.rs (main 885 + this PR's file = 886) and docs/baseline-stages.json (synthesized: main's assertions plus this PR's 3). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
Conflicts: the stage-corpus count in xml.rs (main 886 + this PR's file = 887) and docs/baseline-stages.json (synthesized: main's assertions plus this PR's 3). The compiler oracle merged cleanly: main's AArch64 digest and this PR's ARM8_le digest. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
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.
[AUTOMATED]
On Thumb-2, kuna's
ands,bics,movsandmvnswith a modified immediate or a shifted register leave the carry flag unchanged. The architecture sets C to the shifter's carry-out, so abcsafter them tests the wrong bit.shift_carry, which their immediate and shifted-register operands already compute and whichorrs,eorsandtstalready use. The function above now printsif (!(a2 & 1)) return 1; return 2;.movs.wof an unshifted register still leaves C alone, as the architecture does.slacompreproduces the old digest on the old sources.tests/stages/kuna-thumb2-logical-carry.xmlhas the shifted-register case above and an immediate whose carry-out is 0. All 3 of its assertions fail without the fix. Compared one instruction at a time against Unicorn, 14 of 76 assembled Thumb-2 logical forms differed on C and none do now. The datatest corpus is unchanged, and decompiling a 6 MB Cortex-M firmware takes the same time.🤖 Generated with Claude Code
Model:
anthropic/claude-opus-5-5