Skip to content

Add GC_2_0p3: 2.0p2 plus FFCC Japan's alias rules - #4

Closed
frioux wants to merge 1 commit into
doldecomp:mainfrom
frioux:gc-2.0p3
Closed

frioux wants to merge 1 commit into
doldecomp:mainfrom
frioux:gc-2.0p3

Conversation

@frioux

@frioux frioux commented Nov 10, 2026

Copy link
Copy Markdown

Adds GC_2_0p3, a derived version like GC_2_0p2 (and #3's GC_2_5a): BFBB's 2.0p2 plus four alias-analysis rules that the Japanese game code of the Final Fantasy Crystal Chronicles decompilation needs. The name "2.0p3" is provisional; happy to rename it (2.0p2f, 2.0f, ...). It is independent of #3; the two touch include/version.h and the README table, so whichever lands second needs a trivial rebase.

What

  • include/version.h: VERSION_GC_2_0P3 between 2.0p2 and 2.5 (2.5, 2.6 and 2.7 move up one index). config/GC_2_0p3/config.json has "derived_from": "GC_2_0": the tooling resolves functions and the original executable one level deep, so a version derived from 2.0p2 itself would not build source-only; the description says it is 2.0p2-based.
  • Every VERSION == VERSION_GC_2_0P2 test also takes 2.0p3 (|| VERSION == VERSION_GC_2_0P3, != likewise), and <= VERSION_GC_2_0P2 becomes <= VERSION_GC_2_0P3 (build 92, build date). So 2.0p3 is 2.0p2 everywhere else.
  • Alias.c, 2.0p3 only:
    • gather_instruction_alias: an access keeps its own alias when other reaching definitions of its base register have none (the loop that downgrades it to worst_case is skipped);
    • may_alias_scheduling: a worst_case store (e.g. the prologue's register saves) and a load of a stack-passed parameter (VarInfoFlag_ParamArea) may alias;
    • is_pointer_like_load: a direct small-data load counts even when the global is const, and a load of part of a small @ literal counts like a load of the whole one.
  • README: table row (counts copied from 2.0p2, as the new code is static inline), a note under the table, and a section in the style of the BFBB one.

Why / evidence

Measured on FFCC's Japanese game code: every unit the project builds with its Japanese compiler (268 units, 3081 functions), scored per function like FFCC's report.json (objdiff 3.6.1). FFCC has so far used 2.0p1k, BFBB's 2.0p1g binary-patch chain plus four FFCC patch steps.

Compiler Japan (of 3081) vs. 2.0p1k
2.0 2380 +0 / -622
2.0p1 2766 +0 / -236
2.0p1g (BFBB) 2959 +0 / -43
2.0p1k (FFCC) 3002
2.5 2368 +0 / -634
2.0p2 2994 +10 / -18
2.0p3 3014 +12 / -0
  • 2.0p2 alone already matches ten functions that FFCC's patched compiler never did. Its 18 losses are exactly two behaviours of FFCC's patches, ported here as the first two rules: +13 / -0 and +5 / -0 on top of 2.0p2. The other two rules are new, +1 / -0 each, and each rests on a single function that changes nothing else (CMenuPcs::SetWorldParam: a static const member in .sdata2 whose load stays below stores into this; CChara::CModel::DrawFur: the copies of two 8-byte {0, 0} initialisers stay below the first array's stores).
  • FFCC's other patch clauses (e3ns, c3a, dsl) were ported too, as experiments: an instrumented build shows they never change a scheduling answer on top of 2.0p2 (its floating-point-literal and small-data-store rules already cover them), so they are not included.
  • 265 of the 274 Japanese objects are byte-identical to 2.0p1k's. The other nine differ only in the twelve functions 2.0p3 matches and three that come closer; no function declines.
  • FFCC's sound library (8 units, built with BFBB's 2.0p1g in all three regions) gives byte-identical objects with 2.0p1g, 2.0p2 and 2.0p3.
  • Switching each remaining 2.0 behaviour to 2.5's on top of 2.0p3, one #if VERSION at a time (148 sites, 77 that build and change the executable), gains nothing. Removing 2.0p2's own rules one at a time loses functions for most of them (up to 218, for the small-data store rule); the floating-point-literal const, copy propagation and small-data value-kill lines change nothing on FFCC. So FFCC Japan independently supports 2.0p2's model.

Only FFCC has been measured. I could not rebuild BFBB (or Ratatouille) with 2.0p3 here; nothing changes for anyone who does not select it.

How tested (macOS arm64, LLVM 23)

  • python configure.py && ninja: all six versions build with clang; build/GC_{2_0,2_0p2,2_5,2_6,2_7}/clang/mwcceppc.exe are byte-identical to the same build of main.
  • configure.py --mwcc: ninja build/GC_2_0/ok build/GC_2_5/ok build/GC_2_6/ok build/GC_2_7/ok gives the same per-function results as before (compare.json functions identical), and build/GC_2_0p3/source-only/mwcceppc.exe and build/GC_2_0p2/source-only/mwcceppc.exe link ("4068 functions, all from the sources"). The MWCC-built source-only 2.0p3 gives the same objects as the clang build on all 274 Japanese FFCC units and the 8 sound units in each region.
  • ruff format --check, ruff check, clang-format --dry-run -Werror on the changed C sources: clean.
  • Not run: --matching / relink.ok, tools/verify.py's regressions baseline, the native Linux build (not available on arm64 macOS). files.decomp.dev failed here earlier, so build/compilers was seeded from FFCC's copy of the same compiler bundle.

FFCC will switch its Japanese game code and sound library to this build once it is merged and released; the FFCC side (draft) expects the release archive to carry 2.0p3/mwcceppc.exe.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QmcpERTQ1WaRZ73F12eUis

A derived version like GC_2_0p2 and GC_2_5a: GameCube 2.0p2 (BFBB's model)
plus four rules measured on the Japanese game code of the Final Fantasy
Crystal Chronicles decompilation:

- gather_instruction_alias keeps an access's own alias when other reaching
  definitions of its base register have none;
- may_alias_scheduling orders a worst_case store before a load of a
  stack-passed parameter;
- is_pointer_like_load treats const small-data globals like the others;
- is_pointer_like_load treats a load of part of a small literal like a load
  of a whole one.

Every other version builds byte-identically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QmcpERTQ1WaRZ73F12eUis
@frioux

frioux commented Nov 15, 2026

Copy link
Copy Markdown
Author

Closing in favour of PrimeDecomp/mwcc-tools#4, the same change ported to mwcc-tools' gc2/.

@frioux frioux closed this Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant