compute: accept SDWA v_cvt_pkrtz_f16_f32 and v_add_co_ci_u32 #3203

Manually merged
github merged 1 commit from github-bot/gh-3201 into gh-pr/3201/base 2026-11-27 22:10:23 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-27 21:31 UTC · original
Leyukaka:sdwa-pkrtz-addc → main · +85 −14 · 4 files · 1 commits · merged 2026-11-27 22:05 UTC

Fixes #3185. 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.

**@⁠Leyukaka** on GitHub · 2026-11-27 21:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3201) `Leyukaka:sdwa-pkrtz-addc` → `main` · +85 −14 · 4 files · 1 commits · merged 2026-11-27 22:05 UTC Fixes #3185. 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.
Both ops already have direct lowerings but were missing from the SDWA
operand profiles, so their SDWA forms were refused. v_add_co_ci_u32 now
takes the SDWA source selections, writes its carry to VCC from the
selected operands like the VOP2 form, 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. Graphics, clamp and omod stay refused.

native_sdwa_f16_hardware reads back both ops in several destination
placements against a CPU reference, including the carry in VCC.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:37:04 +00:00
github-bot changed target branch from main to gh-pr/3201/base 2026-11-27 22:10:22 +00:00
github manually merged commit 5a5167520e into gh-pr/3201/base 2026-11-27 22:10:23 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 22:04 UTC · original · approved these changes

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.

**@⁠pigalot** on GitHub · 2026-11-27 22:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3201#pullrequestreview-6093789428) · **approved these changes** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.