Fixed to handle composite types in conditional expressions#14
Open
mycoboco wants to merge 1 commit into
Open
Conversation
AJBats
added a commit
to AJBats/saturncc
that referenced
this pull request
Apr 18, 2026
LCC's front-end wraps `int + int_disp` results in LOAD(LOAD(...))
nodes when the value is cast to pointer for INDIR. This blocks the
compound `reg: INDIRI2(ADDI4(reg,immi8))` dispload rule from
matching — the INDIRI2 sees LOAD, not ADDI4, as its direct child.
The `char * + int_disp` path produces ADDP4 directly (no LOAD
wrappers) and the compound rule matches cleanly. Same ABI either
way — both pass in r4 as a 32-bit value.
Impact:
- FUN_06044834: 20 -> 16 diffs vs prod.
- All three .w loads now use displacement mode:
mov.w @(14,r4),r0 (was: mov r4,r1; add drh#14,r1; mov.w @r1,r1)
mov.w @(26,r4),r0
mov.w @(30,r4),r0
Remaining 16-diff divergence decomposes into three gaps, tracked
for proof-of-thesis progress:
- Gap 9: 3x redundant `exts.w` (SH-2's mov.w already sign-extends)
- peephole: 2x extra `mov r0,rN; add rN,r1` vs prod's direct `add r0,r1`
- Gap 2: prod uses indexed for offsets 26 and 30 despite both
fitting .w disp range (max 30). SHC heuristic under investigation.
Baseline re-pinned. All 28 validate_build stages green; broad
corpus 168/168 unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
lcc currently fails to correctly handle composite types in conditoinal expressions. For example,
The two assignments to
care both invalid, but lcc complains that only the latter is.This commit fixes the problem by adding two calls to
composite()when checking types for conditional expressions.