compute: accept a scratch-base register write that nothing can observe #1648

Merged
triggered02 merged 3 commits from upstream-pr/1655 into main 2026-11-24 16:49:29 +00:00
triggered02 commented 2026-11-24 16:22:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T16:22:10Z.


Fixes #1648, per the scope you set: the exact whole-register immediate write is handled when the accepted program cannot observe scratch state, direct reads and scratch-dependent memory stay refused, the untouched UAV guards are compared as well as the output, and the offline acceptance count is reported separately (as not measured — see the end).

Change

s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO|HI), <imm> now lowers to nothing. Nothing the compute lowering accepts can read either half — a read through s_getreg_b32 and every scratch_*/flat_* memory form are themselves unmodelled and refused — so the write has no observable consumer. Its value is not tracked, which is why only this exact whole-register immediate form is accepted; every other s_setreg_imm32_b32 form stays refused.

Tests

  • draw-scratch-base-write: lowers the indexed kernel with the write in front, requires the generated HLSL to be byte-identical to the untouched kernel, then runs the same WARP readback as the original case — so all 320 words and the untouched guard words are compared, and a wrong stored or guard word still fails.
  • Refusal pins in controls(): a read of either half, a scratch memory form, a write to any other hardware register, and a write-only kernel with a mismatched binding.
release: compute_store_aot_warp Passed 5.76 s   compute_store_aot_scratch_base_warp Passed 2.68 s
dev:     compute_store_aot_warp Passed 6.99 s   compute_store_aot_scratch_base_warp Passed 2.98 s
readback: groups=3 compared_words=320 mismatches=0

Fail-first: with the write's acceptance removed, the fixture raises

ValueError: Unsupported compute instruction: s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0

and the new test exits 1.

What this does not establish

  • LLVM is not installed on this machine, so the issue's CLI .dxbc reproduction was not run, and the acceptance-count rescan (389 of 2,689 records) is not measured here — reporting it separately as you asked, and reporting it as unmeasured rather than estimating from the unit fixture.
  • Scratch state remains unmodelled: the write's value is not tracked. If a later accepted instruction can observe the base, this decision has to be revisited rather than extended.
  • No other profile, CPU or GPU is exercised.

One design note: my first version also pre-scanned the program for consumers of the base. That guard was unreachable — every consumer form is refused before it can observe anything — and no test could make it fire, so I removed it rather than ship a branch that looks protective but never runs. The comment and the docs say why the write is safe instead.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6586396007 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T16:22:10Z. --- Fixes #1648, per the scope you set: the exact whole-register immediate write is handled when the accepted program cannot observe scratch state, direct reads and scratch-dependent memory stay refused, the untouched UAV guards are compared as well as the output, and the offline acceptance count is reported separately (as *not measured* — see the end). ## Change `s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO|HI), <imm>` now lowers to nothing. Nothing the compute lowering accepts can read either half — a read through `s_getreg_b32` and every `scratch_*`/`flat_*` memory form are themselves unmodelled and refused — so the write has no observable consumer. Its value is not tracked, which is why only this exact whole-register immediate form is accepted; every other `s_setreg_imm32_b32` form stays refused. ## Tests - **`draw-scratch-base-write`**: lowers the indexed kernel with the write in front, requires the generated HLSL to be **byte-identical** to the untouched kernel, then runs the same WARP readback as the original case — so all 320 words and the untouched guard words are compared, and a wrong stored or guard word still fails. - **Refusal pins in `controls()`**: a read of either half, a scratch memory form, a write to any other hardware register, and a write-only kernel with a mismatched binding. ``` release: compute_store_aot_warp Passed 5.76 s compute_store_aot_scratch_base_warp Passed 2.68 s dev: compute_store_aot_warp Passed 6.99 s compute_store_aot_scratch_base_warp Passed 2.98 s readback: groups=3 compared_words=320 mismatches=0 ``` Fail-first: with the write's acceptance removed, the fixture raises ``` ValueError: Unsupported compute instruction: s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0 ``` and the new test exits 1. ## What this does not establish - **LLVM is not installed on this machine**, so the issue's CLI `.dxbc` reproduction was not run, and the **acceptance-count rescan (389 of 2,689 records) is not measured here** — reporting it separately as you asked, and reporting it as unmeasured rather than estimating from the unit fixture. - Scratch state remains unmodelled: the write's value is not tracked. If a later accepted instruction can observe the base, this decision has to be revisited rather than extended. - No other profile, CPU or GPU is exercised. One design note: my first version also pre-scanned the program for consumers of the base. That guard was unreachable — every consumer form is refused before it can observe anything — and no test could make it fire, so I removed it rather than ship a branch that looks protective but never runs. The comment and the docs say why the write is safe instead. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 17:01:51 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 17:01:52 +00:00 (Migrated from github.com)

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

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c259252e11

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

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:32:25Z.

Review: COMMENTED


Peer review on c259252e:

Findings

No P1 or P2 defects found.

  • tools/compute_store_aot.py accepts only the whole-register immediate s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_(?:LO|HI)), ... form, after ds_wait (s_waitcnt lgkmcnt(0)) and outside lane-guard restore blocks. No s_getreg_b32, scratch_*, or flat_* consumer is accepted by the compute lowering, so the write has no observable consumer.
  • Title-neutrality: clean.

Nits:

  • tests/compute_store_check.py: binary mode (Linux) only runs the negative must_reject checks in controls() and does not exercise positive lowering of SCRATCH_BASE_WRITE_LINES (which runs in draw_scratch_base_write on Windows). Also, HW_REG_FLAT_SCR_HI only appears in a must_reject case (stride=8), so positive HW_REG_FLAT_SCR_HI lowering is not directly covered.
  • tests/compute_store_check.py: stray " at the end of the first line of draw_scratch_base_write's docstring.

Verification

  • Linux:
    • python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1 — PASS (exit 0).
  • Win2025 (OS build 26100, MSVC 14.44.35207, WARP; *_hardware excluded):
    • Debug (--preset dev): cmake --build --preset dev --target offscreen_check -- -j 6 (30.14s), ctest --preset dev -R '^(...|compute_store_aot_scratch_base_warp|...)$' --parallel 4 --no-tests=error --output-on-failure — 55/55 passed (77.57s; compute_store_aot_scratch_base_warp 4.17s).
    • Release /O2 (--preset release): cmake --build --preset release --target offscreen_check -- -j 6 (51.82s), ctest --preset release -R '^(...|compute_store_aot_scratch_base_warp|...)$' --parallel 4 --no-tests=error --output-on-failure — 55/55 passed (77.33s; compute_store_aot_scratch_base_warp 4.31s).
  • Local mutation check:
    • Temporarily narrowed HW_REG_FLAT_SCR_(?:LO|HI) to HW_REG_FLAT_SCR_HI in tools/compute_store_aot.py; draw_scratch_base_write failed as expected (ValueError: Unsupported compute instruction: s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0, exit 1). Restored cleanly (git status --short clean).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043317275 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655#pullrequestreview-6043317275). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:32:25Z. **Review:** COMMENTED --- Peer review on `c259252e`: ### Findings No P1 or P2 defects found. - `tools/compute_store_aot.py` accepts only the whole-register immediate `s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_(?:LO|HI)), ...` form, after `ds_wait` (`s_waitcnt lgkmcnt(0)`) and outside lane-guard restore blocks. No `s_getreg_b32`, `scratch_*`, or `flat_*` consumer is accepted by the compute lowering, so the write has no observable consumer. - Title-neutrality: clean. **Nits:** - `tests/compute_store_check.py`: `binary` mode (Linux) only runs the negative `must_reject` checks in `controls()` and does not exercise positive lowering of `SCRATCH_BASE_WRITE_LINES` (which runs in `draw_scratch_base_write` on Windows). Also, `HW_REG_FLAT_SCR_HI` only appears in a `must_reject` case (`stride=8`), so positive `HW_REG_FLAT_SCR_HI` lowering is not directly covered. - `tests/compute_store_check.py`: stray `"` at the end of the first line of `draw_scratch_base_write`'s docstring. ### Verification - **Linux**: - `python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1` — **PASS** (exit 0). - **Win2025 (OS build 26100, MSVC 14.44.35207, WARP; `*_hardware` excluded)**: - **Debug (`--preset dev`)**: `cmake --build --preset dev --target offscreen_check -- -j 6` (`30.14s`), `ctest --preset dev -R '^(...|compute_store_aot_scratch_base_warp|...)$' --parallel 4 --no-tests=error --output-on-failure` — **55/55 passed** (`77.57s`; `compute_store_aot_scratch_base_warp` `4.17s`). - **Release `/O2` (`--preset release`)**: `cmake --build --preset release --target offscreen_check -- -j 6` (`51.82s`), `ctest --preset release -R '^(...|compute_store_aot_scratch_base_warp|...)$' --parallel 4 --no-tests=error --output-on-failure` — **55/55 passed** (`77.33s`; `compute_store_aot_scratch_base_warp` `4.31s`). - **Local mutation check**: - Temporarily narrowed `HW_REG_FLAT_SCR_(?:LO|HI)` to `HW_REG_FLAT_SCR_HI` in `tools/compute_store_aot.py`; `draw_scratch_base_write` failed as expected (`ValueError: Unsupported compute instruction: s_setreg_imm32_b32 hwreg(HW_REG_FLAT_SCR_LO), 0`, exit 1). Restored cleanly (`git status --short` clean). AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-24 17:01:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:49:04Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043574773 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655#pullrequestreview-6043574773). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:49:04Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-24 17:02:07 +00:00 (Migrated from github.com)

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


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-24T16:25:27.301197Z c259252 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:7137559632 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655#issuecomment-7137559632). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T16:22:21Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"c259252e11320c9a5500f061420e74e03373f471","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-24T16:25:27.301197Z">2026-11-24T16:25:27.301197Z</relative-time> | `c259252` | 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>
triggered02 commented 2026-11-24 17:02:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T16:32:44Z.


Correct, and the integer-only literal check was wrong for exactly that reason: LLVM spells an imm32 whose bit pattern looks like a float as an inline float, and that is the string the disassembler hands to lower(). 0x3f800000 arrives as 1.0, 0x3e23f983 as 0.15915494. Fixed in 30ef44f3.

The hwreg match stays strict (only HW_REG_FLAT_SCR_LO / _HI, whole register); only the literal became LLVM's spelling of an imm32 — decimal, hex, inline float with optional sign and exponent, or the non-finite names. Anything else is refused with Unsupported scratch-base immediate spelling, and hwreg(4) (a raw register id) or a register operand stay refused as unsupported instructions, both pinned in controls().

The fixture now lowers and reads back three spellings — 0, 1.0, 0.15915494 — and the mode asserts each produces HLSL byte-identical to the untouched kernel before the WARP readback:

release: compute_store_aot_warp Passed 6.83 s, compute_store_aot_scratch_base_warp Passed 3.45 s
dev:     compute_store_aot_warp Passed 7.03 s, compute_store_aot_scratch_base_warp Passed 3.43 s
readback: groups=3 compared_words=320 mismatches=0

Fail-first for the float path specifically: restoring the integer-only check fails the mode with ValueError: Unsupported scratch-base immediate spelling: 1.0.

Thanks — this one would have stayed latent until a real title record used a float-looking immediate, since every fixture I wrote used 0 and 0x400.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137832579 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655#issuecomment-7137832579). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T16:32:44Z. --- Correct, and the integer-only literal check was wrong for exactly that reason: LLVM spells an imm32 whose bit pattern looks like a float as an inline float, and that is the string the disassembler hands to `lower()`. `0x3f800000` arrives as `1.0`, `0x3e23f983` as `0.15915494`. Fixed in `30ef44f3`. The hwreg match stays strict (only `HW_REG_FLAT_SCR_LO` / `_HI`, whole register); only the literal became LLVM's spelling of an imm32 — decimal, hex, inline float with optional sign and exponent, or the non-finite names. Anything else is refused with `Unsupported scratch-base immediate spelling`, and `hwreg(4)` (a raw register id) or a register operand stay refused as unsupported instructions, both pinned in `controls()`. The fixture now lowers and reads back three spellings — `0`, `1.0`, `0.15915494` — and the mode asserts each produces HLSL byte-identical to the untouched kernel before the WARP readback: ``` release: compute_store_aot_warp Passed 6.83 s, compute_store_aot_scratch_base_warp Passed 3.45 s dev: compute_store_aot_warp Passed 7.03 s, compute_store_aot_scratch_base_warp Passed 3.43 s readback: groups=3 compared_words=320 mismatches=0 ``` Fail-first for the float path specifically: restoring the integer-only check fails the mode with `ValueError: Unsupported scratch-base immediate spelling: 1.0`. Thanks — this one would have stayed latent until a real title record used a float-looking immediate, since every fixture I wrote used `0` and `0x400`.
triggered02 commented 2026-11-24 17:02:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T16:34:24Z.


Thanks — no P1/P2 and both nits were fair. Fixed in e6d94835; the review was on c259252e, so it predates the float-spelling fix Codex raised separately.

Positive coverage in every mode. controls() now lowers the integer write and both float-spelled spellings and requires each to equal the untouched kernel:

untouched = aot.lower(INDEXED, 32, **INDEX_BINDING)
for lines in [SCRATCH_BASE_WRITE_LINES] + [[spelling] + INDEXED for spelling in SCRATCH_BASE_WRITE_SPELLINGS]:
    assert aot.lower(lines, 32, **INDEX_BINDING) == untouched, lines[0]

That also covers HW_REG_FLAT_SCR_HI positively (the 0.15915494 spelling writes HI), so it is no longer only a rejection case. controls() runs before mode dispatch, which is what the binary mode exercises first; I verified it by importing the module and calling controls() directly — controls ok, 2 extra spellings positively covered — since I do not have LLVM here to run the full binary mode.

Docstring. The stray " is gone.

dev:     compute_store_aot_warp Passed 7.39 s, compute_store_aot_scratch_base_warp Passed 4.02 s
release: compute_store_aot_warp Passed 7.44 s, compute_store_aot_scratch_base_warp Passed 3.95 s

Your mutation check is the right one for the hwreg split; mine only removed the acceptance entirely, so narrowing LO/HI was not covered locally. Thanks for both.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137876261 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655#issuecomment-7137876261). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T16:34:24Z. --- Thanks — no P1/P2 and both nits were fair. Fixed in `e6d94835`; the review was on `c259252e`, so it predates the float-spelling fix Codex raised separately. **Positive coverage in every mode.** `controls()` now lowers the integer write and both float-spelled spellings and requires each to equal the untouched kernel: ```python untouched = aot.lower(INDEXED, 32, **INDEX_BINDING) for lines in [SCRATCH_BASE_WRITE_LINES] + [[spelling] + INDEXED for spelling in SCRATCH_BASE_WRITE_SPELLINGS]: assert aot.lower(lines, 32, **INDEX_BINDING) == untouched, lines[0] ``` That also covers `HW_REG_FLAT_SCR_HI` positively (the `0.15915494` spelling writes HI), so it is no longer only a rejection case. `controls()` runs before mode dispatch, which is what the binary mode exercises first; I verified it by importing the module and calling `controls()` directly — `controls ok, 2 extra spellings positively covered` — since I do not have LLVM here to run the full binary mode. **Docstring.** The stray `"` is gone. ``` dev: compute_store_aot_warp Passed 7.39 s, compute_store_aot_scratch_base_warp Passed 4.02 s release: compute_store_aot_warp Passed 7.44 s, compute_store_aot_scratch_base_warp Passed 3.95 s ``` Your mutation check is the right one for the hwreg split; mine only removed the acceptance entirely, so narrowing LO/HI was not covered locally. Thanks for both.
chatgpt-codex-connector[bot commented 2026-11-24 17:02:11 +00:00 (Migrated from github.com)

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

Code review location: tools/compute_store_aot.py; line 374

@@ -371,6 +371,12 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N
         if (guard is not None and guard["at_label"]
                 and not re.fullmatch(r"s_waitcnt_depctr 0x[0-9a-f]+|s_nop \d+|s_or_b32 .*", line)):
             raise ValueError("Lane guard branch does not reach its restore")
+        if m := re.fullmatch(r"s_setreg_imm32_b32 hwreg\(HW_REG_FLAT_SCR_(?:LO|HI)\), (-?(?:0x[0-9a-fA-F]+|\d+))", line):

P2 Badge Accept float-spelled scratch-base immediates

When a valid scratch-base immediate has a bit pattern LLVM spells as an inline float, such as 0x3f800000 becoming 1.0 in tests/rdna2_tools_check.py::test_hwreg_operands_use_llvm_spelling, pixel_aot.disassemble() passes that spelling to lower(), but this integer-only regex misses it and lowering falls through to Unsupported compute instruction. Since the immediate is intentionally ignored, accept these float spellings too (or parse them back to their 32-bit values).

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4683124627 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655#discussion_r4683124627). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T16:25:24Z. **Code review location:** `tools/compute_store_aot.py`; line 374 ~~~~diff @@ -371,6 +371,12 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N if (guard is not None and guard["at_label"] and not re.fullmatch(r"s_waitcnt_depctr 0x[0-9a-f]+|s_nop \d+|s_or_b32 .*", line)): raise ValueError("Lane guard branch does not reach its restore") + if m := re.fullmatch(r"s_setreg_imm32_b32 hwreg\(HW_REG_FLAT_SCR_(?:LO|HI)\), (-?(?:0x[0-9a-fA-F]+|\d+))", line): ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Accept float-spelled scratch-base immediates** When a valid scratch-base immediate has a bit pattern LLVM spells as an inline float, such as `0x3f800000` becoming `1.0` in `tests/rdna2_tools_check.py::test_hwreg_operands_use_llvm_spelling`, `pixel_aot.disassemble()` passes that spelling to `lower()`, but this integer-only regex misses it and lowering falls through to `Unsupported compute instruction`. Since the immediate is intentionally ignored, accept these float spellings too (or parse them back to their 32-bit values). Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
R0Y00 commented 2026-11-24 17:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:49:04Z.

Code review location: tools/compute_store_aot.py; line 374

@@ -371,6 +371,12 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N
         if (guard is not None and guard["at_label"]
                 and not re.fullmatch(r"s_waitcnt_depctr 0x[0-9a-f]+|s_nop \d+|s_or_b32 .*", line)):
             raise ValueError("Lane guard branch does not reach its restore")
+        if m := re.fullmatch(r"s_setreg_imm32_b32 hwreg\(HW_REG_FLAT_SCR_(?:LO|HI)\), (-?(?:0x[0-9a-fA-F]+|\d+))", line):

Verified at e6d94835. The lowering accepts LLVM floating spellings, and the source-built low/high cases including 1.0 and 0.15915494 produce identical HLSL. Direct reads, scratch memory and nonliteral operands remain refused. The related Windows Release checks passed on RTX and WARP (4/4).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4683430035 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1655#discussion_r4683430035). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:49:04Z. **Code review location:** `tools/compute_store_aot.py`; line 374 ~~~~diff @@ -371,6 +371,12 @@ def lower(instructions, group, *, table_reg, descriptor_offset=None, group_reg=N if (guard is not None and guard["at_label"] and not re.fullmatch(r"s_waitcnt_depctr 0x[0-9a-f]+|s_nop \d+|s_or_b32 .*", line)): raise ValueError("Lane guard branch does not reach its restore") + if m := re.fullmatch(r"s_setreg_imm32_b32 hwreg\(HW_REG_FLAT_SCR_(?:LO|HI)\), (-?(?:0x[0-9a-fA-F]+|\d+))", line): ~~~~ --- Verified at e6d94835. The lowering accepts LLVM floating spellings, and the source-built low/high cases including 1.0 and 0.15915494 produce identical HLSL. Direct reads, scratch memory and nonliteral operands remain refused. The related Windows Release checks passed on RTX and WARP (4/4).
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!1648
No description provided.