shader: refuse e32 compares with an SGPR destination in pixel_aot #800

Merged
JB2WIN merged 2 commits from upstream-pr/806 into main 2026-11-23 07:30:49 +00:00
JB2WIN commented 2026-11-23 06:16:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T06:16:09Z.


Change

VOPC e32 writes VCC only. LLVM 15.0.7 on gfx1013 rejects v_cmp_lt_i32_e32 s52, v1, v2, v_cmp_lt_f32_e32 s52, v1, v2 and v_cmp_lt_u16_e32 s52, v1, v2 with "invalid operand for instruction". It assembles the suffix-less v_cmp_lt_f32 s52, v1, v2 as v_cmp_lt_f32_e64. pixel_aot and the scanner still accepted the e32 spelling with an SGPR destination.

With this change, an explicit _e32 with a destination other than vcc/vcc_lo raises VOPC e32 destination must be vcc. This applies to the f32, f16, i32/u32, i16/u16, class_f32 and class_f16 compare branches, through one helper, check_vopc_e32_dst. The scanner marks those spellings unsupported.

These keep their current behaviour:

  • the suffix-less SGPR-destination spelling, which still lowers like _e64, as LLVM assembles it;
  • _e64;
  • e32 with vcc/vcc_lo, including the wave64 vcc spelling.

No existing fixture used the refused form. The 64-bit compares (#803) already apply the same rule and are not touched here. I noticed this gap while working on #803.

AI-assisted (Claude Code).

Verification

Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP, at 186711d.

  • New controls. Each compare family (f32, f16, i32, u32, i16, u16 with lt and eq, plus class_f32 and class_f16) is tested with s52 and s[52:53]:
    • _e32 gives the exact message.
    • The suffix-less spelling lowers to the same HLSL as _e64.
    • _e32 with vcc/vcc_lo is still accepted.
  • Scanner tests. They assert the same split.
  • Dev-time check (not committed). Without the change, both the controls and the scanner test fail.
  • Full ctest --preset dev --no-tests=error -j4. 369 of 370 pass. The one failure is compute_store_aot_hardware, which hits its 45 s timeout on this adapter on plain main as well (#448). Skipped: bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp.
  • Other checks. The controls, the LLVM 15 binary round trip, form_coverage_check.py, rdna2_tools_check.py, pso_readiness_check.py and docs_links_check.py pass.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6553520628 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/806). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T06:16:09Z. --- ## Change VOPC e32 writes VCC only. LLVM 15.0.7 on `gfx1013` rejects `v_cmp_lt_i32_e32 s52, v1, v2`, `v_cmp_lt_f32_e32 s52, v1, v2` and `v_cmp_lt_u16_e32 s52, v1, v2` with "invalid operand for instruction". It assembles the suffix-less `v_cmp_lt_f32 s52, v1, v2` as `v_cmp_lt_f32_e64`. `pixel_aot` and the scanner still accepted the e32 spelling with an SGPR destination. With this change, an explicit `_e32` with a destination other than `vcc`/`vcc_lo` raises `VOPC e32 destination must be vcc`. This applies to the f32, f16, i32/u32, i16/u16, `class_f32` and `class_f16` compare branches, through one helper, `check_vopc_e32_dst`. The scanner marks those spellings unsupported. These keep their current behaviour: - the suffix-less SGPR-destination spelling, which still lowers like `_e64`, as LLVM assembles it; - `_e64`; - e32 with `vcc`/`vcc_lo`, including the wave64 `vcc` spelling. No existing fixture used the refused form. The 64-bit compares (#803) already apply the same rule and are not touched here. I noticed this gap while working on #803. AI-assisted (Claude Code). ## Verification Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP, at `186711d`. - **New controls.** Each compare family (f32, f16, i32, u32, i16, u16 with `lt` and `eq`, plus `class_f32` and `class_f16`) is tested with `s52` and `s[52:53]`: - `_e32` gives the exact message. - The suffix-less spelling lowers to the same HLSL as `_e64`. - `_e32` with `vcc`/`vcc_lo` is still accepted. - **Scanner tests.** They assert the same split. - **Dev-time check (not committed).** Without the change, both the controls and the scanner test fail. - **Full `ctest --preset dev --no-tests=error -j4`.** 369 of 370 pass. The one failure is `compute_store_aot_hardware`, which hits its 45 s timeout on this adapter on plain `main` as well (#448). Skipped: `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp`. - **Other checks.** The controls, the LLVM 15 binary round trip, `form_coverage_check.py`, `rdna2_tools_check.py`, `pso_readiness_check.py` and `docs_links_check.py` pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:44:52 +00:00
MatyEjsr commented 2026-11-24 06:49:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MatyEjsr on 2026-11-23T06:36:12Z.


Verdict: Approve (reviewed head 1e268ab782c70bc6094ca34148ca00a33ad46101, compared against main ab5d3a5).

Verification

Environment: Windows 11 x64, Python 3.12.10, and WSL Arch llvm-mc 23.1.5 (-triple=amdgcn--amdpal -mcpu=gfx1013) for ISA checks. Zero-GPU review (no WARP or hardware draw executed).

Commands and results on 1e268ab:

  • python -B tests/pixel_aot_check.py: passed (exit 0).
  • python -B tests/rdna2_tools_check.py: 65 passed, 1 skipped (test_llvm_comparison, skipped because LLVM_LIB is not set on Windows).
  • python -B tests/docs_links_check.py (13 files, 154 links) and python -B tests/bidi_controls_check.py (654 files): both passed.
  • git merge-tree --write-tree main 1e268ab: clean against ab5d3a5 (exit 0).

Before vs. after against main (ab5d3a5):

  • On main, scan_unsupported_shaders.is_instruction_supported() returned True for v_cmp_lt_{f32,f16,i32,u16}_e32 s52, v18, v19, v_cmp_lt_f32_e32 s[52:53], v18, v19, and v_cmp_class_{f32,f16}_e32 s52, v18, 0x3, and pixel_aot accepted them.
  • On 1e268ab, all 6 non-SDWA v_cmp_* branches in tools/pixel_aot.py (class_f32, class_f16, f32, f16, i32/u32, i16/u16) enforce check_vopc_e32_dst, and the corresponding tools/scan_unsupported_shaders.py rules reject _e32 with an SGPR destination while preserving suffix-less, _e64, and _e32 vcc/vcc_lo.

Independent ISA and parity checks:

  • WSL llvm-mc (-triple=amdgcn--amdpal -mcpu=gfx1013 -show-encoding): Across all 14 families ({f32,f16,i32,u32,i16,u16} × {lt,eq} + class_{f32,f16}): _e32 with s52 / s[52:53] rejected 28/28, _e32 with vcc_lo accepted 14/14, suffix-less with s52 accepted 14/14, and _e64 with s52 accepted 14/14.
  • SDWA check: Verified llvm-mc accepts v_cmp_lt_f32_sdwa with both vcc/vcc_lo and s52/s[52:53], confirming leaving the v_cmp_*_f32_sdwa branch unchanged is ISA-accurate.
  • Scanner vs. translator parity: Tested 252 matrix cases (14 families × {_e32, suffix-less, _e64} × {vcc_lo, vcc, s52, s[52:53], exec, v12}) plus 5 modifier/SDWA cases (v_cmp_lt_f16 with -s44 and v_cmp_lt_f32_sdwa): 0 parity diffs.
  • Fixtures are synthetic source-owned instructions with both positive controls (vcc/vcc_lo, suffix-less, _e64) and negative controls (_e32 with s52/s[52:53]).

AI-assisted review (local Python and llvm-mc checks executed locally).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7093491985 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/806#issuecomment-7093491985). Originally posted by [MatyEjsr](https://github.com/MatyEjsr) on 2026-11-23T06:36:12Z. --- **Verdict: Approve** (reviewed head `1e268ab782c70bc6094ca34148ca00a33ad46101`, compared against `main` `ab5d3a5`). ### Verification Environment: Windows 11 x64, Python 3.12.10, and WSL Arch `llvm-mc` 23.1.5 (`-triple=amdgcn--amdpal -mcpu=gfx1013`) for ISA checks. Zero-GPU review (no WARP or hardware draw executed). Commands and results on `1e268ab`: - `python -B tests/pixel_aot_check.py`: passed (exit 0). - `python -B tests/rdna2_tools_check.py`: **65 passed, 1 skipped** (`test_llvm_comparison`, skipped because `LLVM_LIB` is not set on Windows). - `python -B tests/docs_links_check.py` (13 files, 154 links) and `python -B tests/bidi_controls_check.py` (654 files): both passed. - `git merge-tree --write-tree main 1e268ab`: clean against `ab5d3a5` (exit 0). Before vs. after against `main` (`ab5d3a5`): - On `main`, `scan_unsupported_shaders.is_instruction_supported()` returned `True` for `v_cmp_lt_{f32,f16,i32,u16}_e32 s52, v18, v19`, `v_cmp_lt_f32_e32 s[52:53], v18, v19`, and `v_cmp_class_{f32,f16}_e32 s52, v18, 0x3`, and `pixel_aot` accepted them. - On `1e268ab`, all 6 non-SDWA `v_cmp_*` branches in `tools/pixel_aot.py` (`class_f32`, `class_f16`, `f32`, `f16`, `i32/u32`, `i16/u16`) enforce `check_vopc_e32_dst`, and the corresponding `tools/scan_unsupported_shaders.py` rules reject `_e32` with an SGPR destination while preserving suffix-less, `_e64`, and `_e32 vcc`/`vcc_lo`. Independent ISA and parity checks: - **WSL `llvm-mc` (`-triple=amdgcn--amdpal -mcpu=gfx1013 -show-encoding`):** Across all 14 families (`{f32,f16,i32,u32,i16,u16}` × `{lt,eq}` + `class_{f32,f16}`): `_e32` with `s52` / `s[52:53]` rejected **28/28**, `_e32` with `vcc_lo` accepted **14/14**, suffix-less with `s52` accepted **14/14**, and `_e64` with `s52` accepted **14/14**. - **SDWA check:** Verified `llvm-mc` accepts `v_cmp_lt_f32_sdwa` with both `vcc`/`vcc_lo` and `s52`/`s[52:53]`, confirming leaving the `v_cmp_*_f32_sdwa` branch unchanged is ISA-accurate. - **Scanner vs. translator parity:** Tested 252 matrix cases (14 families × `{_e32, suffix-less, _e64}` × `{vcc_lo, vcc, s52, s[52:53], exec, v12}`) plus 5 modifier/SDWA cases (`v_cmp_lt_f16` with `-s44` and `v_cmp_lt_f32_sdwa`): **0 parity diffs**. - Fixtures are synthetic source-owned instructions with both positive controls (`vcc`/`vcc_lo`, suffix-less, `_e64`) and negative controls (`_e32` with `s52`/`s[52:53]`). *AI-assisted review (local Python and `llvm-mc` checks executed locally).*
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!800
No description provided.