Skip to content

Improve 3 functions, match 1 - #3307

Merged
MarkMcCaskey merged 1 commit into
doldecomp:masterfrom
titus-ssbm:opus/narrowing-conversions-20260904
Sep 4, 2026
Merged

Improve 3 functions, match 1#3307
MarkMcCaskey merged 1 commit into
doldecomp:masterfrom
titus-ssbm:opus/narrowing-conversions-20260904

Conversation

@titus-ssbm

Copy link
Copy Markdown
Contributor

Fixes four integer type declarations that caused MWCC to emit width and
signedness conversions that retail does not have.

When an argument is passed to a parameter narrower than itself, MWCC emits a
conversion at the call site (extsb, extsh, clrlwi). When the declared type
is wide enough, no conversion is emitted. Retail's codegen therefore pins the
width of each parameter: a plain register copy where we emit a mask means the
declaration is too narrow, and a mask where we emit a plain copy means it is too
wide. This is the s8-is-usually-an-int case described in CONTRIBUTING.

  • gm_801B5324: arg1 widened to s32. The indirect call through x54 now
    narrows its first argument as retail does. Matches.
  • fn_8016B388: arg1 widened to int, removing an extsh in the caller
    fn_801891F4 (99.517 -> 99.786).
  • mn_80230D18: arg2 widened to int, removing an extsb in the caller
    mn_80230E38 (99.843 -> 99.961).
  • ifStock_802F8298_get_flag: return type changed to u8. The getter and a
    later direct read of the same byte are one common subexpression, so the
    getter's int was carried into a comparison that retail performs unsigned
    (cmpwi -> cmplwi), improving ifStock_802F8298 (97.064 -> 97.191).

gm_801B5324 is the one case where s32 and int are not interchangeable: it
matches with s32 and regresses with int.

Claude Opus 5 did the function matching work.

Widen four integer type declarations that caused MWCC to emit width and
signedness conversions retail does not have.

gm_801B5324 arg1 -> s32 (matches), fn_8016B388 arg1 -> int, mn_80230D18
arg2 -> int, and ifStock_802F8298_get_flag returns u8.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BYEhCxFv7n35cBTiKK8e3L
@decomp-dev

decomp-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown

Report for GALE01 (3bf5523 - 88799d7)

📈 Matched code: 95.45% (+0.02%, +768 bytes)

✅ 1 new match
Unit Item Bytes Before After
main/melee/gm/gmallstar gm_801B5324 +45 94.21% 100.00%
📈 3 improvements in unmatched items
Unit Item Bytes Before After
main/melee/gm/gm_1884 fn_801891F4 +6 99.52% 99.79%
main/melee/mn/mnmainrule mn_80230E38 +3 99.84% 99.96%
main/melee/if/ifstock ifStock_802F8298 +2 97.06% 97.19%

@MarkMcCaskey MarkMcCaskey added the ai-assisted Utilizes a LLM to do the heavy lifting label Sep 4, 2026

@MarkMcCaskey MarkMcCaskey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@MarkMcCaskey
MarkMcCaskey merged commit 98dcaaa into doldecomp:master Sep 4, 2026
12 checks passed
usehoplite Bot pushed a commit to taiwancodex/melee that referenced this pull request Sep 4, 2026
Widen four integer type declarations that caused MWCC to emit width and
signedness conversions retail does not have.

gm_801B5324 arg1 -> s32 (matches), fn_8016B388 arg1 -> int, mn_80230D18
arg2 -> int, and ifStock_802F8298_get_flag returns u8.

Claude-Session: https://claude.ai/code/session_01BYEhCxFv7n35cBTiKK8e3L

Co-authored-by: titus-ssbm <306849928+titus-ssbm@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Utilizes a LLM to do the heavy lifting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants