Skip to content

Preserve comparison values before scalar assignments - #30

Merged
Sumaiter merged 3 commits into
mainfrom
fix/materialize-comparison-value
Nov 14, 2026
Merged

Sumaiter merged 3 commits into
mainfrom
fix/materialize-comparison-value

Conversation

@Sumaiter

@Sumaiter Sumaiter commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Comparisons assigned directly to an existing wide integer accumulator can lose a native comparison-result copy. Offer a bounded search child that first stores the comparison's existing int value in a local, then performs the original assignment conversion. Function signatures, destination types, operands, conditional evaluation and compiler flags are unchanged.

The shared rule accepts only standalone assignments to unescaped, unqualified, unambiguous local integers. It rejects effectful comparison operands, qualifiers, attributes, local typedefs, labels, macros and unsupported insertion sites. Queue budgets, claims, deduplication and independent promotion checks remain unchanged.

Independent review demonstrated that -Dint=volatile int could add observable volatile accesses through the new temporary. The rule now rejects macro overrides, forced headers, include-path overrides and response/profile options without rewriting the original flags. Regression tests cover the counterexample and ordinary optimization flags.

Validation:

  • 592 Python tests: 583 passed, 9 existing skips; 23 JavaScript tests passed.

  • Ten real, unchanged SN compiler builds across five independent synthetic headers/result contracts. All actual call relocation symbols/types/encoded addends are checked, including the double helper. Narrow-result and double cases retain identical code as explicit counterexamples to any universal improvement claim.

  • The generated AST reproduces a retained independently verified 36-to-40-byte correction after renaming only the new local; all six retail placements passed. No new game compilation or reservation transfer was used for that replay.

  • Built the VSIX and verified packaged runtime bytes and absence of game/compiler binaries. The package was not installed.

Compiler metadata, a reproducible optional runner and conservative negative tests are included. No ROM, game source, objects, private paths, proprietary compiler, game addresses or inferred ABI rules are contributed. This generates candidates; it does not certify semantics or matches.

Review correction: the preprocessing-option guard now also checks visible sourceFlags and compileCommand argv vectors from ps2decomp.json. A project-level -Dint=volatile int, forced include or response/profile option can no longer bypass the guard merely because the draft has no cflags comment. Malformed manifests/options disable this variant. Two new regression tests cover both option vectors, unchanged ordinary profiles, byte-for-byte preservation of project settings and invalid metadata. Opaque wrapper internals still require an independently established preprocessing contract; the rule does not inspect or execute them. All ten retained compiler-source hashes, five header hashes, call relocation/addend inventories and identical-text counterexamples were independently checked during review. No additional proprietary compiler or native game builds were run. The three changed runtime/documentation files match the rebuilt VSIX byte-for-byte.

@Sumaiter
Sumaiter merged commit b2e46c8 into main Nov 14, 2026
4 checks passed
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