startup: treat wave32 vcc_hi as an ordinary scalar register in gfx2hlsl (Part of #1723) #2695

Merged
tedin7 merged 9 commits from upstream-pr/2703 into main 2026-11-26 06:32:25 +00:00
tedin7 commented 2026-11-26 02:48:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:48:43Z.


Part of #1723

What this unblocks: pixel and vertex programs that use vcc_hi as a compare or carry-out destination, a lane-mask source, or a scalar register now translate (wave32) instead of being refused, while the wave64 reading stays refused.

Builds on #2698, which turned the scalar vcc_hi / exec_hi destination crashes into refusals. Those guards stay as they are; this PR adds the lowering they leave open.

What changed

In wave32 only vcc_lo is the condition mask; vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2 ISA, "VCC"). wave32_vcc_hi renames vcc_hi to an SGPR the program never names (taken from the top of s105 downwards) when that is exact in both wave sizes:

  • no instruction names the 64-bit pair vcc, and
  • a vector compare or carry-out writes vcc_hi or an odd SGPR as its mask (a misaligned pair in wave64, so the program is wave32), or no vector instruction writes vcc_lo (in wave64 that write would also set vcc_hi), and
  • the program has no s_movrel* that could reach the chosen register.

The second commit keeps vcc_hi refused when a possibly-wave64 program reads VCC as a mask. Applied to vs and ps stages only.

What stays refused

Everything not proven wave32 (the pair vcc, a vector write of vcc_lo with no wave32 proof, s_movrel*), exec_hi, and scalar writes into vcc_lo/exec_hi keep the refusals of #2698 (<op> destination vcc_hi).

Tests

tests/startup_gfx2hlsl_vcc_hi_check.py (registered in CMakeLists.txt, noted in docs/startup-runtime.md): translation controls, mutation controls (compare bit not read, carry lost, vcc_hi read as zero), binary mode (fixture words assemble to the recorded words), and a draw mode with a CPU reference for the pixel readback. On origin/main the controls fail (PS translates, SCALAR_ONLY translates); with the change they pass. The refusal expectations match the text #2698 produces.

Verification

  • python3 -B tests/startup_gfx2hlsl_vcc_hi_check.py: PASS (fails on origin/main)
  • python3 -B tests/startup_gfx2hlsl_vcc_hi_check.py binary llvm-mc-19: PASS
  • All tests/startup_gfx2hlsl_*_check.py run with no arguments on this branch and on origin/main: same result per script (export_null_draw and mul24_align_draw need a compiler and renderer and exit 1 on both); the only new script is vcc_hi_check.
  • Win2025 on the exact head 0caf9c9e (default 5-slot pool), python3 x2w_pipe.py win2025 2703 --regex '^startup_gfx2hlsl_vcc_hi': dev 3/3 and release 3/3 passed (startup_gfx2hlsl_vcc_hi_controls, startup_gfx2hlsl_vcc_hi_warp, startup_gfx2hlsl_vcc_hi_hardware). The draw reads back 16 x 16 pixels of a vcc_hi compare, carry and scalar use against the CPU reference; the mutation controls (compare bit dropped, carry lost, vcc_hi read as zero) fail the draw, and the controls keep the wave64 readings refused (a VALU vcc_lo write or mask read with no wave32 proof, the 64-bit vcc pair, exec_hi).
  • An independent check with compiler-built pixel shaders (wave64 ballot high word, 64-bit carry, two live compares) found no wave64 program that now translates with a wrong vcc_hi: the ballot high word stays refused with operand 'vcc_hi'.
  • Commands to paste: cmake --build --preset dev --target offscreen_check then ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_vcc_hi' -V.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6618411183 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T02:48:43Z. --- Part of #1723 What this unblocks: pixel and vertex programs that use `vcc_hi` as a compare or carry-out destination, a lane-mask source, or a scalar register now translate (wave32) instead of being refused, while the wave64 reading stays refused. Builds on #2698, which turned the scalar `vcc_hi` / `exec_hi` destination crashes into refusals. Those guards stay as they are; this PR adds the lowering they leave open. ## What changed In wave32 only `vcc_lo` is the condition mask; `vcc_hi` is a free scalar register that compilers allocate like any other (RDNA 2 ISA, "VCC"). `wave32_vcc_hi` renames `vcc_hi` to an SGPR the program never names (taken from the top of s105 downwards) when that is exact in both wave sizes: - no instruction names the 64-bit pair `vcc`, and - a vector compare or carry-out writes `vcc_hi` or an odd SGPR as its mask (a misaligned pair in wave64, so the program is wave32), or no vector instruction writes `vcc_lo` (in wave64 that write would also set `vcc_hi`), and - the program has no `s_movrel*` that could reach the chosen register. The second commit keeps `vcc_hi` refused when a possibly-wave64 program reads VCC as a mask. Applied to `vs` and `ps` stages only. ## What stays refused Everything not proven wave32 (the pair `vcc`, a vector write of `vcc_lo` with no wave32 proof, `s_movrel*`), `exec_hi`, and scalar writes into `vcc_lo`/`exec_hi` keep the refusals of #2698 (`<op> destination vcc_hi`). ## Tests `tests/startup_gfx2hlsl_vcc_hi_check.py` (registered in `CMakeLists.txt`, noted in `docs/startup-runtime.md`): translation controls, mutation controls (compare bit not read, carry lost, `vcc_hi` read as zero), `binary` mode (fixture words assemble to the recorded words), and a `draw` mode with a CPU reference for the pixel readback. On `origin/main` the controls fail (`PS translates`, `SCALAR_ONLY translates`); with the change they pass. The refusal expectations match the text #2698 produces. ## Verification - `python3 -B tests/startup_gfx2hlsl_vcc_hi_check.py`: PASS (fails on `origin/main`) - `python3 -B tests/startup_gfx2hlsl_vcc_hi_check.py binary llvm-mc-19`: PASS - All `tests/startup_gfx2hlsl_*_check.py` run with no arguments on this branch and on `origin/main`: same result per script (`export_null_draw` and `mul24_align_draw` need a compiler and renderer and exit 1 on both); the only new script is `vcc_hi_check`. - Win2025 on the exact head 0caf9c9e (default 5-slot pool), `python3 x2w_pipe.py win2025 2703 --regex '^startup_gfx2hlsl_vcc_hi'`: dev 3/3 and release 3/3 passed (`startup_gfx2hlsl_vcc_hi_controls`, `startup_gfx2hlsl_vcc_hi_warp`, `startup_gfx2hlsl_vcc_hi_hardware`). The draw reads back 16 x 16 pixels of a `vcc_hi` compare, carry and scalar use against the CPU reference; the mutation controls (compare bit dropped, carry lost, `vcc_hi` read as zero) fail the draw, and the controls keep the wave64 readings refused (a VALU `vcc_lo` write or mask read with no wave32 proof, the 64-bit `vcc` pair, `exec_hi`). - An independent check with compiler-built pixel shaders (wave64 ballot high word, 64-bit carry, two live compares) found no wave64 program that now translates with a wrong `vcc_hi`: the ballot high word stays refused with `operand 'vcc_hi'`. - Commands to paste: `cmake --build --preset dev --target offscreen_check` then `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_vcc_hi' -V`. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 04:04:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:12:00Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0caf9c9e0c

ℹ️ 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:6068046276 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#pullrequestreview-6068046276). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:12:00Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `0caf9c9e0c` <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-26 04:04:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:47:45Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068285092 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#pullrequestreview-6068285092). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:47:45Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 04:04:26 +00:00 (Migrated from github.com)

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

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068285376 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#pullrequestreview-6068285376). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:47:47Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 04:04:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:07:26Z.


Ready for review, @MasterDomino.

Win2025 on head 0caf9c9e (default slots): dev 3/3 and release 3/3 passed (startup_gfx2hlsl_vcc_hi_controls, _warp, _hardware), including the pixel readback of the wave32 vcc_hi path and the wave64 refusal controls. I merged current main into the branch twice (one blank-line conflict next to the wave32_vcc_hi call; no code change). Details are in the PR body.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181415969 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#issuecomment-7181415969). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:07:26Z. --- Ready for review, @MasterDomino. Win2025 on head 0caf9c9e (default slots): dev 3/3 and release 3/3 passed (`startup_gfx2hlsl_vcc_hi_controls`, `_warp`, `_hardware`), including the pixel readback of the wave32 `vcc_hi` path and the wave64 refusal controls. I merged current main into the branch twice (one blank-line conflict next to the `wave32_vcc_hi` call; no code change). Details are in the PR body. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 04:04:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:07:34Z.


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-26T03:12:03.303433Z 0caf9c9 Draft marked ready
ℹ️ 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:7181417750 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#issuecomment-7181417750). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:07:34Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0caf9c9e0c9ea046f8a73d14a255f9390e7296e2","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-26T03:12:03.303433Z">2026-11-26T03:12:03.303433Z</relative-time> | `0caf9c9` | Draft marked ready | <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>
tedin7 commented 2026-11-26 04:04:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:48:50Z.


Independent re-check of the fix pushed after Ready (48f889350: vcc_hi stays refused when a wide operand covers s107, or when a scalar word is read as a lane mask), head 5d283a63e.

  • Counter-shapes (pixel stage): a scalar write to vcc_hi followed by a v_cmp_* that rewrites it and a v_cndmask read keeps the per-lane form and translates; the same with a branch between the scalar write and the compare is refused (conservative); a load into s[106:107] followed by the compare also translates, since the compare writes last.
  • tests/startup_gfx2hlsl_vcc_hi_check.py reports 2 mismatches on the parent of the fix and passes with it.
  • Win2025 (dev + release) was already run on this exact head (3/3); not repeated.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182046070 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#issuecomment-7182046070). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:48:50Z. --- Independent re-check of the fix pushed after Ready (48f889350: vcc_hi stays refused when a wide operand covers s107, or when a scalar word is read as a lane mask), head 5d283a63e. - Counter-shapes (pixel stage): a scalar write to `vcc_hi` followed by a `v_cmp_*` that rewrites it and a `v_cndmask` read keeps the per-lane form and translates; the same with a branch between the scalar write and the compare is refused (conservative); a load into `s[106:107]` followed by the compare also translates, since the compare writes last. - `tests/startup_gfx2hlsl_vcc_hi_check.py` reports 2 mismatches on the parent of the fix and passes with it. - Win2025 (dev + release) was already run on this exact head (3/3); not repeated. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:12:00Z.

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

@@ -946,6 +946,55 @@ def writes_exec(name, ops):
     return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld'))
 
 
+# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2
+# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program
+# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry).
+def wave32_vcc_hi(ins):
+    """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register,
+    else `ins`.
+
+    The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own
+    word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare,
+    a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC
+    (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is
+    exact when
+    - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and
+    - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in
+      wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask.
+    Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused."""
+    if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins):
+        return ins
+    if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins):
+        return ins
+    masks = []  # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST)
+    for _o, _n, name, asm in ins:
+        ops = parse(asm)[1]
+        if name.startswith('v_cmp_') and ops:
+            masks.append(ops[0])
+        elif VOP3B_SDST.match(name) and len(ops) > 1:
+            masks.append(ops[1])
+        if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \
+                and ops[-1] != 'vcc_lo':
+            masks.append(ops[-1])  # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32
+    odd = any((reg_range(tok) or ('', 0, 1))[0] == 's' and reg_range(tok)[1] == reg_range(tok)[2]
+              and reg_range(tok)[1] % 2 for tok in masks)
+    # Without that proof the program may be wave64, where every VALU use of VCC as a lane mask (a write, an
+    # implicit or explicit mask source such as v_cndmask_b32_e32, a carry-in, v_div_fmas) and s_cbranch_vccz/vccnz
+    # see vcc_hi for lanes 32..63: none may be present.
+    vcc_mask_use = any((name.startswith('v_') and re.search(r'\bvcc_lo\b', asm)) or name.startswith('v_div_fmas')
+                       or name in ('s_cbranch_vccz', 's_cbranch_vccnz') for _o, _n, name, asm in ins)
+    if 'vcc_hi' not in masks and not odd and vcc_mask_use:
+        return ins
+    named = set()
+    for *_, asm in ins:
+        for lo, hi, single in re.findall(r'\bs\[(\d+):(\d+)\]|\bs(\d+)\b', asm):
+            named.update(range(int(lo), int(hi) + 1) if lo else (int(single),))
+    free = next((n for n in range(105, 63, -1) if n not in named), None)
+    if free is None:
+        return ins
+    return [(off, n, name, re.sub(r'\bvcc_hi\b', 's%d' % free, asm)) for off, n, name, asm in ins]

P1 Badge Preserve the s107 alias when renaming vcc_hi

With a descriptor load into s[104:107] (already supported by op_s_load_dwordx4), this rewrite moves explicit vcc_hi accesses to another register but leaves the load targeting s107, which aliases vcc_hi. A synthetic bytecode fixture that initializes vcc_hi to 0x1234, performs that load, waits, and then reads vcc_hi now generates v0 = 0x00001234u, although the source reads the fourth loaded word. This newly accepts a previously refused shader with stale-register output. Preserve the range alias too, or refuse overlapping loads before renaming.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703472112 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#discussion_r4703472112). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:12:00Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 995 ~~~~diff @@ -946,6 +946,55 @@ def writes_exec(name, ops): return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld')) +# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2 +# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program +# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry). +def wave32_vcc_hi(ins): + """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register, + else `ins`. + + The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own + word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare, + a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC + (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is + exact when + - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and + - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in + wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask. + Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused.""" + if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins): + return ins + if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins): + return ins + masks = [] # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST) + for _o, _n, name, asm in ins: + ops = parse(asm)[1] + if name.startswith('v_cmp_') and ops: + masks.append(ops[0]) + elif VOP3B_SDST.match(name) and len(ops) > 1: + masks.append(ops[1]) + if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \ + and ops[-1] != 'vcc_lo': + masks.append(ops[-1]) # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32 + odd = any((reg_range(tok) or ('', 0, 1))[0] == 's' and reg_range(tok)[1] == reg_range(tok)[2] + and reg_range(tok)[1] % 2 for tok in masks) + # Without that proof the program may be wave64, where every VALU use of VCC as a lane mask (a write, an + # implicit or explicit mask source such as v_cndmask_b32_e32, a carry-in, v_div_fmas) and s_cbranch_vccz/vccnz + # see vcc_hi for lanes 32..63: none may be present. + vcc_mask_use = any((name.startswith('v_') and re.search(r'\bvcc_lo\b', asm)) or name.startswith('v_div_fmas') + or name in ('s_cbranch_vccz', 's_cbranch_vccnz') for _o, _n, name, asm in ins) + if 'vcc_hi' not in masks and not odd and vcc_mask_use: + return ins + named = set() + for *_, asm in ins: + for lo, hi, single in re.findall(r'\bs\[(\d+):(\d+)\]|\bs(\d+)\b', asm): + named.update(range(int(lo), int(hi) + 1) if lo else (int(single),)) + free = next((n for n in range(105, 63, -1) if n not in named), None) + if free is None: + return ins + return [(off, n, name, re.sub(r'\bvcc_hi\b', 's%d' % free, asm)) for off, n, name, asm in ins] ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Preserve the s107 alias when renaming vcc_hi** With a descriptor load into `s[104:107]` (already supported by `op_s_load_dwordx4`), this rewrite moves explicit `vcc_hi` accesses to another register but leaves the load targeting `s107`, which aliases `vcc_hi`. A synthetic bytecode fixture that initializes `vcc_hi` to `0x1234`, performs that load, waits, and then reads `vcc_hi` now generates `v0 = 0x00001234u`, although the source reads the fourth loaded word. This newly accepts a previously refused shader with stale-register output. Preserve the range alias too, or refuse overlapping loads before renaming. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:12:00Z.

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

@@ -946,6 +946,55 @@ def writes_exec(name, ops):
     return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld'))
 
 
+# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2
+# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program
+# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry).
+def wave32_vcc_hi(ins):
+    """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register,
+    else `ins`.
+
+    The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own
+    word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare,
+    a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC
+    (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is
+    exact when
+    - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and
+    - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in
+      wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask.
+    Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused."""
+    if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins):
+        return ins
+    if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins):
+        return ins
+    masks = []  # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST)
+    for _o, _n, name, asm in ins:
+        ops = parse(asm)[1]
+        if name.startswith('v_cmp_') and ops:
+            masks.append(ops[0])
+        elif VOP3B_SDST.match(name) and len(ops) > 1:
+            masks.append(ops[1])
+        if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \
+                and ops[-1] != 'vcc_lo':
+            masks.append(ops[-1])  # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32

P1 Badge Require a per-lane representation for vcc_hi mask sources

When vcc_hi is scalar-written and then used as an explicit select mask, this establishes wave32 but does not establish that the renamed SGPR contains the current lane's bit. For s_mov_b32 vcc_hi, 0x55555555 followed by v_cndmask_b32_e64 v2, 1.0, 2.0, vcc_hi, the emitted HLSL tests (0x55555555u & 1), so every lane selects 2.0, although odd lanes must select 1.0. This shader was previously refused. Require a tracked per-lane mask or an all-zero/all-one constant, or implement lane-bit extraction for full-word mask sources before allowing this lowering.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703472119 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#discussion_r4703472119). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:12:00Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 978 ~~~~diff @@ -946,6 +946,55 @@ def writes_exec(name, ops): return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld')) +# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2 +# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program +# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry). +def wave32_vcc_hi(ins): + """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register, + else `ins`. + + The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own + word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare, + a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC + (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is + exact when + - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and + - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in + wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask. + Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused.""" + if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins): + return ins + if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins): + return ins + masks = [] # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST) + for _o, _n, name, asm in ins: + ops = parse(asm)[1] + if name.startswith('v_cmp_') and ops: + masks.append(ops[0]) + elif VOP3B_SDST.match(name) and len(ops) > 1: + masks.append(ops[1]) + if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \ + and ops[-1] != 'vcc_lo': + masks.append(ops[-1]) # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32 ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Require a per-lane representation for vcc_hi mask sources** When `vcc_hi` is scalar-written and then used as an explicit select mask, this establishes wave32 but does not establish that the renamed SGPR contains the current lane's bit. For `s_mov_b32 vcc_hi, 0x55555555` followed by `v_cndmask_b32_e64 v2, 1.0, 2.0, vcc_hi`, the emitted HLSL tests `(0x55555555u & 1)`, so every lane selects `2.0`, although odd lanes must select `1.0`. This shader was previously refused. Require a tracked per-lane mask or an all-zero/all-one constant, or implement lane-bit extraction for full-word mask sources before allowing this lowering. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:47:44Z.

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

@@ -946,6 +946,55 @@ def writes_exec(name, ops):
     return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld'))
 
 
+# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2
+# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program
+# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry).
+def wave32_vcc_hi(ins):
+    """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register,
+    else `ins`.
+
+    The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own
+    word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare,
+    a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC
+    (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is
+    exact when
+    - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and
+    - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in
+      wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask.
+    Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused."""
+    if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins):
+        return ins
+    if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins):
+        return ins
+    masks = []  # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST)
+    for _o, _n, name, asm in ins:
+        ops = parse(asm)[1]
+        if name.startswith('v_cmp_') and ops:
+            masks.append(ops[0])
+        elif VOP3B_SDST.match(name) and len(ops) > 1:
+            masks.append(ops[1])
+        if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \
+                and ops[-1] != 'vcc_lo':
+            masks.append(ops[-1])  # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32
+    odd = any((reg_range(tok) or ('', 0, 1))[0] == 's' and reg_range(tok)[1] == reg_range(tok)[2]
+              and reg_range(tok)[1] % 2 for tok in masks)
+    # Without that proof the program may be wave64, where every VALU use of VCC as a lane mask (a write, an
+    # implicit or explicit mask source such as v_cndmask_b32_e32, a carry-in, v_div_fmas) and s_cbranch_vccz/vccnz
+    # see vcc_hi for lanes 32..63: none may be present.
+    vcc_mask_use = any((name.startswith('v_') and re.search(r'\bvcc_lo\b', asm)) or name.startswith('v_div_fmas')
+                       or name in ('s_cbranch_vccz', 's_cbranch_vccnz') for _o, _n, name, asm in ins)
+    if 'vcc_hi' not in masks and not odd and vcc_mask_use:
+        return ins
+    named = set()
+    for *_, asm in ins:
+        for lo, hi, single in re.findall(r'\bs\[(\d+):(\d+)\]|\bs(\d+)\b', asm):
+            named.update(range(int(lo), int(hi) + 1) if lo else (int(single),))
+    free = next((n for n in range(105, 63, -1) if n not in named), None)
+    if free is None:
+        return ins
+    return [(off, n, name, re.sub(r'\bvcc_hi\b', 's%d' % free, asm)) for off, n, name, asm in ins]

Confirmed and fixed in 5d283a63e. A wide operand that covers SGPR 107 (such as s_load_dwordx4 s[104:107]) writes vcc_hi, so there is no free register to rename it to. wave32_vcc_hi now returns the instructions unchanged (vcc_hi stays refused by name) when any register range covers s107.

Test: startup_gfx2hlsl_vcc_hi_check.py, "a load into s[104:107] keeps vcc_hi refused" (fails on the previous head, passes now).

Commands run:

  • python3 tests/startup_gfx2hlsl_vcc_hi_check.py and ... binary llvm-mc-19
  • all tests/startup_gfx2hlsl_* scripts (same exit codes as before)
  • Windows (WARP) on 5d283a63e: ctest --preset dev|release -R startup_gfx2hlsl_vcc_hi 3/3 on both presets

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703668019 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#discussion_r4703668019). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:47:44Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 995 ~~~~diff @@ -946,6 +946,55 @@ def writes_exec(name, ops): return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld')) +# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2 +# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program +# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry). +def wave32_vcc_hi(ins): + """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register, + else `ins`. + + The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own + word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare, + a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC + (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is + exact when + - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and + - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in + wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask. + Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused.""" + if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins): + return ins + if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins): + return ins + masks = [] # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST) + for _o, _n, name, asm in ins: + ops = parse(asm)[1] + if name.startswith('v_cmp_') and ops: + masks.append(ops[0]) + elif VOP3B_SDST.match(name) and len(ops) > 1: + masks.append(ops[1]) + if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \ + and ops[-1] != 'vcc_lo': + masks.append(ops[-1]) # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32 + odd = any((reg_range(tok) or ('', 0, 1))[0] == 's' and reg_range(tok)[1] == reg_range(tok)[2] + and reg_range(tok)[1] % 2 for tok in masks) + # Without that proof the program may be wave64, where every VALU use of VCC as a lane mask (a write, an + # implicit or explicit mask source such as v_cndmask_b32_e32, a carry-in, v_div_fmas) and s_cbranch_vccz/vccnz + # see vcc_hi for lanes 32..63: none may be present. + vcc_mask_use = any((name.startswith('v_') and re.search(r'\bvcc_lo\b', asm)) or name.startswith('v_div_fmas') + or name in ('s_cbranch_vccz', 's_cbranch_vccnz') for _o, _n, name, asm in ins) + if 'vcc_hi' not in masks and not odd and vcc_mask_use: + return ins + named = set() + for *_, asm in ins: + for lo, hi, single in re.findall(r'\bs\[(\d+):(\d+)\]|\bs(\d+)\b', asm): + named.update(range(int(lo), int(hi) + 1) if lo else (int(single),)) + free = next((n for n in range(105, 63, -1) if n not in named), None) + if free is None: + return ins + return [(off, n, name, re.sub(r'\bvcc_hi\b', 's%d' % free, asm)) for off, n, name, asm in ins] ~~~~ --- Confirmed and fixed in `5d283a63e`. A wide operand that covers SGPR 107 (such as `s_load_dwordx4 s[104:107]`) writes vcc_hi, so there is no free register to rename it to. `wave32_vcc_hi` now returns the instructions unchanged (vcc_hi stays refused by name) when any register range covers s107. Test: `startup_gfx2hlsl_vcc_hi_check.py`, "a load into s[104:107] keeps vcc_hi refused" (fails on the previous head, passes now). Commands run: - `python3 tests/startup_gfx2hlsl_vcc_hi_check.py` and `... binary llvm-mc-19` - all `tests/startup_gfx2hlsl_*` scripts (same exit codes as before) - Windows (WARP) on `5d283a63e`: `ctest --preset dev|release -R startup_gfx2hlsl_vcc_hi` 3/3 on both presets AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

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

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

@@ -946,6 +946,55 @@ def writes_exec(name, ops):
     return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld'))
 
 
+# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2
+# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program
+# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry).
+def wave32_vcc_hi(ins):
+    """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register,
+    else `ins`.
+
+    The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own
+    word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare,
+    a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC
+    (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is
+    exact when
+    - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and
+    - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in
+      wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask.
+    Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused."""
+    if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins):
+        return ins
+    if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins):
+        return ins
+    masks = []  # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST)
+    for _o, _n, name, asm in ins:
+        ops = parse(asm)[1]
+        if name.startswith('v_cmp_') and ops:
+            masks.append(ops[0])
+        elif VOP3B_SDST.match(name) and len(ops) > 1:
+            masks.append(ops[1])
+        if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \
+                and ops[-1] != 'vcc_lo':
+            masks.append(ops[-1])  # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32

Confirmed and fixed in 5d283a63e. s_mov_b32 vcc_hi, 0x55555555 then v_cndmask_b32_e64 v2, 1.0, 2.0, vcc_hi produced (0x55555555u & 1) for every lane. A VOP3 lane-mask source that reads vcc_hi after a scalar write (or in a program with branches, where the order is unknown) now keeps vcc_hi refused. A compare or carry-out that wrote vcc_hi last keeps the per-lane form, so the existing draw fixture is unchanged.

Note: an ordinary SGPR used the same way (s_mov_b32 s7, 0x55555555 then the same v_cndmask_b32_e64 ... s7) lowers the same way on main. I left that alone here since it is not part of this change; this PR now just does not extend it to vcc_hi.

Test: new fixture SCALAR_MASK in startup_gfx2hlsl_vcc_hi_check.py (refused with "s_mov_b32 destination vcc_hi"; fails on the previous head).

Commands run: same as the first thread on this PR; Windows dev+release 3/3 on 5d283a63e.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703668250 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#discussion_r4703668250). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:47:47Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 978 ~~~~diff @@ -946,6 +946,55 @@ def writes_exec(name, ops): return 'saveexec' in name or 'wrexec' in name or name.startswith(('v_cmpx', 's_movreld')) +# In wave32 VCC is vcc_lo alone and vcc_hi is a free scalar register that compilers allocate like any other (RDNA 2 +# ISA, "VCC": in wave32 only VCC_LO is the condition mask). The translator models it as an ordinary SGPR the program +# never names, taken from the top of the 106 (beyond the user-data and system registers set at entry). +def wave32_vcc_hi(ins): + """`ins` with every vcc_hi operand renamed to an unused SGPR when vcc_hi is provably an ordinary scalar register, + else `ins`. + + The decoder prints wave32 syntax, so the program text alone does not give the wave size. vcc_hi holds its own + word in both wave sizes as long as only scalar instructions write it; in wave64 a VALU write of VCC (a compare, + a carry-out, v_div_scale, printed as vcc_lo) also writes vcc_hi with the high lanes, and a VALU mask read of VCC + (v_cndmask_b32_e32, a carry-in, v_div_fmas) or s_cbranch_vccz/vccnz reads vcc_hi for them. So the rename is + exact when + - no instruction names the 64-bit pair `vcc` (whose high word would then be vcc_hi), and + - a VALU compare or carry writes vcc_hi or an odd SGPR, or a VOP3 mask source reads one (a misaligned pair in + wave64, so the program is wave32), or no VALU instruction and no vcc branch uses vcc_lo as a lane mask. + Otherwise, or when M0-relative s_movrel* could reach the chosen register, vcc_hi is left alone and refused.""" + if not any(re.search(r'\bvcc_hi\b', asm) for *_, asm in ins): + return ins + if any(re.search(r'\bvcc\b', asm) or name.startswith('s_movrel') for _o, _n, name, asm in ins): + return ins + masks = [] # lane-mask destinations of VALU compares and carry-outs (VOP3b SDST) + for _o, _n, name, asm in ins: + ops = parse(asm)[1] + if name.startswith('v_cmp_') and ops: + masks.append(ops[0]) + elif VOP3B_SDST.match(name) and len(ops) > 1: + masks.append(ops[1]) + if name in ('v_cndmask_b32_e64', 'v_add_co_ci_u32_e64', 'v_sub_co_ci_u32_e64', 'v_subrev_co_ci_u32_e64') \ + and ops[-1] != 'vcc_lo': + masks.append(ops[-1]) # a lane-mask source is a pair in wave64 too: vcc_hi or an odd SGPR proves wave32 ~~~~ --- Confirmed and fixed in `5d283a63e`. `s_mov_b32 vcc_hi, 0x55555555` then `v_cndmask_b32_e64 v2, 1.0, 2.0, vcc_hi` produced `(0x55555555u & 1)` for every lane. A VOP3 lane-mask source that reads vcc_hi after a scalar write (or in a program with branches, where the order is unknown) now keeps vcc_hi refused. A compare or carry-out that wrote vcc_hi last keeps the per-lane form, so the existing draw fixture is unchanged. Note: an ordinary SGPR used the same way (`s_mov_b32 s7, 0x55555555` then the same `v_cndmask_b32_e64 ... s7`) lowers the same way on `main`. I left that alone here since it is not part of this change; this PR now just does not extend it to vcc_hi. Test: new fixture `SCALAR_MASK` in `startup_gfx2hlsl_vcc_hi_check.py` (refused with "s_mov_b32 destination vcc_hi"; fails on the previous head). Commands run: same as the first thread on this PR; Windows dev+release 3/3 on `5d283a63e`. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 07:00:15 +00:00
R0Y00 commented 2026-11-26 07:00:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T06:29:05Z.

Review: APPROVED


Verified the narrow VCC high proof and the original refusals after preserving the existing DPP and wave64-spill registrations. The host controls and the DXC/FXC draw all passed using WARP and RTX 4060 Laptop. Each draw matched 256 pixels and caught wrong compare, carry-out and VCC high mutations.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069507647 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2703#pullrequestreview-6069507647). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T06:29:05Z. **Review:** APPROVED --- Verified the narrow VCC high proof and the original refusals after preserving the existing DPP and wave64-spill registrations. The host controls and the DXC/FXC draw all passed using WARP and RTX 4060 Laptop. Each draw matched 256 pixels and caught wrong compare, carry-out and VCC high mutations.
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!2695
No description provided.