compute: lower 64-bit integer VOPC compares in direct compute #3210

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

@⁠Leyukaka on GitHub · 2026-11-27 21:46 UTC · original
Leyukaka:vcmp-i64 → main · +202 −0 · 4 files · 1 commits · merged 2026-11-27 22:07 UTC

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

Change (src/gfx1013_direct_compute.inl): direct compute lowers v_cmp_{eq,ne,lt,le,gt,ge}_{i64,u64}, in the e32, e64 and v_cmpx forms.

  • Both sources are read as 64-bit values: an SGPR pair, a VGPR pair, or an inline constant. An inline constant is sign-extended to 64 bits for both i64 and u64.
  • The values are compared with an i64 icmp (signed or unsigned predicate), and the lane mask is written like the 32-bit compares. v_cmpx writes EXEC through the decoder's EXEC destination.
  • Refused:
    • a 32-bit literal source, because I could not establish its 64-bit extension;
    • source modifiers;
    • subword forms;
    • other special source registers.

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 cf3df832 plus this commit.

  • native_vopc_cmp64_hardware (new) runs 10 cases that together cover eq, ne, lt, le, gt and ge, signed and unsigned, and the e32, e64 and cmpx forms. Its sources are SGPR/VGPR pairs with nonzero high words (including a sign-bit-only difference) and inline -1. The masks, per-lane selects on VCC and guards are checked against a CPU reference.
  • It also checks that a literal source is refused.
  • native_direct_container and the native_salu_cmp64* tests pass.
  • Mutation checks, run by hand, each failing native_vopc_cmp64_hardware:
    • zero-extending inline constants for u64;
    • comparing signed as unsigned.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main 9e7eab5b.

  • 9 of 2,689 requests stopped first at "direct comparison width", all v_cmp_ne_i64_e32 vcc_lo, s[N:N+1], v[6:7] (s[10:11] in 7 of them, s[8:9] and s[12:13] in one each).
  • With this change, all 9 pass it. 6 stop at "direct descriptor address outside bound table" and 3 at "unbound numeric SGPR", so none of them compiles yet. The baseline was measured on 9e7eab5b and the change on cf3df832; the one extra compiled request between the two (405 to 406) comes from #3148, which sits between them.
  • No request that compiled before stops compiling. The requests of one start-up run give the same 9.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-27 21:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3208) `Leyukaka:vcmp-i64` → `main` · +202 −0 · 4 files · 1 commits · merged 2026-11-27 22:07 UTC Fixes #3209. Part of #2935. Target branch `main`. **Change** (`src/gfx1013_direct_compute.inl`): direct compute lowers `v_cmp_{eq,ne,lt,le,gt,ge}_{i64,u64}`, in the e32, e64 and `v_cmpx` forms. - Both sources are read as 64-bit values: an SGPR pair, a VGPR pair, or an inline constant. An inline constant is sign-extended to 64 bits for both i64 and u64. - The values are compared with an i64 `icmp` (signed or unsigned predicate), and the lane mask is written like the 32-bit compares. `v_cmpx` writes EXEC through the decoder's EXEC destination. - Refused: - a 32-bit literal source, because I could not establish its 64-bit extension; - source modifiers; - subword forms; - other special source registers. **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` `cf3df832` plus this commit. - `native_vopc_cmp64_hardware` (new) runs 10 cases that together cover eq, ne, lt, le, gt and ge, signed and unsigned, and the e32, e64 and cmpx forms. Its sources are SGPR/VGPR pairs with nonzero high words (including a sign-bit-only difference) and inline -1. The masks, per-lane selects on VCC and guards are checked against a CPU reference. - It also checks that a literal source is refused. - `native_direct_container` and the `native_salu_cmp64*` tests pass. - Mutation checks, run by hand, each failing `native_vopc_cmp64_hardware`: - zero-extending inline constants for u64; - comparing signed as unsigned. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `main` `9e7eab5b`. - 9 of 2,689 requests stopped first at "direct comparison width", all `v_cmp_ne_i64_e32 vcc_lo, s[N:N+1], v[6:7]` (s[10:11] in 7 of them, s[8:9] and s[12:13] in one each). - With this change, all 9 pass it. 6 stop at "direct descriptor address outside bound table" and 3 at "unbound numeric SGPR", so none of them compiles yet. The baseline was measured on `9e7eab5b` and the change on `cf3df832`; the one extra compiled request between the two (405 to 406) comes from #3148, which sits between them. - No request that compiled before stops compiling. The requests of one start-up run give the same 9. AI-assisted.
v_cmp_{eq,ne,lt,le,gt,ge}_{i64,u64} (e32, e64 and v_cmpx) were refused
as "direct comparison width". Both sources are now read as 64-bit values
(an SGPR pair, a VGPR pair, or an inline constant sign-extended to 64
bits for both i64 and u64) and compared with an i64 icmp; the lane mask
is written like the 32-bit compares. A 32-bit literal source stays
refused, as do source modifiers and subword forms.

native_vopc_cmp64_hardware covers eq/ne/lt/le/gt/ge, signed and
unsigned, e32, e64 and cmpx, SGPR/VGPR pairs and inline -1 against a CPU
reference, and checks that literal sources are refused.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:49:48 +00:00
github-bot changed target branch from main to gh-pr/3208/base 2026-11-27 22:10:31 +00:00
github manually merged commit 94e1d579d5 into gh-pr/3208/base 2026-11-27 22:10:34 +00:00
Author
Owner

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

I reviewed 94e1d579 merged over current main 5b5e36ee. The merge is clean (tree de82d908) and git diff --cached --check is clean.

What I traced.

  • Routing: the new block runs after float_alu and before the generic VOPC path, and only for names ending in _i64 or _u64 in compute. So the 32-bit and float compares are unchanged. v_cmp_f_i64 and v_cmp_t_i64 still refuse with the same message as on main ("direct comparison width").
  • Operands:
    • an even SGPR pair up to s[104:105], or a VGPR pair up to v[254:255], is read as zext(lo) | zext(hi) << 32;
    • inline integers 128 to 208 are sign-extended to 64 bits for both i64 and u64, which matches how RDNA treats inline constants on 64-bit operands;
    • everything else is refused, including a literal, vcc, exec, odd SGPRs, and DPP or SDWA (250 and 249 fall through to the operand refusal, or are caught as subword).
  • Predicates and mask: the predicates map to icmp eq/ne/slt/sle/sgt/sge or the u forms. The mask goes through write_ballot, as the 32-bit compares do, and v_cmpx gets EXEC as its destination from the decoder. ir.features |= 1048576 is the same Int64 flag the existing 64-bit paths set.

What I ran.

  • dev: full build, then

    ctest --test-dir out/build/dev --no-tests=error -j 4 -R '^(native_direct_container|native_salu_cmp64.*)$' -E '_hardware$'
    ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(native_vopc_cmp64|native_salu_cmp64.*)_hardware$'
    

    3/3 CPU tests (native_direct_container, native_salu_cmp64_controls, native_salu_cmp64_ir) and 2/2 hardware tests (native_vopc_cmp64_hardware, native_salu_cmp64_hardware) pass, with no skips.

  • release /O2: built compile_dxil, native_store_replay and native_compute_ir_dump, then ran the same five tests. 5/5 pass.

Mutants, each rebuilt in dev and run against native_vopc_cmp64_hardware (the unmutated baseline passes first):

Mutant Result
new block off (negative control: main's behaviour) killed
inline constant zero-extended killed
signed compared as unsigned killed
unsigned compared as signed killed
high word dropped killed
high word read from the low register killed
literal accepted, sign-extended killed
odd SGPR accepted as a pair base survives
abs/neg modifiers accepted survives

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

Non-blocking.

  1. Two refusals are not pinned. The odd-SGPR one is close to equivalent, because a valid program does not encode an odd base for a 64-bit operand. The modifier refusal matters more: accepting neg on an integer compare would silently ignore it. One e64 case with neg set in the refusal list would pin it.
  2. Operand positions. Every case puts the SGPR pair or the inline constant in src0 and a VGPR pair in src1. A VGPR pair in src0, or an SGPR pair in the e64 src1, goes through the same input lambda, so I expect no difference, but neither is exercised.

Verdict: approve on 94e1d579.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 94e1d579.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 22:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3208#pullrequestreview-6093801944) · **approved these changes** I reviewed `94e1d579` merged over current `main` `5b5e36ee`. The merge is clean (tree `de82d908`) and `git diff --cached --check` is clean. **What I traced.** - **Routing:** the new block runs after `float_alu` and before the generic VOPC path, and only for names ending in `_i64` or `_u64` in compute. So the 32-bit and float compares are unchanged. `v_cmp_f_i64` and `v_cmp_t_i64` still refuse with the same message as on `main` ("direct comparison width"). - **Operands:** - an even SGPR pair up to s[104:105], or a VGPR pair up to v[254:255], is read as `zext(lo) | zext(hi) << 32`; - inline integers 128 to 208 are sign-extended to 64 bits for both `i64` and `u64`, which matches how RDNA treats inline constants on 64-bit operands; - everything else is refused, including a literal, `vcc`, `exec`, odd SGPRs, and DPP or SDWA (250 and 249 fall through to the operand refusal, or are caught as `subword`). - **Predicates and mask:** the predicates map to `icmp eq/ne/slt/sle/sgt/sge` or the `u` forms. The mask goes through `write_ballot`, as the 32-bit compares do, and `v_cmpx` gets EXEC as its destination from the decoder. `ir.features |= 1048576` is the same Int64 flag the existing 64-bit paths set. **What I ran.** - **`dev`:** full build, then ```powershell ctest --test-dir out/build/dev --no-tests=error -j 4 -R '^(native_direct_container|native_salu_cmp64.*)$' -E '_hardware$' ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(native_vopc_cmp64|native_salu_cmp64.*)_hardware$' ``` 3/3 CPU tests (`native_direct_container`, `native_salu_cmp64_controls`, `native_salu_cmp64_ir`) and 2/2 hardware tests (`native_vopc_cmp64_hardware`, `native_salu_cmp64_hardware`) pass, with no skips. - **`release` `/O2`:** built `compile_dxil`, `native_store_replay` and `native_compute_ir_dump`, then ran the same five tests. 5/5 pass. **Mutants**, each rebuilt in `dev` and run against `native_vopc_cmp64_hardware` (the unmutated baseline passes first): | Mutant | Result | |---|---| | new block off (negative control: main's behaviour) | killed | | inline constant zero-extended | killed | | signed compared as unsigned | killed | | unsigned compared as signed | killed | | high word dropped | killed | | high word read from the low register | killed | | literal accepted, sign-extended | killed | | odd SGPR accepted as a pair base | **survives** | | abs/neg modifiers accepted | **survives** | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** 1. **Two refusals are not pinned.** The odd-SGPR one is close to equivalent, because a valid program does not encode an odd base for a 64-bit operand. The modifier refusal matters more: accepting `neg` on an integer compare would silently ignore it. One e64 case with `neg` set in the refusal list would pin it. 2. **Operand positions.** Every case puts the SGPR pair or the inline constant in `src0` and a VGPR pair in `src1`. A VGPR pair in `src0`, or an SGPR pair in the e64 `src1`, goes through the same `input` lambda, so I expect no difference, but neither is exercised. **Verdict:** approve on `94e1d579`. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `94e1d579`. This reply was AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No description provided.