compute: accept SDWA v_cvt_pkrtz_f16_f32 and v_add_co_ci_u32 #3201

Merged
Leyukaka merged 1 commit from upstream-pr/3201 into main 2026-11-27 22:05:25 +00:00
Leyukaka commented 2026-11-27 21:31:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T21:31:20Z.


Fixes #3183. Part of #2935. Target branch main.

Change (src/gfx1013_compute_native.cpp, src/gfx1013_direct_compute.inl): the SDWA forms of v_cvt_pkrtz_f16_f32 and v_add_co_ci_u32 are accepted in direct compute. Both ops already had direct lowerings but were missing from the SDWA operand profiles.

  • v_add_co_ci_u32 takes the SDWA source selections. It computes the sum and carry-out from the selected operands plus VCC carry-in, writes the carry to VCC as the VOP2 form does, and places the result per dst_sel/dst_unused.
  • v_cvt_pkrtz_f16_f32 takes full f32 sources (src_sel DWORD; other selections stay refused) and places the packed result per dst_sel/dst_unused.
  • Graphics, clamp and omod stay refused.

Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on main 5b145ca9 plus this commit (5a516752).

  • native_sdwa_f16_hardware reads back both ops in several destination placements against a CPU reference, including the carry in VCC.
  • native_sdwa_f16_ir, native_f16_alu* and native_direct_container pass.
  • Mutation check, run by hand: writing the v_add_co_ci_u32 result without SDWA placement fails native_sdwa_f16_hardware.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, baseline main 6057071b. The change was measured on a5dad843; the commits in between do not touch the two native source files.

  • 9 v_cvt_pkrtz_f16_f32_sdwa and 3 v_add_co_ci_u32_sdwa requests stopped first at "unimplemented direct SDWA operand profile".
  • 1 now compiles: 403 to 404 in the capture, and 416 to 417 in the requests of one start-up run.
  • No request that compiled before stops compiling.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5533338071 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3201). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T21:31:20Z. --- Fixes #3183. Part of #2935. Target branch `main`. **Change** (`src/gfx1013_compute_native.cpp`, `src/gfx1013_direct_compute.inl`): the SDWA forms of `v_cvt_pkrtz_f16_f32` and `v_add_co_ci_u32` are accepted in direct compute. Both ops already had direct lowerings but were missing from the SDWA operand profiles. - `v_add_co_ci_u32` takes the SDWA source selections. It computes the sum and carry-out from the selected operands plus VCC carry-in, writes the carry to VCC as the VOP2 form does, and places the result per dst_sel/dst_unused. - `v_cvt_pkrtz_f16_f32` takes full f32 sources (src_sel DWORD; other selections stay refused) and places the packed result per dst_sel/dst_unused. - Graphics, clamp and omod stay refused. **Tests.** The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on `main` `5b145ca9` plus this commit (`5a516752`). - `native_sdwa_f16_hardware` reads back both ops in several destination placements against a CPU reference, including the carry in VCC. - `native_sdwa_f16_ir`, `native_f16_alu*` and `native_direct_container` pass. - Mutation check, run by hand: writing the `v_add_co_ci_u32` result without SDWA placement fails `native_sdwa_f16_hardware`. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`, baseline `main` `6057071b`. The change was measured on `a5dad843`; the commits in between do not touch the two native source files. - 9 `v_cvt_pkrtz_f16_f32_sdwa` and 3 `v_add_co_ci_u32_sdwa` requests stopped first at "unimplemented direct SDWA operand profile". - 1 now compiles: 403 to 404 in the capture, and 416 to 417 in the requests of one start-up run. - No request that compiled before stops compiling. AI-assisted.
pigalot commented 2026-11-27 22:04:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:04:29Z.

Review: APPROVED


Independently reviewed 5a516752 integrated over main 63fd6ea8 (tree 1a03639e). The merge is clean and git diff --cached --check is clean.

What I traced.

  • Decoder. v_add_co_ci_u32 joins the integer SDWA profile, so sext is allowed and neg/abs (control & 0x30), clamp and omod are refused. v_cvt_pkrtz_f16_f32 joins the fp-input profile, so abs/neg are allowed and sext is refused. Clamp and omod are refused for it too, because it is in neither floats nor conversion. Both are refused under graphics.
  • Carry path. Only v_add_co_ci_u32 reaches carry_destination() with i.subword set: the other carry ops never pass the SDWA profile check. The operands are selected before the optional v_subrev swap. Carry-out and the VCC carry-in come from the full 32-bit sum of the selected operands. Only the VGPR result goes through place_subword().
  • pkrtz. The existing abs/neg and RTZ packing is unchanged. The new refusal limits both sources to src_sel:DWORD, and the packed word is then placed per dst_sel/dst_unused.

What I ran. I built compile_dxil native_store_replay native_compute_ir_dump in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_sdwa_f16_ir|native_f16_alu_ir|native_direct_container|native_sdwa_f16_hardware|native_f16_alu_hardware|native_sdwa_vcc_hi_hardware)$'

6/6 pass in Debug and in Release /O2, with no skips. native_sdwa_f16_hardware checked 74 results and 1,990 guards.

Negative control and mutants. Each mutant was rebuilt in dev and run against the six tests:

Mutant Result
both source files back to main killed: native_sdwa_f16_ir gets "unimplemented direct SDWA operand profile", native_sdwa_f16_hardware fails
carry result without place_subword killed (native_sdwa_f16_hardware, word 29: 0xffffffff vs 0xffff0000)
carry sources without subword() selection killed (native_sdwa_f16_hardware, word 34: 0x1 vs 0x0)
pkrtz result without place_subword killed (native_sdwa_f16_hardware, word 26: 0x3c00 vs 0x3c001357)
drop the pkrtz src_sel:DWORD refusal survives
drop the graphics refusal for the two profiles survives

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking.

  1. The pkrtz source-selection refusal isn't pinned. Without it, a WORD_0 source compiles and converts the whole f32 word. These refusals pass on this head and kill the mutant:
    ] + [
        (sdwa(PKRTZ, WORD_0, PAD, src0, src1), 'unsupported packed half conversion SDWA source selection')
        for src0, src1 in ((WORD_0, DWORD), (DWORD, WORD_1), (BYTE_1, DWORD))
    ]
    
  2. The graphics refusal isn't exercised either. No fixture compiles these SDWA forms in a vertex or pixel container.

Verdict: approve on 5a516752.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.26100, DXC 1.9.2602.17; Python 3.12.10; wave32. Debug-layer status was not checked.
CI: Build and test on Windows passes on 5a516752 (the pr preset doesn't include these tests).

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093789428 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3201#pullrequestreview-6093789428). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T22:04:29Z. **Review:** APPROVED --- Independently reviewed `5a516752` integrated over `main` `63fd6ea8` (tree `1a03639e`). The merge is clean and `git diff --cached --check` is clean. **What I traced.** - **Decoder.** `v_add_co_ci_u32` joins the integer SDWA profile, so sext is allowed and neg/abs (`control & 0x30`), clamp and omod are refused. `v_cvt_pkrtz_f16_f32` joins the fp-input profile, so abs/neg are allowed and sext is refused. Clamp and omod are refused for it too, because it is in neither `floats` nor `conversion`. Both are refused under `graphics`. - **Carry path.** Only `v_add_co_ci_u32` reaches `carry_destination()` with `i.subword` set: the other carry ops never pass the SDWA profile check. The operands are selected before the optional `v_subrev` swap. Carry-out and the VCC carry-in come from the full 32-bit sum of the selected operands. Only the VGPR result goes through `place_subword()`. - **pkrtz.** The existing abs/neg and RTZ packing is unchanged. The new refusal limits both sources to `src_sel:DWORD`, and the packed word is then placed per `dst_sel`/`dst_unused`. **What I ran.** I built `compile_dxil native_store_replay native_compute_ir_dump` in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_sdwa_f16_ir|native_f16_alu_ir|native_direct_container|native_sdwa_f16_hardware|native_f16_alu_hardware|native_sdwa_vcc_hi_hardware)$' ``` 6/6 pass in Debug and in Release `/O2`, with no skips. `native_sdwa_f16_hardware` checked 74 results and 1,990 guards. **Negative control and mutants.** Each mutant was rebuilt in `dev` and run against the six tests: | Mutant | Result | |---|---| | both source files back to `main` | killed: `native_sdwa_f16_ir` gets "unimplemented direct SDWA operand profile", `native_sdwa_f16_hardware` fails | | carry result without `place_subword` | killed (`native_sdwa_f16_hardware`, word 29: `0xffffffff` vs `0xffff0000`) | | carry sources without `subword()` selection | killed (`native_sdwa_f16_hardware`, word 34: `0x1` vs `0x0`) | | pkrtz result without `place_subword` | killed (`native_sdwa_f16_hardware`, word 26: `0x3c00` vs `0x3c001357`) | | drop the pkrtz `src_sel:DWORD` refusal | **survives** | | drop the `graphics` refusal for the two profiles | **survives** | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** 1. **The pkrtz source-selection refusal isn't pinned.** Without it, a `WORD_0` source compiles and converts the whole f32 word. These refusals pass on this head and kill the mutant: ```python ] + [ (sdwa(PKRTZ, WORD_0, PAD, src0, src1), 'unsupported packed half conversion SDWA source selection') for src0, src1 in ((WORD_0, DWORD), (DWORD, WORD_1), (BYTE_1, DWORD)) ] ``` 2. **The graphics refusal isn't exercised either.** No fixture compiles these SDWA forms in a vertex or pixel container. **Verdict:** approve on `5a516752`. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.26100, DXC 1.9.2602.17; Python 3.12.10; wave32. Debug-layer status was not checked. CI: `Build and test on Windows` passes on `5a516752` (the `pr` preset doesn't include these tests). This reply was 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!3201
No description provided.