Skip to content

fix(shaders): a loop that leaves by predicated EXITs ends at its closing self-branch (the last program that did not lower) - #1810

Merged
hckrman101 merged 1 commit into
NotRexed:mainfrom
Joey-Magnus:fix/lower-end-at-closing-branch
Nov 10, 2026
Merged

hckrman101 merged 1 commit into
NotRexed:mainfrom
Joey-Magnus:fix/lower-end-at-closing-branch

Conversation

@Joey-Magnus

Copy link
Copy Markdown
Contributor

The last of OoT's programs that fail to translate (f24a3ebf686232fb, a compute program with matrix multiplies) is refused as "native program has no unconditional EXIT". It's a loop that leaves only through @P0 EXIT, so it has no unconditional EXIT. It ends the way NVIDIA's compiler closes such programs: the loop's unconditional BRA back, then a BRA to itself that nothing reaches.

The end of the program (instructions 1808-1809, then NOP padding to 1823; its five EXITs at 646, 956, 1244, 1525 and 1528 are all @P0):

1808  00007947 ffffb710 0383ffff 000fea00   BRA 642     (the loop, unconditional)
1809  00007947 fffffff0 0383ffff 000fc000   BRA 1809    (the closing self-branch)

Change (lower_to_maxwell.h, BRA): the closing self-branch already ended a program after a jump table (computed_branch). It now also ends one when the instruction before it is an unconditional BRA or EXIT, so nothing can fall into it, and the program makes no calls. finish still refuses if any branch points past the end. A self-branch that can be fallen into is still not an end, and programs that end at an unconditional EXIT end there as before.

Tests

🤖 Generated with Claude Code

…nditional jump back

One of OoT's compute programs is a loop that leaves only by @p0 EXIT: it ends with the
loop's unconditional BRA back and the closing BRA to itself, and was refused as "native
program has no unconditional EXIT". The self-branch was the end only after a jump table;
now also when the instruction before it is an unconditional BRA or EXIT (nothing falls into
it) and the program makes no calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Joey-Magnus
Joey-Magnus force-pushed the fix/lower-end-at-closing-branch branch from 8ca9cd3 to 7e1db37 Compare November 10, 2026 18:01
@hckrman101
hckrman101 merged commit a8e7ee5 into NotRexed:main Nov 10, 2026
7 of 9 checks passed
Joey-Magnus pushed a commit to Joey-Magnus/Hookshot that referenced this pull request Nov 10, 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