shader: allow s_load into high SGPRs s[104:107] in gfx2hlsl (Part of #1723) #2050

Merged
tedin7 merged 8 commits from upstream-pr/2057 into main 2026-11-25 22:55:39 +00:00
tedin7 commented 2026-11-24 23:44:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:44:59Z.


Part of #1723

What this unblocks: 224 draw refusals (s_load into s[104:107]).

The translator refused any s_load whose destination ended above s105. s106/s107 are vcc, so s_load_dwordx4 s[104:107], <table ptr>, imm was refused even though a descriptor load emits no code: it only records which table bytes the registers name. Now a descriptor load may end in s[104:107]. A root constant-buffer load (which must write the registers), a load starting above s105, and a destination past s107 are still refused.

Note: later code must not read vcc before redefining it. Compilers do not do this after a descriptor load.

Verification: (run locally in the worktree on Linux; the Win2025 run is not done)

  • python3 -B tests/startup_gfx2hlsl_sload_s104_check.py -> ok (fails on main with s_load destination s[104:107] for 4 dwords)
  • python3 -B tests/startup_gfx2hlsl_{smem_offset,op_refusals,readfirstlane_uniform,operand_count,capture}_check.py -> all exit 0
  • Test registered in CMakeLists.txt as startup_gfx2hlsl_sload_s104.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593739788 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:44:59Z. --- Part of #1723 What this unblocks: 224 draw refusals (s_load into s[104:107]). The translator refused any `s_load` whose destination ended above s105. s106/s107 are vcc, so `s_load_dwordx4 s[104:107], <table ptr>, imm` was refused even though a descriptor load emits no code: it only records which table bytes the registers name. Now a descriptor load may end in s[104:107]. A root constant-buffer load (which must write the registers), a load starting above s105, and a destination past s107 are still refused. Note: later code must not read vcc before redefining it. Compilers do not do this after a descriptor load. Verification: (run locally in the worktree on Linux; the Win2025 run is not done) - `python3 -B tests/startup_gfx2hlsl_sload_s104_check.py` -> ok (fails on main with `s_load destination s[104:107] for 4 dwords`) - `python3 -B tests/startup_gfx2hlsl_{smem_offset,op_refusals,readfirstlane_uniform,operand_count,capture}_check.py` -> all exit 0 - Test registered in CMakeLists.txt as `startup_gfx2hlsl_sload_s104`. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 01:01:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:52:12Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de88ff3a01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049332786 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#pullrequestreview-6049332786). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:52:12Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `de88ff3a01` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot commented 2026-11-25 01:01:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:45:11Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T23:52:14.739675Z de88ff3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147754960 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#issuecomment-7147754960). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:45:11Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"de88ff3a01f1418ad7e488d6b930e2854c009212","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T23:52:14.739675Z">2026-11-24T23:52:14.739675Z</relative-time> | `de88ff3` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-25 01:02:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:52:12Z.

Code review location: tools/startup/gfx2hlsl.py; line 974

@@ -968,8 +968,10 @@ def op_s_load_dwordx4(self, ops, mods, count=4):
         if len(ops) != 3:
             raise Unsupported('s_load with %d operands' % len(ops))
         dst, base = reg_range(ops[0]), reg_range(ops[1])
-        if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[2] > 105:
+        if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[1] > 105 or dst[2] > 107:
             raise Unsupported('s_load destination %s for %d dwords' % (ops[0], count))
+        # s106/s107 are vcc: only a descriptor load, which emits no code, may end there (s[104:107]).
+        into_vcc = dst[2] > 105

P2 Badge Guard VCC reads after symbolic loads into s106/s107

When a newly accepted high-SGPR load is followed by a VCC read before redefinition, the read still uses the old runtime mask. For example, s_load_dwordx4 s[104:107], s[8:9], 0, followed by s_waitcnt lgkmcnt(0) and v_cndmask_b32_e32 v0, 0, 1, now translates successfully to a select against the unchanged vcc. Recording descriptor symbols in sym[106] and sym[107] does not protect these reads: u('vcc_lo'), implicit cndmask operands, and VCC branches bypass S()'s numeric-descriptor refusal. Mark VCC unavailable after an overlapping symbolic load and reject reads until it is redefined, rather than silently translating an unmodelled value.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688212708 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#discussion_r4688212708). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:52:12Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 974 ~~~~diff @@ -968,8 +968,10 @@ def op_s_load_dwordx4(self, ops, mods, count=4): if len(ops) != 3: raise Unsupported('s_load with %d operands' % len(ops)) dst, base = reg_range(ops[0]), reg_range(ops[1]) - if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[2] > 105: + if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[1] > 105 or dst[2] > 107: raise Unsupported('s_load destination %s for %d dwords' % (ops[0], count)) + # s106/s107 are vcc: only a descriptor load, which emits no code, may end there (s[104:107]). + into_vcc = dst[2] > 105 ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Guard VCC reads after symbolic loads into s106/s107** When a newly accepted high-SGPR load is followed by a VCC read before redefinition, the read still uses the old runtime mask. For example, `s_load_dwordx4 s[104:107], s[8:9], 0`, followed by `s_waitcnt lgkmcnt(0)` and `v_cndmask_b32_e32 v0, 0, 1`, now translates successfully to a select against the unchanged `vcc`. Recording descriptor symbols in `sym[106]` and `sym[107]` does not protect these reads: `u('vcc_lo')`, implicit cndmask operands, and VCC branches bypass `S()`'s numeric-descriptor refusal. Mark VCC unavailable after an overlapping symbolic load and reject reads until it is redefined, rather than silently translating an unmodelled value. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 02:01:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:28:28Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050167684 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#pullrequestreview-6050167684). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:28:28Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 02:02:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:13:47Z.


Fixed and pushed in e0e712d5 (VCC guard added, tests pass).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149335895 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#issuecomment-7149335895). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:13:47Z. --- Fixed and pushed in e0e712d5 (VCC guard added, tests pass).
tedin7 commented 2026-11-25 02:02:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:28:28Z.

Code review location: tools/startup/gfx2hlsl.py; line 974

@@ -968,8 +968,10 @@ def op_s_load_dwordx4(self, ops, mods, count=4):
         if len(ops) != 3:
             raise Unsupported('s_load with %d operands' % len(ops))
         dst, base = reg_range(ops[0]), reg_range(ops[1])
-        if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[2] > 105:
+        if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[1] > 105 or dst[2] > 107:
             raise Unsupported('s_load destination %s for %d dwords' % (ops[0], count))
+        # s106/s107 are vcc: only a descriptor load, which emits no code, may end there (s[104:107]).
+        into_vcc = dst[2] > 105

Fixed in e0e712d5. After a descriptor load into s106/s107, vcc is marked unavailable. Any read (vcc/vcc_lo operands, implicit cndmask mask, s_cbranch_vcc*) is refused until vcc is written again. Covered in tests/startup_gfx2hlsl_sload_s104_check.py. Verification (Linux): python3 tests/startup_gfx2hlsl_sload_s104_check.py -> ok. Windows/WARP not run for this change.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688947404 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#discussion_r4688947404). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:28:28Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 974 ~~~~diff @@ -968,8 +968,10 @@ def op_s_load_dwordx4(self, ops, mods, count=4): if len(ops) != 3: raise Unsupported('s_load with %d operands' % len(ops)) dst, base = reg_range(ops[0]), reg_range(ops[1]) - if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[2] > 105: + if not dst or dst[0] != 's' or dst[2] - dst[1] + 1 != count or dst[1] > 105 or dst[2] > 107: raise Unsupported('s_load destination %s for %d dwords' % (ops[0], count)) + # s106/s107 are vcc: only a descriptor load, which emits no code, may end there (s[104:107]). + into_vcc = dst[2] > 105 ~~~~ --- Fixed in e0e712d5. After a descriptor load into s106/s107, vcc is marked unavailable. Any read (vcc/vcc_lo operands, implicit cndmask mask, s_cbranch_vcc*) is refused until vcc is written again. Covered in tests/startup_gfx2hlsl_sload_s104_check.py. Verification (Linux): `python3 tests/startup_gfx2hlsl_sload_s104_check.py` -> ok. Windows/WARP not run for this change. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 07:00:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:13:54Z.

Review: COMMENTED


I verified the straight-line VCC guard and reproduced two branch cases that still need checks on this head. s_load_dwordx4 s[104:107], s[4:5], 0x20; s_cbranch_scc0 can skip the only VCC redefinition and reach an implicit v_cndmask_b32 read. Also, a branch can skip the descriptor load itself, while a later buffer load still uses the descriptor recorded in translation order. A VCC redefinition before a high-SGPR descriptor use can likewise clobber the recorded descriptor.

I prepared a local candidate against 8150d800 that checks these reads along the stage’s branch edges and preserves a matching descriptor on every path. The focused check passes the branch-bypass refusals, accepts the dominated reads, and refuses reuse after a VCC write. All 46 local startup_gfx2hlsl_*_check.py scripts passed. A separate replay on the local diagnostic translator with Windows SDK 10.0.26100.0 FXC newly produced a manifest and both shader binaries for one captured request; four others advanced to a separate unsupported instruction. This verifies translation only.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052698252 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#pullrequestreview-6052698252). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T06:13:54Z. **Review:** COMMENTED --- I verified the straight-line VCC guard and reproduced two branch cases that still need checks on this head. `s_load_dwordx4 s[104:107], s[4:5], 0x20; s_cbranch_scc0` can skip the only VCC redefinition and reach an implicit `v_cndmask_b32` read. Also, a branch can skip the descriptor load itself, while a later buffer load still uses the descriptor recorded in translation order. A VCC redefinition before a high-SGPR descriptor use can likewise clobber the recorded descriptor. I prepared a local candidate against `8150d800` that checks these reads along the stage’s branch edges and preserves a matching descriptor on every path. The focused check passes the branch-bypass refusals, accepts the dominated reads, and refuses reuse after a VCC write. All 46 local `startup_gfx2hlsl_*_check.py` scripts passed. A separate replay on the local diagnostic translator with Windows SDK `10.0.26100.0` FXC newly produced a manifest and both shader binaries for one captured request; four others advanced to a separate unsupported instruction. This verifies translation only.
R0Y00 commented 2026-11-25 07:01:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:55:37Z.


I fast-forwarded the original branch to 0d2e34f8, preserving your commits. The added control-flow check rejects a VCC read when an incoming path skipped the redefinition, and rejects a descriptor use when the matching symbolic load did not reach it. The focused high-SGPR, SMEM-offset, refusal, readfirstlane and scalar-arity controls passed on the updated head. The PR can now run its usual checks.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7155302977 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#issuecomment-7155302977). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T06:55:37Z. --- I fast-forwarded the original branch to `0d2e34f8`, preserving your commits. The added control-flow check rejects a VCC read when an incoming path skipped the redefinition, and rejects a descriptor use when the matching symbolic load did not reach it. The focused high-SGPR, SMEM-offset, refusal, readfirstlane and scalar-arity controls passed on the updated head. The PR can now run its usual checks.
tedin7 commented 2026-11-25 13:00:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:05:40Z.


Thanks for the fast-forward to 0d2e34f8. I checked the current head 76d0f6c1, which contains it plus a merge of main.

The branch cases from your review are covered on this head, so I made no code change:

  • A VCC read after a branch that skips the only redefinition is refused.
  • A descriptor use after a branch that skips the s_load is refused.
  • A VCC write between the load and the descriptor use is refused.
  • The dominated reads are still accepted.

These are in tests/startup_gfx2hlsl_sload_s104_check.py, and the gfx1013 fixtures, Linux Python checks and Windows build and test jobs all pass on this head.

Commands run locally on 76d0f6c1:

  • python3 tests/startup_gfx2hlsl_sload_s104_check.py → ok
  • every tests/startup_gfx2hlsl_*_check.py (52 scripts) → all passed

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7161910788 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#issuecomment-7161910788). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:05:40Z. --- Thanks for the fast-forward to `0d2e34f8`. I checked the current head `76d0f6c1`, which contains it plus a merge of main. The branch cases from your review are covered on this head, so I made no code change: - A VCC read after a branch that skips the only redefinition is refused. - A descriptor use after a branch that skips the `s_load` is refused. - A VCC write between the load and the descriptor use is refused. - The dominated reads are still accepted. These are in `tests/startup_gfx2hlsl_sload_s104_check.py`, and the gfx1013 fixtures, Linux Python checks and Windows build and test jobs all pass on this head. Commands run locally on `76d0f6c1`: - `python3 tests/startup_gfx2hlsl_sload_s104_check.py` → ok - every `tests/startup_gfx2hlsl_*_check.py` (52 scripts) → all passed AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 14:04:33 +00:00
tedin7 commented 2026-11-25 14:05:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:50:51Z.


Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.

We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7164376602 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#issuecomment-7164376602). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:50:51Z. --- Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is. We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here. AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-25 23:02:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T22:56:24Z.


Post-merge audit of e0da6b39: five mutations of the VCC/descriptor path walk, three caught — and the biggest survivor is caused by an or in the fixture's own assertion

python -B tests/startup_gfx2hlsl_sload_s104_check.py
    ok

The change lets s_load write s[104:107], which overlaps VCC, so translation now has to prove two things along every path
(check_vcc_paths, gfx2hlsl.py:1885): a descriptor load reaches its use on all paths, and VCC is numeric at a mask
read. The walk is a small worklist over blocks with a state taken from the last load_descriptor and cleared by
write_vcc.

mutation caught
the VCC read refusal removed (read_vcc while a descriptor is live) caught
write_vcc stops clearing the state caught
jump edges no longer followed caught
the multi-path descriptor check forced true (if state is None or any(…) → if False) survived
sequential fallthrough edges no longer added survived

Survivor 1, and why it is the fixture's fault rather than the code's

The fixture does build the "load bypassed on one path" case:

try:
    translate('s_cbranch_scc0 label_000C', load, 's_nop 0', fetch, 's_endpgm')
except G.Unsupported as error:
    assert ('without a matching load on every path' in str(error)
            or 'joined at a branch target' in str(error)), error

That or is the problem. With the multi-path check disabled, a different guard (joined at a branch target) still
raises, the assertion still passes, and the case cannot tell the two apart. The regression I injected — "a descriptor read
on a path that never loaded it is accepted" — is exactly the bug this PR exists to prevent, and the assertion would stay
green.

Splitting it into two cases would close it: one whose CFG has no join (so only check_vcc_paths can refuse), and one that
genuinely joins (so the join guard is the one under test). Asserting the message exactly rather than with or is the
cheap version.

Survivor 2: every branch in the fixture has both edges leading somewhere that already decides

s_cbranch_scc0 produces a taken edge and a fallthrough edge. In the fixture's cases the taken edge reaches a state that
resolves the question, so removing the fallthrough edge changes no verdict. That means the (not term or term[0] == 'branch') conjunct — the one that makes straight-line code work at all — has no case where it is the deciding edge.

A load in one block with the reader reachable only by falling into the next block would pin it, and that is the most
common real shape: a straight-line prologue that loads, followed by the code that uses the word, with no branch at all.

What the three catches do cover

The VCC side is well covered: a mask read after a descriptor load is refused, a write_vcc re-enables the read, and
jump edges are followed. Those three are the semantics a title would hit, and each has a case that fails when broken.

AI-assisted; pure Python, Windows 11 build 26300, no DXC or GPU for the rows above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7176961448 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2057#issuecomment-7176961448). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T22:56:24Z. --- ## Post-merge audit of `e0da6b39`: five mutations of the VCC/descriptor path walk, three caught — and the biggest survivor is caused by an `or` in the fixture's own assertion ```text python -B tests/startup_gfx2hlsl_sload_s104_check.py ok ``` The change lets `s_load` write `s[104:107]`, which overlaps VCC, so translation now has to prove two things along every path (`check_vcc_paths`, `gfx2hlsl.py:1885`): a descriptor load reaches its use on **all** paths, and VCC is numeric at a mask read. The walk is a small worklist over blocks with a `state` taken from the last `load_descriptor` and cleared by `write_vcc`. | mutation | caught | |---|---| | the VCC read refusal removed (`read_vcc` while a descriptor is live) | **caught** | | `write_vcc` stops clearing the state | **caught** | | jump edges no longer followed | **caught** | | the multi-path descriptor check forced true (`if state is None or any(…)` → `if False`) | survived | | sequential fallthrough edges no longer added | survived | ### Survivor 1, and why it is the fixture's fault rather than the code's The fixture *does* build the "load bypassed on one path" case: ```python try: translate('s_cbranch_scc0 label_000C', load, 's_nop 0', fetch, 's_endpgm') except G.Unsupported as error: assert ('without a matching load on every path' in str(error) or 'joined at a branch target' in str(error)), error ``` That `or` is the problem. With the multi-path check disabled, a **different** guard (`joined at a branch target`) still raises, the assertion still passes, and the case cannot tell the two apart. The regression I injected — "a descriptor read on a path that never loaded it is accepted" — is exactly the bug this PR exists to prevent, and the assertion would stay green. Splitting it into two cases would close it: one whose CFG has no join (so only `check_vcc_paths` can refuse), and one that genuinely joins (so the join guard is the one under test). Asserting the message **exactly** rather than with `or` is the cheap version. ### Survivor 2: every branch in the fixture has both edges leading somewhere that already decides `s_cbranch_scc0` produces a taken edge and a fallthrough edge. In the fixture's cases the taken edge reaches a state that resolves the question, so removing the fallthrough edge changes no verdict. That means the `(not term or term[0] == 'branch')` conjunct — the one that makes straight-line code work at all — has no case where it is the deciding edge. A load in one block with the reader reachable **only** by falling into the next block would pin it, and that is the most common real shape: a straight-line prologue that loads, followed by the code that uses the word, with no branch at all. ### What the three catches do cover The VCC side is well covered: a mask read after a descriptor load is refused, a `write_vcc` re-enables the read, and jump edges are followed. Those three are the semantics a title would hit, and each has a case that fails when broken. AI-assisted; pure Python, Windows 11 build 26300, no DXC or GPU for the rows above.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2050
No description provided.