startup: lower VOPC SDWA compares in gfx2hlsl #1908

Merged
MasterDomino merged 2 commits from upstream-pr/1915 into main 2026-11-24 21:24:48 +00:00
MasterDomino commented 2026-11-24 21:06:15 +00:00 (Migrated from github.com)

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


Refs #1906

What and why

tools/startup/gfx2hlsl.py compare() refused every compare with an _sdwa suffix. In a local startup run on main, 12 pipeline requests stopped at unsupported: v_cmpx_le_i32_sdwa. tools/disasm_rdna2.py already decodes VOPC SDWA in full (_decode_vopc_sdwa). This change lowers the SDWA forms of the compare table compare() already has.

Change

  • i32 and u32 sources read their src0_sel/src1_sel field through the existing sdwa_source(), sign-extended when the decoder prints sext(). The compare reads the extended 32-bit value as its type: int(...) for i32, unsigned for u32.
  • f32 compares are refused in their SDWA form (<name>: f32 SDWA compares are not lowered). Their predicates are shared with the non-SDWA forms, whose lg/nlg are not ordered for NaN (#1920), so no f32 SDWA lowering is claimed until those predicates are verified independently. Review follow-up in 800a8e34.
  • Destination: EXEC for v_cmpx_*_sdwa (two operands; gfx10 forbids sdst_en). For v_cmp_*_sdwa, vcc_lo or the SGPR the decoder prints, through set_s and masks. EXEC masking is the same as in the non-SDWA path.
  • Refused: class compares (v_cmp_class_*, v_cmpx_class_*), with the same message as before. Also refused: every f32 SDWA compare, a missing or repeated select, an unknown select value, and any SDWA modifier other than src0_sel/src1_sel (clamp, dst_sel, dst_unused, src2_sel, mul:2). So are a destination other than vcc_lo, EXEC or an SGPR, the wrong operand count, and 16-bit compares.
  • The v_cmp dispatch in Stage.one() already ran before the VOP1/VOP2 _sdwa route. It now passes mods to compare().
  • The condition check moved above the operand conversion, so an unknown condition is refused before its operands are read. Valid non-SDWA compares emit the same text as before (checked below).
  • tests/offscreen_check.cpp gains --startup-pixel-words <vs> <ps> <width> <height> <expected.bin>. It draws through the existing check_startup_flat_param path over a width × height target and compares every pixel's four words with a file. It reports the first differing pixel and the number of differing pixels.

Tests

Commit 925198a1 on upstream/main 94dbdbf0. Windows 11 build 26300.9974, DXC 1.8.2502.11 and FXC from Windows SDK 10.0.26100, D3D12 debug layer enabled (debug_errors=0 debug_warnings=0).

Translator check against a reference (pure Python, also runs on Linux):

ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_vopc_sdwa$' -V

The check covers all 32 i32/u32 compares the decoder names (f, lt, eq, le, gt, ne, ge, t; v_cmp and v_cmpx). Destinations are v_cmp into vcc_lo, v_cmp into an SGPR and v_cmpx into EXEC. Each source takes every select (BYTE_0..3, WORD_0/1, DWORD) with sext() on and off. That makes 9408 forms. Each form is built from the VOP_SDWA9Be fields, decoded by tools/disasm_rdna2.py and translated. The emitted HLSL runs through the integer evaluator from startup_gfx2hlsl_bit_alu_check.py over 64 source pairs (602,112 evaluations). The reference is the selected field, zero- or sign-extended in plain Python integers, then compared as the type says. Result: 9408 integer forms x 64 pairs (602112 evaluations) equal the reference: ok. The check also confirms that the value set separates every condition from a lowering without the select or without sext(). It also checks:

  • masking by an already-reduced EXEC;
  • SGPR and inline-constant sources (sext(s3) BYTE_3, -16);
  • 720 f32 SDWA forms (every condition, neg/abs on both sources, all three destinations) are refused, and so is every byte or word select on a float source;
  • each refusal with its exact message;
  • the non-SDWA text unchanged.

Result: PASS, 1.9 s.

LLVM 15 round trip:

python -B tests/startup_gfx2hlsl_vopc_sdwa_check.py decode "C:\Program Files\LLVM\bin\LLVM-C.dll"

With LLVM 15.0.7, LLVM's C API disassembles all 9889 accepted forms and the pixel fixture exactly as tools/disasm_rdna2.py does. Result: PASS. The binary <llvm-mc> mode assembles the same decoded text with llvm-mc and compares it with the words built in the test. Run locally with llvm-mc 15.0.7 (from a conda LLVM 15 package): llvm-mc assembles 9889 decoded VOPC SDWA forms to the same words: ok, llvm-mc assembles the pixel fixture to the same words: ok, PASS. Both modes are added to the LLVM 15 list in .github/workflows/windows.yml (binary llvm-mc-15, decode libLLVM-15.so.1), and the controls are added to the platform-independent Python list.

Draw on WARP and the RX 9070 XT:

ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_vopc_sdwa_(warp|hardware)$' -V

The pixel program is source-built (v_mul_u32_u24_e32 v1, 0x9b5d, v0, then v_cmpx_le_i32_sdwa -16, sext(v1) src0_sel:DWORD src1_sel:BYTE_1, then exp mrt0 v0, v0, v0, v0 done vm). It reads the packed screen position, so the compare decides per pixel which of 16 × 16 pixels survive: 160 do. Every pixel's four words are compared with a CPU reference: survivors hold the packed position, and discarded pixels keep the clear value -1.0. The pixel stage is compiled with FXC ps_5_1 and DXC ps_6_0.

Backend Adapter, driver FXC ps_5_1 DXC ps_6_0
WARP Microsoft Basic Render Driver, 10.0.26100.9818 256/256 pixels match 256/256 pixels match
Hardware AMD Radeon RX 9070 XT (1002:7550), 32.0.31044.16 256/256 pixels match 256/256 pixels match

No capability skips.

Other tests run:

  • ctest --preset dev --no-tests=error -R '^startup_' -j 4: 259 passed, 0 failed, 4 skipped (exit 77). The skipped tests are startup_view_heap_{warp,hardware} and startup_logical_view_{warp,hardware}. On this machine the adapter accepts enough descriptors that the logical view tables are not needed. None of the four is related to this change.
  • ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_|rdna2_tools|docs_links)': 29/29 passed.
  • python -B tools/run_checks_parallel.py <the 61 checks of the python-linux job, including tests/form_coverage_check.py, tests/rdna2_tools_check.py, tests/docs_links_check.py and tests/bidi_controls_check.py>: all 61 passed.

tests/form_coverage_check.py measures pixel_aot's accepted forms, not gfx2hlsl, so it needs no update.

Negative controls

  • Draw mutants. Two mutations of the translated pixel stage must each fail the draw against the reference and match their own plain-integer image. One reads the whole dword (v1 in place of the selected field). The other zero-extends the byte (((v1 >> 8u) & 0xffu)). Both hold on WARP and hardware, with both compilers:
    • no select: pixel mismatch (1,0): expected bf800000,bf800000,bf800000,bf800000 actual 00000001,00000001,00000001,00000001 / 120 of 256 pixels differ
    • no sext: pixel mismatch (1,0): expected bf800000,bf800000,bf800000,bf800000 actual 00000001,00000001,00000001,00000001 / 96 of 256 pixels differ
  • Translator mutants (patched in a scratch run, not committed). Each one makes the reference check fail at 9408 integer forms x 64 pairs ... equal the reference. The mutants are:
    • sdwa_source ignoring the select;
    • ignoring sext();
    • always sign-extending;
    • reading i32 as unsigned;
    • swapping the sources.
  • Unmodified upstream/main translator. The new check stops at gfx2hlsl.Unsupported: v_cmp_f_i32_sdwa.

Recount on the loading path

I re-translated the same local startup run's 185 pipeline requests offline with upstream/main and with this branch. Aggregate counts only:

  • Requests refused at v_cmpx_le_i32_sdwa: 12 on main, 0 on this branch.
  • Those 12 now translate all of their v_cmpx_le_i32_sdwa <const>, sext(vN) src0_sel:DWORD src1_sel:BYTE_0 and stop at the next refusal, s_nor_b32 (12).
  • Total refusals are unchanged at 98, with 90 requests translated in both runs. All 536 other output files are byte-identical. Only the 12 refusal reasons changed.
  • Still behind the new first refusal in those programs: v_cmp_ne_i32_sdwa sN, sN, vN … BYTE_0 (9) and v_cmpx_ne_i32_sdwa sN, vN … BYTE_0 (3). The translator check above covers both forms. The class forms (v_cmp_class_f32_sdwa, 39; v_cmpx_class_f32_sdwa, 12) also remain.

Not covered

  • Existing, unchanged here: the shared compare table lowers f32 lg as != and nlg as !(a != b). For a NaN operand the ISA gives the opposite result in both cases. That affects the non-SDWA forms and is tracked in #1920; f32 SDWA forms are refused here until it is settled.
  • Class compares (v_cmp_class_*, v_cmpx_class_*, SDWA or not) stay refused. They need a class condition in compare(). That is the follow-up named in #1906.
  • v_cmp_tru_f32 and 16-bit compares stay refused, as before.
  • Not verified: execution of the title's CPU code, full-game startup and frame rate.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6591412725 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1915). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T21:06:15Z. --- Refs #1906 ## What and why `tools/startup/gfx2hlsl.py` `compare()` refused every compare with an `_sdwa` suffix. In a local startup run on `main`, 12 pipeline requests stopped at `unsupported: v_cmpx_le_i32_sdwa`. `tools/disasm_rdna2.py` already decodes VOPC SDWA in full (`_decode_vopc_sdwa`). This change lowers the SDWA forms of the compare table `compare()` already has. ## Change - **i32 and u32 sources** read their `src0_sel`/`src1_sel` field through the existing `sdwa_source()`, sign-extended when the decoder prints `sext()`. The compare reads the extended 32-bit value as its type: `int(...)` for i32, unsigned for u32. - **f32 compares** are refused in their SDWA form (`<name>: f32 SDWA compares are not lowered`). Their predicates are shared with the non-SDWA forms, whose `lg`/`nlg` are not ordered for NaN (#1920), so no f32 SDWA lowering is claimed until those predicates are verified independently. Review follow-up in `800a8e34`. - **Destination:** EXEC for `v_cmpx_*_sdwa` (two operands; gfx10 forbids `sdst_en`). For `v_cmp_*_sdwa`, `vcc_lo` or the SGPR the decoder prints, through `set_s` and `masks`. EXEC masking is the same as in the non-SDWA path. - **Refused:** class compares (`v_cmp_class_*`, `v_cmpx_class_*`), with the same message as before. Also refused: every f32 SDWA compare, a missing or repeated select, an unknown select value, and any SDWA modifier other than `src0_sel`/`src1_sel` (`clamp`, `dst_sel`, `dst_unused`, `src2_sel`, `mul:2`). So are a destination other than `vcc_lo`, EXEC or an SGPR, the wrong operand count, and 16-bit compares. - The `v_cmp` dispatch in `Stage.one()` already ran before the VOP1/VOP2 `_sdwa` route. It now passes `mods` to `compare()`. - The condition check moved above the operand conversion, so an unknown condition is refused before its operands are read. Valid non-SDWA compares emit the same text as before (checked below). - `tests/offscreen_check.cpp` gains `--startup-pixel-words <vs> <ps> <width> <height> <expected.bin>`. It draws through the existing `check_startup_flat_param` path over a width × height target and compares every pixel's four words with a file. It reports the first differing pixel and the number of differing pixels. ## Tests Commit `925198a1` on `upstream/main` `94dbdbf0`. Windows 11 build 26300.9974, DXC 1.8.2502.11 and FXC from Windows SDK 10.0.26100, D3D12 debug layer enabled (`debug_errors=0 debug_warnings=0`). **Translator check against a reference** (pure Python, also runs on Linux): ``` ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_vopc_sdwa$' -V ``` The check covers all 32 i32/u32 compares the decoder names (f, lt, eq, le, gt, ne, ge, t; `v_cmp` and `v_cmpx`). Destinations are `v_cmp` into `vcc_lo`, `v_cmp` into an SGPR and `v_cmpx` into EXEC. Each source takes every select (BYTE_0..3, WORD_0/1, DWORD) with `sext()` on and off. That makes 9408 forms. Each form is built from the VOP_SDWA9Be fields, decoded by `tools/disasm_rdna2.py` and translated. The emitted HLSL runs through the integer evaluator from `startup_gfx2hlsl_bit_alu_check.py` over 64 source pairs (602,112 evaluations). The reference is the selected field, zero- or sign-extended in plain Python integers, then compared as the type says. Result: `9408 integer forms x 64 pairs (602112 evaluations) equal the reference: ok`. The check also confirms that the value set separates every condition from a lowering without the select or without `sext()`. It also checks: - masking by an already-reduced EXEC; - SGPR and inline-constant sources (`sext(s3)` BYTE_3, `-16`); - 720 f32 SDWA forms (every condition, `neg`/`abs` on both sources, all three destinations) are refused, and so is every byte or word select on a float source; - each refusal with its exact message; - the non-SDWA text unchanged. Result: PASS, 1.9 s. **LLVM 15 round trip:** ``` python -B tests/startup_gfx2hlsl_vopc_sdwa_check.py decode "C:\Program Files\LLVM\bin\LLVM-C.dll" ``` With LLVM 15.0.7, LLVM's C API disassembles all 9889 accepted forms and the pixel fixture exactly as `tools/disasm_rdna2.py` does. Result: PASS. The `binary <llvm-mc>` mode assembles the same decoded text with llvm-mc and compares it with the words built in the test. Run locally with `llvm-mc` 15.0.7 (from a conda LLVM 15 package): `llvm-mc assembles 9889 decoded VOPC SDWA forms to the same words: ok`, `llvm-mc assembles the pixel fixture to the same words: ok`, PASS. Both modes are added to the LLVM 15 list in `.github/workflows/windows.yml` (`binary llvm-mc-15`, `decode libLLVM-15.so.1`), and the controls are added to the platform-independent Python list. **Draw on WARP and the RX 9070 XT:** ``` ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_vopc_sdwa_(warp|hardware)$' -V ``` The pixel program is source-built (`v_mul_u32_u24_e32 v1, 0x9b5d, v0`, then `v_cmpx_le_i32_sdwa -16, sext(v1) src0_sel:DWORD src1_sel:BYTE_1`, then `exp mrt0 v0, v0, v0, v0 done vm`). It reads the packed screen position, so the compare decides per pixel which of 16 × 16 pixels survive: 160 do. Every pixel's four words are compared with a CPU reference: survivors hold the packed position, and discarded pixels keep the clear value -1.0. The pixel stage is compiled with FXC `ps_5_1` and DXC `ps_6_0`. | Backend | Adapter, driver | FXC ps_5_1 | DXC ps_6_0 | |---|---|---|---| | WARP | Microsoft Basic Render Driver, 10.0.26100.9818 | 256/256 pixels match | 256/256 pixels match | | Hardware | AMD Radeon RX 9070 XT (1002:7550), 32.0.31044.16 | 256/256 pixels match | 256/256 pixels match | No capability skips. **Other tests run:** - `ctest --preset dev --no-tests=error -R '^startup_' -j 4`: 259 passed, 0 failed, 4 skipped (exit 77). The skipped tests are `startup_view_heap_{warp,hardware}` and `startup_logical_view_{warp,hardware}`. On this machine the adapter accepts enough descriptors that the logical view tables are not needed. None of the four is related to this change. - `ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_|rdna2_tools|docs_links)'`: 29/29 passed. - `python -B tools/run_checks_parallel.py <the 61 checks of the python-linux job, including tests/form_coverage_check.py, tests/rdna2_tools_check.py, tests/docs_links_check.py and tests/bidi_controls_check.py>`: all 61 passed. `tests/form_coverage_check.py` measures `pixel_aot`'s accepted forms, not gfx2hlsl, so it needs no update. ## Negative controls - **Draw mutants.** Two mutations of the translated pixel stage must each fail the draw against the reference and match their own plain-integer image. One reads the whole dword (`v1` in place of the selected field). The other zero-extends the byte (`((v1 >> 8u) & 0xffu)`). Both hold on WARP and hardware, with both compilers: - no select: `pixel mismatch (1,0): expected bf800000,bf800000,bf800000,bf800000 actual 00000001,00000001,00000001,00000001 / 120 of 256 pixels differ` - no sext: `pixel mismatch (1,0): expected bf800000,bf800000,bf800000,bf800000 actual 00000001,00000001,00000001,00000001 / 96 of 256 pixels differ` - **Translator mutants** (patched in a scratch run, not committed). Each one makes the reference check fail at `9408 integer forms x 64 pairs ... equal the reference`. The mutants are: - `sdwa_source` ignoring the select; - ignoring `sext()`; - always sign-extending; - reading i32 as unsigned; - swapping the sources. - **Unmodified `upstream/main` translator.** The new check stops at `gfx2hlsl.Unsupported: v_cmp_f_i32_sdwa`. ## Recount on the loading path I re-translated the same local startup run's 185 pipeline requests offline with `upstream/main` and with this branch. Aggregate counts only: - Requests refused at `v_cmpx_le_i32_sdwa`: 12 on `main`, 0 on this branch. - Those 12 now translate all of their `v_cmpx_le_i32_sdwa <const>, sext(vN) src0_sel:DWORD src1_sel:BYTE_0` and stop at the next refusal, `s_nor_b32` (12). - Total refusals are unchanged at 98, with 90 requests translated in both runs. All 536 other output files are byte-identical. Only the 12 refusal reasons changed. - Still behind the new first refusal in those programs: `v_cmp_ne_i32_sdwa sN, sN, vN … BYTE_0` (9) and `v_cmpx_ne_i32_sdwa sN, vN … BYTE_0` (3). The translator check above covers both forms. The class forms (`v_cmp_class_f32_sdwa`, 39; `v_cmpx_class_f32_sdwa`, 12) also remain. ## Not covered - **Existing, unchanged here:** the shared compare table lowers f32 `lg` as `!=` and `nlg` as `!(a != b)`. For a NaN operand the ISA gives the opposite result in both cases. That affects the non-SDWA forms and is tracked in #1920; f32 SDWA forms are refused here until it is settled. - **Class compares** (`v_cmp_class_*`, `v_cmpx_class_*`, SDWA or not) stay refused. They need a class condition in `compare()`. That is the follow-up named in #1906. - **`v_cmp_tru_f32` and 16-bit compares** stay refused, as before. - **Not verified:** execution of the title's CPU code, full-game startup and frame rate. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 21:27:34 +00:00
R0Y00 commented 2026-11-24 21:27:35 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


The integer SDWA fixture exercises the new select and sign-extension behavior, including the reported loading refusal. The f32 matrix currently compares only against the existing non-SDWA HLSL text. That oracle shares a predicate issue: RDNA2 LG is ordered less-or-greater and NLG is its negation, while the table emits != and its negation. Those expressions can disagree on NaN. Please keep this slice integer-only, or establish the f32 predicates independently with finite unequal/equal and NaN cases on the actual emitted FXC/DXC paths. In particular, LG should be false and NLG true for a NaN input. The new f32 SDWA support should not inherit the shared predicate without evidence.

AMD RDNA 2 ISA

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047525842 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1915#pullrequestreview-6047525842). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T21:14:58Z. **Review:** CHANGES_REQUESTED --- The integer SDWA fixture exercises the new select and sign-extension behavior, including the reported loading refusal. The f32 matrix currently compares only against the existing non-SDWA HLSL text. That oracle shares a predicate issue: RDNA2 LG is ordered less-or-greater and NLG is its negation, while the table emits != and its negation. Those expressions can disagree on NaN. Please keep this slice integer-only, or establish the f32 predicates independently with finite unequal/equal and NaN cases on the actual emitted FXC/DXC paths. In particular, LG should be false and NLG true for a NaN input. The new f32 SDWA support should not inherit the shared predicate without evidence. [AMD RDNA 2 ISA](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf)
tedin7 commented 2026-11-24 21:27:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:16:21Z.

Review: COMMENTED


Review of exact head 925198a1a5ccbfa36f7e4cbb27d59175d4d2c64d (title and body are neutral; the diff touches .github/workflows/windows.yml, CMakeLists.txt, docs/experiments.md, docs/startup-runtime.md, tests/offscreen_check.cpp, tests/startup_gfx2hlsl_vopc_sdwa_check.py, tools/startup/gfx2hlsl.py).

Verdict: no P1, no P2, no P3 found.

Commands run locally (against origin/main...HEAD):

  • git diff --check origin/main...HEAD: clean, rc=0
  • tests/docs_links_check.py: "Self-test passed. Checked 18 Markdown files and 377 links."
  • tests/bidi_controls_check.py: "Checked 1339 tracked source, script and build/CI files: no bidirectional controls."
  • tests/startup_gfx2hlsl_vopc_sdwa_check.py (plain): PASS.
  • tests/startup_gfx2hlsl_vopc_sdwa_check.py binary llvm-mc-19: "llvm-mc assembles 9889 decoded VOPC SDWA forms to the same words: ok", PASS. (The workflow passes llvm-mc-15; I had llvm-mc-19.)
  • tests/startup_gfx2hlsl_vopc_sdwa_check.py decode libLLVM-19.so: "LLVM disassembles 9889 VOPC SDWA forms as tools/disasm_rdna2.py does: ok", PASS. (The workflow passes libLLVM-15.so.1.)
  • x2w_pipe.py win2025 1915 --targets offscreen_check --regex '^startup_gfx2hlsl_vopc_sdwa(_warp)?$' on Windows Server 2025 (Debug and Release /O2): 2/2 passed in both (startup_gfx2hlsl_vopc_sdwa and the 16 x 16 pixel draw startup_gfx2hlsl_vopc_sdwa_warp, which exercises the new --startup-pixel-words operation).

Mutations (applied to tools/startup/gfx2hlsl.py on top of the exact head, startup_gfx2hlsl_vopc_sdwa_check.py plain run, then restored; the checkout stayed clean):

  1. sdwa_source(self.u(token), selection, sext) changed to pass False for sext (no sign extension): 5 MISMATCH lines, the run asserts. Caught.
  2. 'int(%s)' % word if typ == 'i32' else word changed to always word (i32 compared as unsigned): 7 MISMATCH lines. Caught.
  3. The float refusal if selection != 'DWORD': raise changed to if False (byte/word select accepted on a float source): 12 MISMATCH lines. Caught.
  4. The destination guard for v_cmp_*_sdwa (if not writes_exec and ops[0] not in ...) disabled: the run crashes with TypeError: 'NoneType' object is not subscriptable. Caught (and it shows the guard is load-bearing: vcc_hi and null reach reg_range otherwise).

What I checked by reading and probing:

  • sdwa_source with sext: for BYTE_1, asuint(asint(v << 16u) >> 24u) is the sign-extended byte; for WORD_1, asuint(asint(v << 0u) >> 16u) is the sign-extended high word. Both match the ISA meaning. u32 reads the extended value as unsigned and i32 wraps it in int().
  • Probes through Stage.one: float -|v1| with DWORD selects emits -abs(F(v1)), the same as the non-SDWA form; sext(v1) on a float source, a double sext(sext(v1)), src0_sel:BYTE_9, a repeated src0_sel, a missing src1_sel, and destinations vcc_hi and null are all refused with Unsupported, not a crash.
  • Non-SDWA compares emit the same text as before; only the condition-table check moved above the operand conversion.
  • run_startup_pixel_words rejects non-numeric or out-of-range sizes and an expected file that is too short or too long, and counts every differing pixel.

Limits: only WARP was available (the hardware variant of the draw test was not run). Local llvm-mc and libLLVM are version 19, not the 15 used in the workflow.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047543477 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1915#pullrequestreview-6047543477). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T21:16:21Z. **Review:** COMMENTED --- Review of exact head `925198a1a5ccbfa36f7e4cbb27d59175d4d2c64d` (title and body are neutral; the diff touches `.github/workflows/windows.yml`, `CMakeLists.txt`, `docs/experiments.md`, `docs/startup-runtime.md`, `tests/offscreen_check.cpp`, `tests/startup_gfx2hlsl_vopc_sdwa_check.py`, `tools/startup/gfx2hlsl.py`). **Verdict: no P1, no P2, no P3 found.** Commands run locally (against `origin/main...HEAD`): - `git diff --check origin/main...HEAD`: clean, rc=0 - `tests/docs_links_check.py`: "Self-test passed. Checked 18 Markdown files and 377 links." - `tests/bidi_controls_check.py`: "Checked 1339 tracked source, script and build/CI files: no bidirectional controls." - `tests/startup_gfx2hlsl_vopc_sdwa_check.py` (plain): PASS. - `tests/startup_gfx2hlsl_vopc_sdwa_check.py binary llvm-mc-19`: "llvm-mc assembles 9889 decoded VOPC SDWA forms to the same words: ok", PASS. (The workflow passes `llvm-mc-15`; I had `llvm-mc-19`.) - `tests/startup_gfx2hlsl_vopc_sdwa_check.py decode libLLVM-19.so`: "LLVM disassembles 9889 VOPC SDWA forms as tools/disasm_rdna2.py does: ok", PASS. (The workflow passes `libLLVM-15.so.1`.) - `x2w_pipe.py win2025 1915 --targets offscreen_check --regex '^startup_gfx2hlsl_vopc_sdwa(_warp)?$'` on Windows Server 2025 (Debug and Release /O2): 2/2 passed in both (`startup_gfx2hlsl_vopc_sdwa` and the 16 x 16 pixel draw `startup_gfx2hlsl_vopc_sdwa_warp`, which exercises the new `--startup-pixel-words` operation). Mutations (applied to `tools/startup/gfx2hlsl.py` on top of the exact head, `startup_gfx2hlsl_vopc_sdwa_check.py` plain run, then restored; the checkout stayed clean): 1. `sdwa_source(self.u(token), selection, sext)` changed to pass `False` for sext (no sign extension): 5 MISMATCH lines, the run asserts. Caught. 2. `'int(%s)' % word if typ == 'i32' else word` changed to always `word` (i32 compared as unsigned): 7 MISMATCH lines. Caught. 3. The float refusal `if selection != 'DWORD': raise` changed to `if False` (byte/word select accepted on a float source): 12 MISMATCH lines. Caught. 4. The destination guard for `v_cmp_*_sdwa` (`if not writes_exec and ops[0] not in ...`) disabled: the run crashes with `TypeError: 'NoneType' object is not subscriptable`. Caught (and it shows the guard is load-bearing: `vcc_hi` and `null` reach `reg_range` otherwise). What I checked by reading and probing: - `sdwa_source` with sext: for `BYTE_1`, `asuint(asint(v << 16u) >> 24u)` is the sign-extended byte; for `WORD_1`, `asuint(asint(v << 0u) >> 16u)` is the sign-extended high word. Both match the ISA meaning. u32 reads the extended value as unsigned and i32 wraps it in `int()`. - Probes through `Stage.one`: float `-|v1|` with DWORD selects emits `-abs(F(v1))`, the same as the non-SDWA form; `sext(v1)` on a float source, a double `sext(sext(v1))`, `src0_sel:BYTE_9`, a repeated `src0_sel`, a missing `src1_sel`, and destinations `vcc_hi` and `null` are all refused with `Unsupported`, not a crash. - Non-SDWA compares emit the same text as before; only the condition-table check moved above the operand conversion. - `run_startup_pixel_words` rejects non-numeric or out-of-range sizes and an expected file that is too short or too long, and counts every differing pixel. Limits: only WARP was available (the `hardware` variant of the draw test was not run). Local `llvm-mc` and `libLLVM` are version 19, not the 15 used in the workflow. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-24 21:27:35 +00:00 (Migrated from github.com)

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

Review: APPROVED


Rechecked the integer-only head. On this exact commit the 9,408 integer forms x 64 inputs and mutation controls pass, all 720 f32 SDWA forms are refused and the startup translator neighbors pass. The existing floating-point comparison follow-up remains #1920.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047660237 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1915#pullrequestreview-6047660237). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T21:24:37Z. **Review:** APPROVED --- Rechecked the integer-only head. On this exact commit the 9,408 integer forms x 64 inputs and mutation controls pass, all 720 f32 SDWA forms are refused and the startup translator neighbors pass. The existing floating-point comparison follow-up remains #1920.
tedin7 commented 2026-11-24 21:27:35 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Follow-up review of exact head 800a8e34d2368b497720c233491e941ac69321f6 (delta since 925198a1: docs/experiments.md, docs/startup-runtime.md, tests/startup_gfx2hlsl_vopc_sdwa_check.py, tools/startup/gfx2hlsl.py).

Verdict: no P1, no P2, no P3 found at this head.

Correction to my review of 925198a1: I wrote that the f32 SDWA text "equals the non-SDWA form's" and treated that as correct. That oracle shares the lg/nlg table entries ({0} != {1} and its negation), which are not the ordered RDNA 2 definitions for NaN. The earlier request for changes was right and I missed it. Refusing f32 SDWA compares, as this head does, is the safe fix; the non-SDWA predicates are tracked in #1920.

Commands run locally (against origin/main...HEAD):

  • git diff --check origin/main...HEAD: clean, rc=0
  • tests/docs_links_check.py: "Checked 18 Markdown files and 377 links." (self-test passed)
  • tests/bidi_controls_check.py: "Checked 1339 tracked source, script and build/CI files: no bidirectional controls."
  • tests/startup_gfx2hlsl_vopc_sdwa_check.py (plain), binary llvm-mc-19 (9889 forms, same words), decode libLLVM-19.so (9889 forms): all PASS.
  • x2w_pipe.py win2025 1915 --targets offscreen_check --regex '^startup_gfx2hlsl_vopc_sdwa(_warp)?$' on Windows Server 2025 (Debug and Release /O2): 2/2 passed in both.

Mutations (tools/startup/gfx2hlsl.py on top of the exact head, plain check run, then restored; the checkout stayed clean):

  1. The f32 SDWA refusal disabled (if False and sdwa and typ == 'f32'): 13 MISMATCH lines. Caught.
  2. The f32 refusal skipped only for lg and nlg (the conditions the review named): 1 MISMATCH ("720 float SDWA forms refused"). Caught, so a partial refusal is detected.
  3. Sign extension dropped (sdwa_source(..., False)): 5 MISMATCH lines, the run asserts. Caught.
  4. i32 read as unsigned (the int() wrap removed): 7 MISMATCH lines. Caught.

What I checked by reading: the refusal sits after the condition-table check and before any operand is read, so class compares and unknown conditions keep their old messages and all 720 f32 SDWA forms get the same message. The integer lowering, destination rules and pixel-words operation are unchanged from the previous head, and the docs now say f32 SDWA is refused (#1920).

Limits: only WARP was available here; the hardware variant was not run by me (the author reports it). Local llvm-mc and libLLVM are version 19, the workflow uses 15.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6047664189 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1915#pullrequestreview-6047664189). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T21:24:55Z. **Review:** COMMENTED --- Follow-up review of exact head `800a8e34d2368b497720c233491e941ac69321f6` (delta since `925198a1`: `docs/experiments.md`, `docs/startup-runtime.md`, `tests/startup_gfx2hlsl_vopc_sdwa_check.py`, `tools/startup/gfx2hlsl.py`). **Verdict: no P1, no P2, no P3 found at this head.** Correction to my review of `925198a1`: I wrote that the f32 SDWA text "equals the non-SDWA form's" and treated that as correct. That oracle shares the `lg`/`nlg` table entries (`{0} != {1}` and its negation), which are not the ordered RDNA 2 definitions for NaN. The earlier request for changes was right and I missed it. Refusing f32 SDWA compares, as this head does, is the safe fix; the non-SDWA predicates are tracked in #1920. Commands run locally (against `origin/main...HEAD`): - `git diff --check origin/main...HEAD`: clean, rc=0 - `tests/docs_links_check.py`: "Checked 18 Markdown files and 377 links." (self-test passed) - `tests/bidi_controls_check.py`: "Checked 1339 tracked source, script and build/CI files: no bidirectional controls." - `tests/startup_gfx2hlsl_vopc_sdwa_check.py` (plain), `binary llvm-mc-19` (9889 forms, same words), `decode libLLVM-19.so` (9889 forms): all PASS. - `x2w_pipe.py win2025 1915 --targets offscreen_check --regex '^startup_gfx2hlsl_vopc_sdwa(_warp)?$'` on Windows Server 2025 (Debug and Release /O2): 2/2 passed in both. Mutations (`tools/startup/gfx2hlsl.py` on top of the exact head, plain check run, then restored; the checkout stayed clean): 1. The f32 SDWA refusal disabled (`if False and sdwa and typ == 'f32'`): 13 MISMATCH lines. Caught. 2. The f32 refusal skipped only for `lg` and `nlg` (the conditions the review named): 1 MISMATCH ("720 float SDWA forms refused"). Caught, so a partial refusal is detected. 3. Sign extension dropped (`sdwa_source(..., False)`): 5 MISMATCH lines, the run asserts. Caught. 4. i32 read as unsigned (the `int()` wrap removed): 7 MISMATCH lines. Caught. What I checked by reading: the refusal sits after the condition-table check and before any operand is read, so class compares and unknown conditions keep their old messages and all 720 f32 SDWA forms get the same message. The integer lowering, destination rules and pixel-words operation are unchanged from the previous head, and the docs now say f32 SDWA is refused (#1920). Limits: only WARP was available here; the hardware variant was not run by me (the author reports it). Local `llvm-mc` and `libLLVM` are version 19, the workflow uses 15. AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-24 21:27:39 +00:00 (Migrated from github.com)

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


The llvm-mc encode mode now also passes locally: startup_gfx2hlsl_vopc_sdwa_check.py binary with llvm-mc 15.0.7 assembles all 9,889 decoded VOPC SDWA forms and the pixel fixture to the same words (PASS). Description updated.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7144555981 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1915#issuecomment-7144555981). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T21:09:36Z. --- The llvm-mc encode mode now also passes locally: `startup_gfx2hlsl_vopc_sdwa_check.py binary` with llvm-mc 15.0.7 assembles all 9,889 decoded VOPC SDWA forms and the pixel fixture to the same words (PASS). Description updated. AI-assisted.
MasterDomino commented 2026-11-24 21:27:40 +00:00 (Migrated from github.com)

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


Agreed, and taken as integer-only in 800a8e34:

  • f32 refused: every f32 SDWA compare is now refused (<name>: f32 SDWA compares are not lowered), so none of them inherits the shared lg/nlg predicates.
  • Check updated: it confirms all 720 f32 SDWA forms (every condition, neg/abs on both sources, all destinations) and every byte or word select on a float source are refused.
  • Unchanged: the integer matrix, the draws, and LLVM 15 decode/encode.

Results at 800a8e34:

  • startup_gfx2hlsl_*: 27/27, including startup_gfx2hlsl_vopc_sdwa_{warp,hardware} on WARP and the RX 9070 XT.
  • binary with llvm-mc 15.0.7: PASS.
  • decode with LLVM-C 15.0.7: PASS.
  • docs and bidi checks: pass.

The f32 predicates themselves are #1920. I'm establishing them there independently: finite equal and unequal, ±0, ±inf, denormal and NaN cases, on the emitted FXC and DXC paths, with LG false and NLG true for a NaN input. f32 SDWA can follow once that holds.

@tedin7 thanks for the mutation run; none of the integer paths you probed changed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7144790798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1915#issuecomment-7144790798). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T21:20:04Z. --- Agreed, and taken as integer-only in `800a8e34`: - **f32 refused:** every f32 SDWA compare is now refused (`<name>: f32 SDWA compares are not lowered`), so none of them inherits the shared `lg`/`nlg` predicates. - **Check updated:** it confirms all 720 f32 SDWA forms (every condition, `neg`/`abs` on both sources, all destinations) and every byte or word select on a float source are refused. - **Unchanged:** the integer matrix, the draws, and LLVM 15 decode/encode. **Results at `800a8e34`:** - `startup_gfx2hlsl_*`: 27/27, including `startup_gfx2hlsl_vopc_sdwa_{warp,hardware}` on WARP and the RX 9070 XT. - `binary` with llvm-mc 15.0.7: PASS. - `decode` with LLVM-C 15.0.7: PASS. - docs and bidi checks: pass. The f32 predicates themselves are #1920. I'm establishing them there independently: finite equal and unequal, ±0, ±inf, denormal and NaN cases, on the emitted FXC and DXC paths, with LG false and NLG true for a NaN input. f32 SDWA can follow once that holds. @tedin7 thanks for the mutation run; none of the integer paths you probed changed. AI-assisted.
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!1908
No description provided.