startup: gfx2hlsl refuses VOPC SDWA compares (v_cmp*_sdwa, v_cmpx*_sdwa) #1899

Open
opened 2026-11-24 20:44:56 +00:00 by MasterDomino · 5 comments
MasterDomino commented 2026-11-24 20:44:56 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T20:44:56Z.


Part of #870. In a local startup run on current main (RX 9070 XT, the post-confirm load), tools/startup/gfx2hlsl.py --pending refuses 12 pipeline requests with unsupported: v_cmpx_le_i32_sdwa. compare() rejects every compare with an _sdwa suffix. tools/disasm_rdna2.py already decodes VOPC SDWA in full (_decode_vopc_sdwa), and pixel_aot lowers only the f32 form with DWORD selects.

Forms in those refused pixel programs. Aggregate count per form, with operands reduced to their kind:

Count Form
12 v_cmpx_le_i32_sdwa <const>, sext(vN) src0_sel:DWORD src1_sel:BYTE_0
3 v_cmpx_ne_i32_sdwa sN, vN src0_sel:DWORD src1_sel:BYTE_0
9 v_cmp_ne_i32_sdwa sN, sN, vN src0_sel:DWORD src1_sel:BYTE_0
12 v_cmpx_class_f32_sdwa <const>, vN src0_sel:DWORD src1_sel:BYTE_1
39 v_cmp_class_f32_sdwa sN, <const or sN>, vN src0_sel:DWORD src1_sel:BYTE_1 or WORD_1

The translator stops at the first refusal, so the later forms in the same programs are hidden today. The _class_ forms also need v_cmp_class_f32 itself, which compare() has no condition for (6 separate refusals in the same run). I'd keep that as its own follow-up.

Proposed scope

compare() accepts the _sdwa forms of the existing compare table:

  • Operand selects: i32/u32 sources take src0_sel/src1_sel through the existing sdwa_source helper, with sext() when printed.
  • f32 sources: keep DWORD selects only and refuse any other select.
  • Destination: EXEC for v_cmpx_*_sdwa (gfx10 forbids sdst_en there); VCC, or the SGPR pair the decoder prints, for v_cmp_*_sdwa. Same EXEC masking as the non-SDWA path.
  • Refused: class, float sources with a non-DWORD select, and any SDWA modifier the decoder does not print for compares.

Acceptance

  • Translator check against a reference (in the style of startup_gfx2hlsl_sdwa_check.py). Every compare in the table × every select × sext on/off, with the source chosen so the selected field differs from the full DWORD. The result must equal an integer reference: the selected, extended field compared as the type says. This covers v_cmp into VCC and into an SGPR pair, and v_cmpx into EXEC.
  • LLVM 15 round trip: encode and decode for the accepted forms.
  • Refusal cases: class, a non-DWORD select on an f32 compare, and an unexpected modifier.
  • Draw on WARP and the RX 9070 XT: a source-built pixel program where a v_cmpx_le_i32_sdwa on a sign-extended byte decides which pixels survive, checked pixel by pixel.
  • Negative controls: a translation that ignores the select, and one that ignores sext, must both fail the draw.
  • Recount on our loading path: report the same run's refusal counts again, aggregate only.

I'd like to take this; PR to follow.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6591052201 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1906). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T20:44:56Z. --- Part of #870. In a local startup run on current `main` (RX 9070 XT, the post-confirm load), `tools/startup/gfx2hlsl.py --pending` refuses 12 pipeline requests with `unsupported: v_cmpx_le_i32_sdwa`. `compare()` rejects every compare with an `_sdwa` suffix. `tools/disasm_rdna2.py` already decodes VOPC SDWA in full (`_decode_vopc_sdwa`), and `pixel_aot` lowers only the f32 form with DWORD selects. **Forms in those refused pixel programs.** Aggregate count per form, with operands reduced to their kind: | Count | Form | |---:|---| | 12 | `v_cmpx_le_i32_sdwa <const>, sext(vN) src0_sel:DWORD src1_sel:BYTE_0` | | 3 | `v_cmpx_ne_i32_sdwa sN, vN src0_sel:DWORD src1_sel:BYTE_0` | | 9 | `v_cmp_ne_i32_sdwa sN, sN, vN src0_sel:DWORD src1_sel:BYTE_0` | | 12 | `v_cmpx_class_f32_sdwa <const>, vN src0_sel:DWORD src1_sel:BYTE_1` | | 39 | `v_cmp_class_f32_sdwa sN, <const or sN>, vN src0_sel:DWORD src1_sel:BYTE_1 or WORD_1` | The translator stops at the first refusal, so the later forms in the same programs are hidden today. The `_class_` forms also need `v_cmp_class_f32` itself, which `compare()` has no condition for (6 separate refusals in the same run). I'd keep that as its own follow-up. ## Proposed scope `compare()` accepts the `_sdwa` forms of the existing compare table: - **Operand selects:** i32/u32 sources take `src0_sel`/`src1_sel` through the existing `sdwa_source` helper, with `sext()` when printed. - **f32 sources:** keep DWORD selects only and refuse any other select. - **Destination:** EXEC for `v_cmpx_*_sdwa` (gfx10 forbids `sdst_en` there); VCC, or the SGPR pair the decoder prints, for `v_cmp_*_sdwa`. Same EXEC masking as the non-SDWA path. - **Refused:** `class`, float sources with a non-DWORD select, and any SDWA modifier the decoder does not print for compares. ## Acceptance - **Translator check against a reference** (in the style of `startup_gfx2hlsl_sdwa_check.py`). Every compare in the table × every select × sext on/off, with the source chosen so the selected field differs from the full DWORD. The result must equal an integer reference: the selected, extended field compared as the type says. This covers `v_cmp` into VCC and into an SGPR pair, and `v_cmpx` into EXEC. - **LLVM 15 round trip:** encode and decode for the accepted forms. - **Refusal cases:** class, a non-DWORD select on an f32 compare, and an unexpected modifier. - **Draw on WARP and the RX 9070 XT:** a source-built pixel program where a `v_cmpx_le_i32_sdwa` on a sign-extended byte decides which pixels survive, checked pixel by pixel. - **Negative controls:** a translation that ignores the select, and one that ignores `sext`, must both fail the draw. - **Recount on our loading path:** report the same run's refusal counts again, aggregate only. I'd like to take this; PR to follow. AI-assisted.
MasterDomino commented 2026-11-24 21:27:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T21:06:27Z.


PR: https://github.com/R0Y00/Xbox2Windows/pull/1915. Reference check over every integer compare × destination × select × sext (9,408 forms × 64 value pairs) plus the f32 DWORD forms and the refusals; LLVM 15 decode of all 9,889 accepted forms; a source-built draw where v_cmpx_le_i32_sdwa on a sign-extended byte decides which pixels survive — 256/256 on WARP and the RX 9070 XT with FXC and DXC, and the select-dropping and sext-dropping mutants fail (120 and 96 pixels). The llvm-mc encode mode runs in the CI LLVM 15 job (no llvm-mc locally). Recount on our loading path: the 12 requests now get past this refusal and stop at the next gap (s_nor_b32); class compares remain the follow-up.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7144484584 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1906#issuecomment-7144484584). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T21:06:27Z. --- PR: https://github.com/R0Y00/Xbox2Windows/pull/1915. Reference check over every integer compare × destination × select × sext (9,408 forms × 64 value pairs) plus the f32 DWORD forms and the refusals; LLVM 15 decode of all 9,889 accepted forms; a source-built draw where `v_cmpx_le_i32_sdwa` on a sign-extended byte decides which pixels survive — 256/256 on WARP and the RX 9070 XT with FXC and DXC, and the select-dropping and sext-dropping mutants fail (120 and 96 pixels). The llvm-mc encode mode runs in the CI LLVM 15 job (no llvm-mc locally). Recount on our loading path: the 12 requests now get past this refusal and stop at the next gap (`s_nor_b32`); class compares remain the follow-up. AI-assisted.
R0Y00 commented 2026-11-24 21:27:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T21:26:01Z.


The integer-only lowering in #1915 has merged. On the exact candidate the independent translator run passed 9,408 integer forms over 64 value pairs and refused all 720 f32 SDWA forms. The author reported that the 12 loading requests advanced to the next shader refusal, s_nor_b32. That result is a shader translation checkpoint. The main executable's measured slot 148 startup boundary is unchanged.

Keep float SDWA on this issue pending the independent predicate work in #1920. The scalar complement follow-up is already claimed in #1919.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7144923464 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1906#issuecomment-7144923464). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T21:26:01Z. --- The integer-only lowering in #1915 has merged. On the exact candidate the independent translator run passed 9,408 integer forms over 64 value pairs and refused all 720 f32 SDWA forms. The author reported that the 12 loading requests advanced to the next shader refusal, s_nor_b32. That result is a shader translation checkpoint. The main executable's measured slot 148 startup boundary is unchanged. Keep float SDWA on this issue pending the independent predicate work in #1920. The scalar complement follow-up is already claimed in #1919.
R0Y00 commented 2026-11-24 23:03:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T22:43:08Z.


#1969 is on main at 9dcf1ae1. The binary32 class compare now selects the class mask from SRC1. Independent default FXC and DXC runs matched all 256 pixels on WARP and RTX 4060 Laptop, and bypassing the selector failed the class control. The ordinary f32 comparison predicates are still tracked here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146562791 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1906#issuecomment-7146562791). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T22:43:08Z. --- #1969 is on main at 9dcf1ae1. The binary32 class compare now selects the class mask from SRC1. Independent default FXC and DXC runs matched all 256 pixels on WARP and RTX 4060 Laptop, and bypassing the selector failed the class control. The ordinary f32 comparison predicates are still tracked here.
MasterDomino commented 2026-11-25 05:04:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T04:31:03Z.


I'd like to take the f32 SDWA compares in gfx2hlsl that #1915 left refused. Now that #1930 and #1949 are on main, every f32 predicate in the table is exact on NaN under default-flag FXC and DXC, so the SDWA forms can reuse it.

Scope:

  • v_cmp_*_f32_sdwa and v_cmpx_*_f32_sdwa with src0_sel/src1_sel and the SDWA neg/abs source modifiers.
  • A selected word or half reads as binary32 bits after the selection, as the ISA defines for SDWA. Each selection and modifier is checked against llvm-mc and LLVM's disassembler.
  • v_cmp_class_f32_sdwa stays out of scope; #2020 covers the f16 class forms.

Tests:

  • The 256-pair NaN/denormal reference and the compiler-rewrite models from startup_gfx2hlsl_f32_nan_check.py, applied to the SDWA forms.
  • Pixel-checked draws with default-flag FXC ps_5_1 and DXC ps_6_0 on WARP and hardware.
  • Negative controls: a mutant without the selection, and one with the pre-#1930/#1949 text, must each fail.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152914019 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1906#issuecomment-7152914019). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T04:31:03Z. --- I'd like to take the f32 SDWA compares in `gfx2hlsl` that #1915 left refused. Now that #1930 and #1949 are on main, every f32 predicate in the table is exact on NaN under default-flag FXC and DXC, so the SDWA forms can reuse it. Scope: - `v_cmp_*_f32_sdwa` and `v_cmpx_*_f32_sdwa` with `src0_sel`/`src1_sel` and the SDWA neg/abs source modifiers. - A selected word or half reads as binary32 bits after the selection, as the ISA defines for SDWA. Each selection and modifier is checked against `llvm-mc` and LLVM's disassembler. - `v_cmp_class_f32_sdwa` stays out of scope; #2020 covers the f16 class forms. Tests: - The 256-pair NaN/denormal reference and the compiler-rewrite models from `startup_gfx2hlsl_f32_nan_check.py`, applied to the SDWA forms. - Pixel-checked draws with default-flag FXC `ps_5_1` and DXC `ps_6_0` on WARP and hardware. - Negative controls: a mutant without the selection, and one with the pre-#1930/#1949 text, must each fail. AI-assisted.
MasterDomino commented 2026-11-25 06:01:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T05:23:12Z.


PR: #2212 (Refs #1906). It is narrower than my claim and corrects its semantics wording.

  • DWORD selections are lowered: src0_sel:DWORD src1_sel:DWORD, with any neg/abs, emits exactly the e64 text, including the #1930/#1949 NaN bit test on the registers. That covers 720 forms, checked over the 256 NaN/denormal pairs under IEEE, FXC-rewrite and DXC-fold models, and drawn with default-flag FXC and DXC on WARP and the RX 9070 XT.
  • Byte and word selections are refused, with the message f32 SDWA byte/word selection depends on the binary32 denormal mode. That's all 34,560 such forms. My claim said a selected field "reads as binary32 bits ... as the ISA defines". The RDNA 2 ISA guide defines only the SDWAB fields, and the zero-extend-then-read-as-binary32 model comes from LLVM's SIPeepholeSDWA. Under that model, the field is always +0 or a denormal, so the result depends only on the denormal mode, which gfx2hlsl doesn't read. pixel_aot refuses the same forms.
  • Still refused: sext() on a float source (integer-only; LLVM 15 doesn't decode it), clamp/omod/dst_sel, and the class compares.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153720056 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1906#issuecomment-7153720056). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T05:23:12Z. --- PR: #2212 (`Refs #1906`). It is narrower than my claim and corrects its semantics wording. - **DWORD selections are lowered:** `src0_sel:DWORD src1_sel:DWORD`, with any neg/abs, emits exactly the e64 text, including the #1930/#1949 NaN bit test on the registers. That covers 720 forms, checked over the 256 NaN/denormal pairs under IEEE, FXC-rewrite and DXC-fold models, and drawn with default-flag FXC and DXC on WARP and the RX 9070 XT. - **Byte and word selections are refused**, with the message `f32 SDWA byte/word selection depends on the binary32 denormal mode`. That's all 34,560 such forms. My claim said a selected field "reads as binary32 bits ... as the ISA defines". The RDNA 2 ISA guide defines only the SDWAB fields, and the zero-extend-then-read-as-binary32 model comes from LLVM's `SIPeepholeSDWA`. Under that model, the field is always +0 or a denormal, so the result depends only on the denormal mode, which gfx2hlsl doesn't read. `pixel_aot` refuses the same forms. - **Still refused:** `sext()` on a float source (integer-only; LLVM 15 doesn't decode it), clamp/omod/`dst_sel`, and the class compares. AI-assisted.
Sign in to join this conversation.
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#1899
No description provided.