Skip to content

[review] mstan #272 - recompiler: sync GTE read-helper classification with runtime accessor semantics - #6

Closed
Alexbeav wants to merge 1 commit into
review-base/mstan-47bda8172e43from
review/mstan-272-gte-read-classification
Closed

[review] mstan #272 - recompiler: sync GTE read-helper classification with runtime accessor semantics#6
Alexbeav wants to merge 1 commit into
review-base/mstan-47bda8172e43from
review/mstan-272-gte-read-classification

Conversation

@Alexbeav

@Alexbeav Alexbeav commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Purpose

This is a review-only retrofit for the already-open upstream PR mstan/psxrecomp#272.

Do not merge this PR. The AI reviewer must inspect this exact diff before the next upstream update.

Identity

  • Upstream base: 47bda8172e43fdba1879c1a5885904a265c567f6
  • Review head: 62dc9b9bb4b72bbacedada5736d783bd331e0784
  • Upstream branch: pr/gte-read-classification

Review gate

Classify each finding as valid, invalid, or uncertain. A valid finding requires a correction, a regression, and repeated validation. An uncertain finding blocks the next upstream update.

Developed with AI assistance; validated as described (test evidence in PR body). AI writes the code and the PR, but I always test before I send something up. Happy to iterate on this process with your feedback.


Summary by cubic

Fixes the GTE read-helper classification so compiled code applies the same masking and sign-extension as the runtime accessors for data and control register reads.

  • Expands data_read_needs_helper to cover regs 1, 3, 5, 7, 16-19, and ctrl_read_needs_helper to include 4, 12, 20.
  • Updates the static assertion masks to match the new helper sets.

Review-only PR for upstream mstan/psxrecomp#272; do not merge.

Written for commit 62dc9b9. Summary will update on new commits.

Review in cubic

… semantics

The emitter's mfc2/cfc2 raw-vs-helper classification
(gte_register_classification.h) was out of sync with the runtime's
gte_read_data/gte_read_ctrl special cases: compiled code read OTZ(7)
and SZ0-3(16-19) unmasked and VZ/IR-class regs (1,3,5,8-11) without
sign extension, and cfc2 missed ctrl regs 4/12/20 — while the
interpreter always goes through the accessors. Nine data regs + three
ctrl regs of backend semantic divergence, locked in by a stale
static_assert mask.

data_read_needs_helper now covers every gte_read_data special case
(masks 0xB08F8FAA data / 0xEC101010 ctrl); regenerate titles to pick
it up.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="recompiler/include/gte_register_classification.h">

<violation number="1" location="recompiler/include/gte_register_classification.h:12">
P3: The new comments describe unsigned masked registers as sign-extended, which misstates the accessor contract. Rewrite both comments to distinguish zero-extension from sign-extension.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@@ -8,7 +8,12 @@
namespace PSXRecompGTERegisters {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The new comments describe unsigned masked registers as sign-extended, which misstates the accessor contract. Rewrite both comments to distinguish zero-extension from sign-extension.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At recompiler/include/gte_register_classification.h, line 12:

<comment>The new comments describe unsigned masked registers as sign-extended, which misstates the accessor contract. Rewrite both comments to distinguish zero-extension from sign-extension.</comment>

<file context>
@@ -8,7 +8,12 @@
 constexpr bool data_read_needs_helper(uint8_t reg) {
-    return (reg >= 8 && reg <= 11) || reg == 15 || reg == 23 ||
+    /* Must cover every reg gte_read_data() treats specially (gte.cpp):
+     * 1,3,5,8-11 sign-extend; 7,16-19 mask to 16 bits; 15 mirrors 14;
+     * 28/29 pack IRGB; 31 computes LZCR. 23 kept from the legacy set. */
+    return reg == 1 || reg == 3 || reg == 5 || reg == 7 ||
</file context>

@Alexbeav

Copy link
Copy Markdown
Owner Author

Review complete. The corresponding upstream PR was merged: mstan#272

Closing this fork review without merge. Its immutable base, discussion, and commit history remain available as evidence.

@Alexbeav Alexbeav closed this Aug 31, 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