shader: extend v_readfirstlane_b32 lowering to branched control flow in gfx2hlsl (Part of #1723) #2053

Closed
tedin7 wants to merge 4 commits from upstream-pr/2060 into main
tedin7 commented 2026-11-24 23:46:17 +00:00 (Migrated from github.com)

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


Part of #1723

What this unblocks: 719 draw refusals (v_readfirstlane_b32 with branches).

v_readfirstlane_b32 was refused in any shader that has a branch. Now a source is proven uniform inside one basic block, even when the shader has branches elsewhere.

  • The VGPR uniformity set is cleared at every block start (branch targets and the instruction after a terminator), so no proof crosses a join or a loop edge.
  • Proofs are refused in a branched shader if any instruction writes exec (exec/exec_lo/exec_hi, *saveexec*, v_cmpx*), so exec_known holds on every path.
  • Scalar sources that can carry a per-lane value (compare results, anything derived from exec/vcc) are found over the whole program, so a loop cannot bring a late mask write back to an earlier read.
  • Shaders without branches behave as before.

Tests:

  • new tests/startup_readfirstlane_branch_check.py, registered as startup_readfirstlane_branch in CMakeLists.txt. It fails on origin/main and passes here. It also checks that a join between the proof and the read, and an exec write, are still refused.
  • tests/startup_gfx2hlsl_readfirstlane_uniform_check.py: the "branch after read" case moved from refused to accepted, which is the intended change.

Verification: (local Linux run; Win2025 not run, this is a Python-only change)

  • python3 -B tests/startup_readfirstlane_branch_check.py: passes; the same file against the previous gfx2hlsl.py raises v_readfirstlane_b32 requires a proven uniform source.
  • python3 -B tests/startup_gfx2hlsl_*_check.py, tests/startup_uniform_lane_check.py, tests/startup_ngg_slice_check.py: all pass.
  • The remaining tests/startup_*_check.py need Windows probe binaries or arguments and were not run.
  • The 719 count comes from the task brief; I did not re-run the shader scan.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593757446 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:46:17Z. --- Part of #1723 What this unblocks: 719 draw refusals (v_readfirstlane_b32 with branches). `v_readfirstlane_b32` was refused in any shader that has a branch. Now a source is proven uniform inside one basic block, even when the shader has branches elsewhere. - The VGPR uniformity set is cleared at every block start (branch targets and the instruction after a terminator), so no proof crosses a join or a loop edge. - Proofs are refused in a branched shader if any instruction writes exec (`exec`/`exec_lo`/`exec_hi`, `*saveexec*`, `v_cmpx*`), so `exec_known` holds on every path. - Scalar sources that can carry a per-lane value (compare results, anything derived from exec/vcc) are found over the whole program, so a loop cannot bring a late mask write back to an earlier read. - Shaders without branches behave as before. Tests: - new `tests/startup_readfirstlane_branch_check.py`, registered as `startup_readfirstlane_branch` in `CMakeLists.txt`. It fails on `origin/main` and passes here. It also checks that a join between the proof and the read, and an exec write, are still refused. - `tests/startup_gfx2hlsl_readfirstlane_uniform_check.py`: the "branch after read" case moved from refused to accepted, which is the intended change. Verification: (local Linux run; Win2025 not run, this is a Python-only change) - `python3 -B tests/startup_readfirstlane_branch_check.py`: passes; the same file against the previous `gfx2hlsl.py` raises `v_readfirstlane_b32 requires a proven uniform source`. - `python3 -B tests/startup_gfx2hlsl_*_check.py`, `tests/startup_uniform_lane_check.py`, `tests/startup_ngg_slice_check.py`: all pass. - The remaining `tests/startup_*_check.py` need Windows probe binaries or arguments and were not run. - The 719 count comes from the task brief; I did not re-run the shader scan. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 01:01:23 +00:00 (Migrated from github.com)

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

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cf21551f9

ℹ️ 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:6049356277 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#pullrequestreview-6049356277). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:54:19Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `0cf21551f9` <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>
tedin7 commented 2026-11-25 01:01:23 +00:00 (Migrated from github.com)

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

Review: COMMENTED


No description provided.

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

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

Review: COMMENTED


No description provided.

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

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

Review: COMMENTED


No description provided.

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

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

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049940872 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#pullrequestreview-6049940872). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:04Z. **Review:** COMMENTED --- _No description provided._
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:46:27Z.


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:54:22.048998Z 0cf2155 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:7147778986 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#issuecomment-7147778986). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:46:27Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0cf21551f9121202409ebcbd2cf108a607ce1596","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:54:22.048998Z">2026-11-24T23:54:22.048998Z</relative-time> | `0cf2155` | 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:54:19Z.

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')
+        parsed = []
+        proof_ok = True
+        for _, _, name, asm in self.ins:
+            _, ops, _ = parse(asm)
+            parsed.append((name, ops))
+            if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')):

P1 Badge Reject implicit WREXEC writes in the branch safety scan

If a later block executes s_andn2_wrexec_b32 or s_andn2_wrexec_b64 and branches back to an earlier producer/read block, this check still leaves proof_ok=True: these instructions write EXEC implicitly, but their destination is an SGPR and their names match none of these checks. The existing WREXEC handler sets exec_known=False, but only after the earlier block has already been proven and emitted without predication. Consequently, the newly accepted shader can execute that block under a changed mask despite its entry-mask assumptions. Include both supported WREXEC forms in the global EXEC-write check.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688234693 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688234693). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:54:19Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 604 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') + parsed = [] + proof_ok = True + for _, _, name, asm in self.ins: + _, ops, _ = parse(asm) + parsed.append((name, ops)) + if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')): ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Reject implicit WREXEC writes in the branch safety scan** If a later block executes `s_andn2_wrexec_b32` or `s_andn2_wrexec_b64` and branches back to an earlier producer/read block, this check still leaves `proof_ok=True`: these instructions write EXEC implicitly, but their destination is an SGPR and their names match none of these checks. The existing WREXEC handler sets `exec_known=False`, but only after the earlier block has already been proven and emitted without predication. Consequently, the newly accepted shader can execute that block under a changed mask despite its entry-mask assumptions. Include both supported WREXEC forms in the global EXEC-write check. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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:54:19Z.

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')
+        parsed = []
+        proof_ok = True
+        for _, _, name, asm in self.ins:
+            _, ops, _ = parse(asm)
+            parsed.append((name, ops))
+            if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')):
+                proof_ok = False
+        tainted = set()
+        changed = True
+        while changed:
+            changed = False
+            for name, ops in parsed:
+                dst = reg_range(ops[0]) if ops else None
+                if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'):
+                    continue
+                hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:])
+                for tok in ops[1:]:
+                    src = reg_range(tok)
+                    if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)):
+                        hot = True

P1 Badge Track implicit SCC dependencies across backward edges

When a later compare block branches back to an earlier s_cselect_b32 s2, 1, 0 followed by a VGPR copy and first-lane read, the select's implicit SCC dependency is absent from this fixed point. For example, v_cmp_lt_f32 into vcc_lo followed by s_cmp_eq_u32 vcc_lo, 0 makes the emitted HLSL SCC lane-dependent, yet tainted_s remains empty and scc_uniform is still initially true when the earlier block is translated. A synthetic machine-code fixture therefore newly accepts s9 = v7 even though its source varies between invocations at execution time. Include SCC producers and consumers in the whole-program proof, or conservatively refuse these reads.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688234701 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688234701). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:54:19Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 618 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') + parsed = [] + proof_ok = True + for _, _, name, asm in self.ins: + _, ops, _ = parse(asm) + parsed.append((name, ops)) + if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')): + proof_ok = False + tainted = set() + changed = True + while changed: + changed = False + for name, ops in parsed: + dst = reg_range(ops[0]) if ops else None + if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'): + continue + hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:]) + for tok in ops[1:]: + src = reg_range(tok) + if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)): + hot = True ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Track implicit SCC dependencies across backward edges** When a later compare block branches back to an earlier `s_cselect_b32 s2, 1, 0` followed by a VGPR copy and first-lane read, the select's implicit SCC dependency is absent from this fixed point. For example, `v_cmp_lt_f32` into `vcc_lo` followed by `s_cmp_eq_u32 vcc_lo, 0` makes the emitted HLSL SCC lane-dependent, yet `tainted_s` remains empty and `scc_uniform` is still initially true when the earlier block is translated. A synthetic machine-code fixture therefore newly accepts `s9 = v7` even though its source varies between invocations at execution time. Include SCC producers and consumers in the whole-program proof, or conservatively refuse these reads. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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:54:19Z.

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')

P1 Badge Include m0 in the whole-program scalar taint analysis

When a later block copies a lane mask through m0 into an SGPR and then jumps back to an earlier producer/read block, this source list fails to taint the SGPR. reg_range('m0') also returns None, so v_cmp into vcc_lo, followed by s_mov_b32 m0, vcc_lo and s_mov_b32 s2, m0, leaves tainted_s empty. An earlier v_mov_b32 v7, s2 followed by v_readfirstlane_b32 s9, v7 is consequently accepted, although s2 is lane-dependent in the emitted HLSL when that block executes. Treat m0 conservatively as non-uniform, as uniform_source() already does, or track its dependencies globally.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688234715 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688234715). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:54:19Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 598 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Include m0 in the whole-program scalar taint analysis** When a later block copies a lane mask through `m0` into an SGPR and then jumps back to an earlier producer/read block, this source list fails to taint the SGPR. `reg_range('m0')` also returns `None`, so `v_cmp` into `vcc_lo`, followed by `s_mov_b32 m0, vcc_lo` and `s_mov_b32 s2, m0`, leaves `tainted_s` empty. An earlier `v_mov_b32 v7, s2` followed by `v_readfirstlane_b32 s9, v7` is consequently accepted, although `s2` is lane-dependent in the emitted HLSL when that block executes. Treat `m0` conservatively as non-uniform, as `uniform_source()` already does, or track its dependencies globally. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:14 +00:00 (Migrated from github.com)

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

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')
+        parsed = []
+        proof_ok = True
+        for _, _, name, asm in self.ins:
+            _, ops, _ = parse(asm)
+            parsed.append((name, ops))
+            if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')):
+                proof_ok = False
+        tainted = set()
+        changed = True
+        while changed:
+            changed = False
+            for name, ops in parsed:
+                dst = reg_range(ops[0]) if ops else None
+                if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'):
+                    continue
+                hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:])
+                for tok in ops[1:]:
+                    src = reg_range(tok)
+                    if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)):
+                        hot = True
+                if hot and not all(r in tainted for r in range(dst[1], dst[2] + 1)):
+                    tainted.update(range(dst[1], dst[2] + 1))
+                    changed = True
+        return proof_ok, tainted
+
+    def proof_allowed(self):
+        """Uniformity proofs need either no branches or a program the branch scan passed."""
+        return not getattr(self, 'has_branches', True) or getattr(self, 'branch_proof', False)

P1 Badge Update the documented branch restriction for first-lane reads

This change admits shaders containing branches, but docs/experiments.md:11646 still explicitly states that the read requires “a branch-free program”; neither that section nor the README is updated. This leaves the published support boundary incorrect. Update the capability description with the new block-local proof and EXEC restrictions and document the new branch fixture's reproduction command. AGENTS.md explicitly requires a README or experiments update whenever a public capability changes.

AGENTS.md reference: AGENTS.md:L211-L212

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688234726 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688234726). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:54:19Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 626 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') + parsed = [] + proof_ok = True + for _, _, name, asm in self.ins: + _, ops, _ = parse(asm) + parsed.append((name, ops)) + if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')): + proof_ok = False + tainted = set() + changed = True + while changed: + changed = False + for name, ops in parsed: + dst = reg_range(ops[0]) if ops else None + if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'): + continue + hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:]) + for tok in ops[1:]: + src = reg_range(tok) + if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)): + hot = True + if hot and not all(r in tainted for r in range(dst[1], dst[2] + 1)): + tainted.update(range(dst[1], dst[2] + 1)) + changed = True + return proof_ok, tainted + + def proof_allowed(self): + """Uniformity proofs need either no branches or a program the branch scan passed.""" + return not getattr(self, 'has_branches', True) or getattr(self, 'branch_proof', False) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Update the documented branch restriction for first-lane reads** This change admits shaders containing branches, but `docs/experiments.md:11646` still explicitly states that the read requires “a branch-free program”; neither that section nor the README is updated. This leaves the published support boundary incorrect. Update the capability description with the new block-local proof and EXEC restrictions and document the new branch fixture's reproduction command. `AGENTS.md` explicitly requires a README or experiments update whenever a public capability changes. AGENTS.md reference: [AGENTS.md:L211-L212](https://github.com/R0Y00/Xbox2Windows/blob/0cf21551f9121202409ebcbd2cf108a607ce1596/AGENTS.md#L211-L212) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 01:02:20 +00:00 (Migrated from github.com)

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

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')
+        parsed = []
+        proof_ok = True
+        for _, _, name, asm in self.ins:
+            _, ops, _ = parse(asm)
+            parsed.append((name, ops))
+            if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')):

Fixed in 454fd640 (rebased on main; push pending): WREXEC (s_andn2_wrexec_b32/b64) now disables the proof program-wide. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688755307 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688755307). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:00:59Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 604 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') + parsed = [] + proof_ok = True + for _, _, name, asm in self.ins: + _, ops, _ = parse(asm) + parsed.append((name, ops)) + if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')): ~~~~ --- Fixed in 454fd640 (rebased on main; push pending): WREXEC (s_andn2_wrexec_b32/b64) now disables the proof program-wide. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.
tedin7 commented 2026-11-25 01:02:20 +00:00 (Migrated from github.com)

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

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')
+        parsed = []
+        proof_ok = True
+        for _, _, name, asm in self.ins:
+            _, ops, _ = parse(asm)
+            parsed.append((name, ops))
+            if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')):
+                proof_ok = False
+        tainted = set()
+        changed = True
+        while changed:
+            changed = False
+            for name, ops in parsed:
+                dst = reg_range(ops[0]) if ops else None
+                if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'):
+                    continue
+                hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:])
+                for tok in ops[1:]:
+                    src = reg_range(tok)
+                    if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)):
+                        hot = True

Fixed in 454fd640 (rebased on main; push pending): a per-lane SCC (compare fed by vcc/exec/tainted regs) now taints s_cselect/s_cmov/s_addc/s_subb destinations across backward edges. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688755489 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688755489). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:01Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 618 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') + parsed = [] + proof_ok = True + for _, _, name, asm in self.ins: + _, ops, _ = parse(asm) + parsed.append((name, ops)) + if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')): + proof_ok = False + tainted = set() + changed = True + while changed: + changed = False + for name, ops in parsed: + dst = reg_range(ops[0]) if ops else None + if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'): + continue + hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:]) + for tok in ops[1:]: + src = reg_range(tok) + if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)): + hot = True ~~~~ --- Fixed in 454fd640 (rebased on main; push pending): a per-lane SCC (compare fed by vcc/exec/tainted regs) now taints s_cselect/s_cmov/s_addc/s_subb destinations across backward edges. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.
tedin7 commented 2026-11-25 01:02:20 +00:00 (Migrated from github.com)

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

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')

Fixed in 454fd640 (rebased on main; push pending): m0 is now tracked as a tainted scalar in the whole-program scan. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688755700 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688755700). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:03Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 598 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') ~~~~ --- Fixed in 454fd640 (rebased on main; push pending): m0 is now tracked as a tainted scalar in the whole-program scan. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.
tedin7 commented 2026-11-25 01:02:20 +00:00 (Migrated from github.com)

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

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

@@ -584,9 +586,45 @@ def translate(self):
             if term:
                 self.blocks.append((start, self.lines, term))
                 self.lines, start = [], off + n
+                self.uniform_v.clear()
         if self.lines:
             self.blocks.append((start, self.lines, None))
 
+    def scan_branch_safety(self):
+        """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block
+        only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path.
+        tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask),
+        found over the whole program because a loop can bring a later write back to an earlier read."""
+        lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi')
+        parsed = []
+        proof_ok = True
+        for _, _, name, asm in self.ins:
+            _, ops, _ = parse(asm)
+            parsed.append((name, ops))
+            if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')):
+                proof_ok = False
+        tainted = set()
+        changed = True
+        while changed:
+            changed = False
+            for name, ops in parsed:
+                dst = reg_range(ops[0]) if ops else None
+                if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'):
+                    continue
+                hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:])
+                for tok in ops[1:]:
+                    src = reg_range(tok)
+                    if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)):
+                        hot = True
+                if hot and not all(r in tainted for r in range(dst[1], dst[2] + 1)):
+                    tainted.update(range(dst[1], dst[2] + 1))
+                    changed = True
+        return proof_ok, tainted
+
+    def proof_allowed(self):
+        """Uniformity proofs need either no branches or a program the branch scan passed."""
+        return not getattr(self, 'has_branches', True) or getattr(self, 'branch_proof', False)

Fixed in 454fd640 (rebased on main; push pending): docs/experiments.md now describes the block-local proof, the exec restrictions and the new test command. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688755942 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#discussion_r4688755942). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:04Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 626 ~~~~diff @@ -584,9 +586,45 @@ def translate(self): if term: self.blocks.append((start, self.lines, term)) self.lines, start = [], off + n + self.uniform_v.clear() if self.lines: self.blocks.append((start, self.lines, None)) + def scan_branch_safety(self): + """-> (proof_ok, tainted_s) for a program with branches. VGPR uniformity is proven inside one basic block + only (see translate), and only when no instruction anywhere writes exec, so exec_known holds on every path. + tainted_s holds each scalar register that can carry a per-lane value (a compare or exec-derived mask), + found over the whole program because a loop can bring a later write back to an earlier read.""" + lane_names = ('exec', 'exec_lo', 'exec_hi', 'vcc', 'vcc_lo', 'vcc_hi') + parsed = [] + proof_ok = True + for _, _, name, asm in self.ins: + _, ops, _ = parse(asm) + parsed.append((name, ops)) + if ops and (ops[0] in ('exec', 'exec_lo', 'exec_hi') or 'saveexec' in name or name.startswith('v_cmpx')): + proof_ok = False + tainted = set() + changed = True + while changed: + changed = False + for name, ops in parsed: + dst = reg_range(ops[0]) if ops else None + if not dst or dst[0] != 's' or name.startswith('v_readfirstlane'): + continue + hot = name.startswith('v_cmp') or any(op in lane_names for op in ops[1:]) + for tok in ops[1:]: + src = reg_range(tok) + if src and src[0] == 's' and any(r in tainted for r in range(src[1], src[2] + 1)): + hot = True + if hot and not all(r in tainted for r in range(dst[1], dst[2] + 1)): + tainted.update(range(dst[1], dst[2] + 1)) + changed = True + return proof_ok, tainted + + def proof_allowed(self): + """Uniformity proofs need either no branches or a program the branch scan passed.""" + return not getattr(self, 'has_branches', True) or getattr(self, 'branch_proof', False) ~~~~ --- Fixed in 454fd640 (rebased on main; push pending): docs/experiments.md now describes the block-local proof, the exec restrictions and the new test command. Tests extended in tests/startup_readfirstlane_branch_check.py. AI-assisted; commands listed were executed locally: python3 tests/startup_readfirstlane_branch_check.py, startup_gfx2hlsl_readfirstlane_uniform_check.py, startup_gfx2hlsl_mad_check.py.
R0Y00 commented 2026-11-25 04:04:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T03:47:15Z.


Please keep the merged #2183 entry-block proof when updating this PR. Exercise one accepted case per rule, with #2060's taint and CFG checks covering later blocks. Keep both refusal sets, especially entry loops and varying sources after a join.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152241059 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#issuecomment-7152241059). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T03:47:15Z. --- Please keep the merged #2183 entry-block proof when updating this PR. Exercise one accepted case per rule, with #2060's taint and CFG checks covering later blocks. Keep both refusal sets, especially entry loops and varying sources after a join.
R0Y00 commented 2026-11-25 05:04:40 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


At c346072c, the branch proof misses values that vary through control flow. I ran a synthetic Stage input that compares varying v0 into VCC, branches on vccz, sets s7 to 1 on the fallthrough arm and 2 on the target arm, then joins for v_mov_b32 v4, s7; v_readfirstlane_b32 s6, v4. The proof accepts it with no refusals, and the common block actually emits v4 = 0x00000002u; s6 = v4; even on the path that assigned 1. The scan tracks scalar dataflow, but the branch condition never taints the two constant writes, and the scalar constant recorded from the last visited block leaks into the join.

Please retain the entry proof from #2183 and refuse this later-block case until the scalar inputs are proven on all incoming paths or redefined in the block itself. Add the two distinct-arm constants as a negative control, alongside a same-block redefinition positive. #2203 changes the same proof area, so please coordinate the shared controls there before updating both branches.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052006840 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#pullrequestreview-6052006840). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T04:48:28Z. **Review:** CHANGES_REQUESTED --- At `c346072c`, the branch proof misses values that vary through control flow. I ran a synthetic Stage input that compares varying v0 into VCC, branches on vccz, sets s7 to 1 on the fallthrough arm and 2 on the target arm, then joins for `v_mov_b32 v4, s7; v_readfirstlane_b32 s6, v4`. The proof accepts it with no refusals, and the common block actually emits `v4 = 0x00000002u; s6 = v4;` even on the path that assigned 1. The scan tracks scalar dataflow, but the branch condition never taints the two constant writes, and the scalar constant recorded from the last visited block leaks into the join. Please retain the entry proof from #2183 and refuse this later-block case until the scalar inputs are proven on all incoming paths or redefined in the block itself. Add the two distinct-arm constants as a negative control, alongside a same-block redefinition positive. #2203 changes the same proof area, so please coordinate the shared controls there before updating both branches.
tedin7 commented 2026-11-25 05:04:56 +00:00 (Migrated from github.com)

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


Thanks @R0Y00. The branch is rebased and pushed as c346072cb90fae2009386d3e1561e7c5fa911c6f (mergeable).

Covered in this head:

  • The #2183 entry-block proof is kept.
  • The #2060 later-block taint and CFG checks are in place.
  • Each rule has one accepted case in tests/startup_readfirstlane_branch_check.py.
  • Both refusal sets are tested: loops in the entry block, and varying sources after a join.

Verification (Windows Server 2025, MSVC 14.44, D3D12 WARP, default 3-slot pool):

  • python3 x2w_pipe.py win2025 2060 --force --regex 'startup_readfirstlane_branch|startup_uniform_lane|startup_ngg_slice' --py-checks tests/startup_readfirstlane_branch_check.py
  • dev (ctest --preset dev): 3/3 passed
  • release (ctest --preset release): 3/3 passed
  • Python check tests/startup_readfirstlane_branch_check.py: ok

Note: the unfocused run failed because the generated command was too long for the Windows shell, so I ran the focused targets above.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152621729 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#issuecomment-7152621729). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T04:11:59Z. --- Thanks @R0Y00. The branch is rebased and pushed as `c346072cb90fae2009386d3e1561e7c5fa911c6f` (mergeable). Covered in this head: - The #2183 entry-block proof is kept. - The #2060 later-block taint and CFG checks are in place. - Each rule has one accepted case in `tests/startup_readfirstlane_branch_check.py`. - Both refusal sets are tested: loops in the entry block, and varying sources after a join. Verification (Windows Server 2025, MSVC 14.44, D3D12 WARP, default 3-slot pool): - `python3 x2w_pipe.py win2025 2060 --force --regex 'startup_readfirstlane_branch|startup_uniform_lane|startup_ngg_slice' --py-checks tests/startup_readfirstlane_branch_check.py` - dev (`ctest --preset dev`): 3/3 passed - release (`ctest --preset release`): 3/3 passed - Python check `tests/startup_readfirstlane_branch_check.py`: ok Note: the unfocused run failed because the generated command was too long for the Windows shell, so I ran the focused targets above. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 07:00:49 +00:00
tedin7 commented 2026-11-25 07:01:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:18:38Z.


Closing as superseded: the branched v_readfirstlane_b32 entry-block and post-entry-block lowering landed on main via #2183 and #2203.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154658783 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2060#issuecomment-7154658783). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:18:38Z. --- Closing as superseded: the branched `v_readfirstlane_b32` entry-block and post-entry-block lowering landed on `main` via #2183 and #2203.

Pull request closed

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!2053
No description provided.