Recompiler: implement S_QUADMASK_B32 and S_QUADMASK_B64 #1463

Closed
hajduzsolt wants to merge 1 commit from upstream-pr/1473 into main
hajduzsolt commented 2026-11-24 16:38:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T16:38:15Z.


What is in it

  • crates/xcl/src/gpu/recomp/emit.rs:
  • Implements s_quadmask_b32 in salu, computing an 8-bit quad mask from SSRC0 into SDST and setting SCC if non-zero.
  • Implements s_quadmask_b64 in salu64, packing low and high 8-bit quad masks into the low dword of the 64-bit SDST with the high dword cleared to 0 and SCC set if non-zero.
  • Adds quadmask branchless bit-compression helper in the HLSL preamble.
  • crates/xcl/src/gpu/recomp/tests.rs:
  • Adds scalar_quadmask_b32_and_b64 unit test verifying generated HLSL translation and DXC compilation.
  • Adds gpu_scalar_quadmask hardware execution test on AMD Radeon RX 9070 XT verifying zero masks, multi-quad bit patterns, full masks, 64-bit pair packing, and SCC flags.

Tested

  • Hardware: AMD Radeon RX 9070 XT 16GB, AMD Ryzen 7 9800X3D, Windows 11 x64, rustc 1.98.1, debug
  • cargo test --workspace -- --test-threads=2: passed
  • cargo test -p xcl --lib quadmask: 2 passed, 0 failed

Regression run

main:

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1679 (PresentX 1679)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14840 MB

PR:

xcl-smoke v1
commit: be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14842 MB

Not tested

  • RDNA3 / Wave32 fallback configurations.

AI use

  • Antigravity (Gemini) wrote the implementation and synthetic unit tests.
<!-- greyfinch-sync:ivall/xcl:issue:5476330508 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T16:38:15Z. --- **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: - Implements `s_quadmask_b32` in `salu`, computing an 8-bit quad mask from SSRC0 into SDST and setting SCC if non-zero. - Implements `s_quadmask_b64` in `salu64`, packing low and high 8-bit quad masks into the low dword of the 64-bit SDST with the high dword cleared to 0 and SCC set if non-zero. - Adds `quadmask` branchless bit-compression helper in the HLSL preamble. - `crates/xcl/src/gpu/recomp/tests.rs`: - Adds `scalar_quadmask_b32_and_b64` unit test verifying generated HLSL translation and DXC compilation. - Adds `gpu_scalar_quadmask` hardware execution test on AMD Radeon RX 9070 XT verifying zero masks, multi-quad bit patterns, full masks, 64-bit pair packing, and SCC flags. **Tested** - Hardware: AMD Radeon RX 9070 XT 16GB, AMD Ryzen 7 9800X3D, Windows 11 x64, rustc 1.98.1, debug - `cargo test --workspace -- --test-threads=2`: passed - `cargo test -p xcl --lib quadmask`: 2 passed, 0 failed **Regression run** main: ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1679 (PresentX 1679) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14840 MB ``` PR: ``` xcl-smoke v1 commit: be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14842 MB ``` **Not tested** - RDNA3 / Wave32 fallback configurations. **AI use** - Antigravity (Gemini) wrote the implementation and synthetic unit tests.
nnonno91 commented 2026-11-24 17:06:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-24T16:43:41Z.


Quad-mask results on native and split waves at be1fa02

Both new quad-mask tests passed on integrated AMD Radeon graphics and the RTX 5090. I also ran a temporary probe that compared both opcodes with a CPU implementation of AMD’s quad-mask rule. It checked each of the 64 single-bit positions plus six other masks, including zero, all ones, and a high-word-only pattern. The probe checked result bits, SCC, and clearing the upper destination dword for S_QUADMASK_B64.

Tested

  • Clean head be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e, Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, Radeon(TM) Graphics (32.0.21042.62), RTX 5090 (617.42), Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug/test profiles.
  • cargo test --locked -p xcl --lib quadmask -- --nocapture --test-threads=1 reported 2 passed, 0 failed on each adapter, with no skips.
  • The temporary probe_quadmask_all_input_bit_positions using the same Cargo test invocation passed 70 input patterns per mode. AMD ran wave32 and native wave64. NVIDIA ran wave32 and split wave64. All results matched the CPU reference.
  • cargo build --workspace --locked and cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output passed on the RTX 5090. Total 772 passed, 0 failed, 41 ignored. The count includes two no wave64 skips: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.

Not tested

  • Retail-title smoke runs, performance, or the original instructions on Xbox hardware. The GPU checks used shaders translated by XCL.

AI use

  • OpenAI Codex (GPT-6, exact model variant unavailable) ran the tests, wrote the temporary probe, and prepared this report.
<!-- greyfinch-sync:ivall/xcl:comment:7138114534 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1473#issuecomment-7138114534). Originally posted by [nnonno91](https://github.com/nnonno91) on 2026-11-24T16:43:41Z. --- ### Quad-mask results on native and split waves at `be1fa02` Both new quad-mask tests passed on integrated AMD Radeon graphics and the RTX 5090. I also ran a temporary probe that compared both opcodes with a CPU implementation of AMD’s quad-mask rule. It checked each of the 64 single-bit positions plus six other masks, including zero, all ones, and a high-word-only pattern. The probe checked result bits, SCC, and clearing the upper destination dword for `S_QUADMASK_B64`. **Tested** - Clean head `be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e`, Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, Radeon(TM) Graphics (32.0.21042.62), RTX 5090 (617.42), Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug/test profiles. - `cargo test --locked -p xcl --lib quadmask -- --nocapture --test-threads=1` reported **2 passed, 0 failed** on each adapter, with no skips. - The temporary `probe_quadmask_all_input_bit_positions` using the same Cargo test invocation passed **70 input patterns per mode**. AMD ran wave32 and native wave64. NVIDIA ran wave32 and split wave64. All results matched the CPU reference. - `cargo build --workspace --locked` and `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output` passed on the RTX 5090. Total **772 passed, 0 failed, 41 ignored**. The count includes two `no wave64` skips: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`. **Not tested** - Retail-title smoke runs, performance, or the original instructions on Xbox hardware. The GPU checks used shaders translated by XCL. **AI use** - OpenAI Codex (GPT-6, exact model variant unavailable) ran the tests, wrote the temporary probe, and prepared this report.
DavidM1911 commented 2026-11-24 19:07:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:11Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141289524 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7141289524). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:53:11Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
upipibi commented 2026-11-26 16:08:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:08:06Z.


NVIDIA test report for be1fa02: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base b7aa9f3.

  • cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 715 passed, 0 failed, 21 ignored; 2 SKIPPED (no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), neither a test this PR adds.
  • gpu::recomp::tests::gpu_scalar_quadmask and scalar_quadmask_b32_and_b64, each with --exact --test-threads=1 --nocapture, 3 runs: 3/3 passed each, 0 SKIPPED; DXC 1.8.2502.11 loaded, so the HLSL compile ran.
    Lib tests only; no title run.
    AI-assisted (Claude Code, Claude Opus 5.5).
<!-- greyfinch-sync:ivall/xcl:comment:7197227336 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7197227336). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T16:08:06Z. --- NVIDIA test report for `be1fa02`: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base `b7aa9f3`. - `cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4`: 715 passed, 0 failed, 21 ignored; 2 SKIPPED (`no wave64`: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), neither a test this PR adds. - `gpu::recomp::tests::gpu_scalar_quadmask` and `scalar_quadmask_b32_and_b64`, each with `--exact --test-threads=1 --nocapture`, 3 runs: 3/3 passed each, 0 SKIPPED; DXC 1.8.2502.11 loaded, so the HLSL compile ran. Lib tests only; no title run. AI-assisted (Claude Code, Claude Opus 5.5).
BBareth commented 2026-11-30 19:20:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:20:36Z.


merge-check claim
head: be1fa02b4d

<!-- greyfinch-sync:ivall/xcl:comment:7289236881 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7289236881). Originally posted by [BBareth](https://github.com/BBareth) on 2026-11-30T19:20:36Z. --- merge-check claim head: be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e
saintwolf commented 2026-11-30 19:27:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T19:27:12Z.


merge-check claim
head: be1fa02b4d

<!-- greyfinch-sync:ivall/xcl:comment:7289417038 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7289417038). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-30T19:27:12Z. --- merge-check claim head: be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e
BBareth commented 2026-11-30 19:40:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:40:28Z.


merge-check
base: ff0c364b3d
head: be1fa02b4d
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: gpu::recomp::tests::gpu_scalar_quadmask, which is this PR's own new test: called Result::unwrap() on an Err value: "s_quadmask_b32 s1, s10: SALU" at tests.rs:354. The other new test, scalar_quadmask_b32_and_b64 (translation to HLSL and a DXC compile), passed. The base alone, run in the same batch: 2888 passed, 1 failed, 51 ignored, 28 SKIPPED lines; its one failure, hle::d3d12x::pso_async::used_tests::emission_resolves_the_retained_recipe_after_title_address_reuse, passed in this merged run and in the six others of the batch, so it is intermittent on the base and not this PR's.
review: one blocking finding. The PR adds s_quadmask_b32 / s_quadmask_b64 to the HLSL emitter only (emit.rs), but on current main runner::run_code goes through the direct DXIL lowering, whose scalar arm does not know the two instructions and returns SALU (gpu/dxil/lower.rs, the fall-through of the SALU match). So the PR's GPU test fails on the merged tree, and a title program with S_QUADMASK would still be refused on the default path. The HLSL side itself reads correct: quadmask() gathers one bit per 4-bit group (0x0F00F010 -> 0x4A checked by hand), the 64-bit form puts the high half's 8 bits at bit 8 and writes 0 to the upper destination register, SCC is result != 0. Needed: the same two instructions in the direct DXIL lowering (or the GPU test pinned to the path that has them, with the limitation stated).
performance: none: two new match arms and one helper function in the generated HLSL prelude.
verdict: not yet: the PR's own GPU test gpu_scalar_quadmask fails on the merged tree (direct DXIL lowering refuses S_QUADMASK)
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.

<!-- greyfinch-sync:ivall/xcl:comment:7289763592 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7289763592). Originally posted by [BBareth](https://github.com/BBareth) on 2026-11-30T19:40:28Z. --- merge-check base: ff0c364b3de011c13ed45865480c21918a79ec89 head: be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: `gpu::recomp::tests::gpu_scalar_quadmask`, which is this PR's own new test: `called Result::unwrap() on an Err value: "s_quadmask_b32 s1, s10: SALU"` at `tests.rs:354`. The other new test, `scalar_quadmask_b32_and_b64` (translation to HLSL and a DXC compile), passed. The base alone, run in the same batch: 2888 passed, 1 failed, 51 ignored, 28 SKIPPED lines; its one failure, `hle::d3d12x::pso_async::used_tests::emission_resolves_the_retained_recipe_after_title_address_reuse`, passed in this merged run and in the six others of the batch, so it is intermittent on the base and not this PR's. review: one blocking finding. The PR adds `s_quadmask_b32` / `s_quadmask_b64` to the HLSL emitter only (`emit.rs`), but on current `main` `runner::run_code` goes through the direct DXIL lowering, whose scalar arm does not know the two instructions and returns `SALU` (`gpu/dxil/lower.rs`, the fall-through of the SALU match). So the PR's GPU test fails on the merged tree, and a title program with S_QUADMASK would still be refused on the default path. The HLSL side itself reads correct: `quadmask()` gathers one bit per 4-bit group (0x0F00F010 -> 0x4A checked by hand), the 64-bit form puts the high half's 8 bits at bit 8 and writes 0 to the upper destination register, SCC is result != 0. Needed: the same two instructions in the direct DXIL lowering (or the GPU test pinned to the path that has them, with the limitation stated). performance: none: two new match arms and one helper function in the generated HLSL prelude. verdict: not yet: the PR's own GPU test `gpu_scalar_quadmask` fails on the merged tree (direct DXIL lowering refuses S_QUADMASK) hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
saintwolf commented 2026-11-30 19:44:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T19:44:02Z.


merge-check
base: ff0c364b3d
head: be1fa02b4d
merge: clean (trial merge be601a0a87f30fecf6b2abd924a1e5549e23aedf; git diff --check clean; +59/-0 in crates/xcl/src/gpu/recomp/emit.rs and tests.rs)
build: cargo build --workspace -> ok (39 lib + 19 test warnings, all pre-existing; none from the changed lines)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored (base ff0c364b is 2889; the new scalar_quadmask_b32_and_b64 passes, the new gpu_scalar_quadmask fails); failing: gpu::recomp::tests::gpu_scalar_quadmask (the PR's new test; it does not exist on the base, so it cannot fail there). The same run with XCL_DIRECT_DXIL=0: 2890 passed, 1 failed, 51 ignored - both new tests pass there, and the single failure is offline_compute_pipeline_is_reused_by_a_second_process (crates/xcl/tests/gpu_compute_e2e.rs, a D3D12.X driver-cache e2e this PR does not touch; it fails on the base ff0c364b in the same environment with the same panic at the same line, and passes in the default-environment run above). SKIPPED: 27, the standard set for this card, in both runs.
review: (1) The PR's new GPU test fails in the default compute-backend configuration. With XCL_DIRECT_DXIL unset, compute kernels route to the direct DXIL backend by default (gpu/dxil/kernel.rs:46-62: 0 none, 1 compute, anything else (unset, all) both), and runner::run_code has no HLSL fallback by design (runner.rs:818-822, "an unsupported instruction is an error (no fallback)"). The direct backend's SALU tables (the 32-bit match at gpu/dxil/lower.rs:1486-1666 with catch-all err(d, "SALU") at lower.rs:1666, and the 64-bit table's catch-all at lower.rs:1921) have no s_quadmask_b32/b64, so the test's run_code returns Err("s_quadmask_b32 s1, s10: SALU") and the unwrap at tests.rs:354 panics. Measured on this card: default environment, gpu_scalar_quadmask FAILED (deterministic: three runs, targeted and full suite); with XCL_DIRECT_DXIL=0 it passes (1/1 targeted, ok in the full-suite run - see the tests line for that run's one pre-existing failure). The runtime is not affected: pso.rs falls back from the direct path to the HLSL path on a refusal (direct_fallback, pso.rs:1277-1283; the Err arm falls through to the HLSL translate at pso.rs:1466-1469), so a game kernel using S_QUADMASK works in the default environment through the logged fallback after this PR. The thread's reports (RTX 5090 + AMD iGPU: 2/2 on the new tests and 772/0/41 for the full suite; RTX 3070: 715/0/21 and the new tests 3/3 standalone) are green without mentioning XCL_DIRECT_DXIL; on this card, where the variable is unset, the GPU test passes only with XCL_DIRECT_DXIL=0. The sibling CPU test already omits direct_check() for the same reason (tests.rs:311-323). What is missing: the two ops in the direct backend's SALU tables (the per-quad any-lane-set fold the HLSL arm uses), or the test routed to the HLSL form when the direct backend refuses it (the routed_to_hlsl convention, tests.rs:79-83), or the GPU test restricted to the HLSL path. (2) The HLSL change itself is correct: quadmask() (emit.rs:6973) folds each 4-lane quad to one bit (m | m>>1 | m>>2 | m>>3, then & 0x11111111) and repacks the eight scattered quad bits down to bits 0-7 by staged shift-and; I hand-traced it against the AMD S_QUADMASK rule and recomputed the test vectors (0x0F00_F010 -> quads 1,3,6 -> 0x4A; 0x8765_4321 -> 0xFF; B64 (0x10, 0x800) -> (0x0402, 0) with the upper destination dword 0). The arms mirror the adjacent s_wqm_b32/s_wqm_b64 exactly (SCC = result != 0; for B64 the high word is 0 by construction, so scc = t0 != 0); the helper sits in the static preamble (always emitted, dead-code-eliminated, zero cost for programs that do not use the op); the encoder has both opcodes (rdna2_spec.rs:588-589, opcodes 44/45). With XCL_DIRECT_DXIL=0 the GPU test passes on this card with every result vector and SCC bit correct, and the CPU translate/DXC test passes in both configurations. (3) Dupe: open #814 (mastrr9, created 2026-11-24T05:48Z, 10h49m before this PR's 16:38Z, +51/-0 in the same two files, head 343bd2f3, MERGEABLE) implements the same two opcodes with the same quadmask helper and semantically the same arms, plus s_bitreplicate_b64_b32; it is not in the #3041 queue and in no #1607 group; if both land they collide in the same match arms, so one needs to drop the overlap. (4) Thread: nnonno91's temporary CPU-reference probe (each of the 64 single-bit positions plus six edge masks, result bits + SCC + B64 upper-dword clear, on AMD iGPU in wave32 and native wave64 and on the RTX 5090 in wave32 and split wave64, all matching), DavidM1911's lib all-pass on an RTX 3060 Ti with the branch merged into current main, upipibi's new tests 3/3 standalone on an RTX 3070.
performance: none meaningful: one scalar helper in the static preamble (dead-code-eliminated for programs that do not use the op) and two translator match arms; the runtime's default behavior is unchanged - a kernel that uses S_QUADMASK takes the existing, already-logged direct-to-HLSL fallback until the direct backend learns the op.
verdict: not yet: the PR's new GPU test fails in the default compute-backend configuration: with XCL_DIRECT_DXIL unset (the default), run_code routes to the direct DXIL backend, whose SALU tables lack S_QUADMASK_B32/B64, so the standard suite reports 1 failed on a GPU machine (with XCL_DIRECT_DXIL=0 both new tests pass, and the runtime handles the op through its existing direct-to-HLSL fallback). Add the two ops to the SALU tables in gpu/dxil/lower.rs, or route the test to the HLSL form.
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B

<!-- greyfinch-sync:ivall/xcl:comment:7289854741 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7289854741). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-30T19:44:02Z. --- merge-check base: ff0c364b3de011c13ed45865480c21918a79ec89 head: be1fa02b4d90d43cdcd9ad5dfb3d32e2c5e9973e merge: clean (trial merge be601a0a87f30fecf6b2abd924a1e5549e23aedf; git diff --check clean; +59/-0 in crates/xcl/src/gpu/recomp/emit.rs and tests.rs) build: cargo build --workspace -> ok (39 lib + 19 test warnings, all pre-existing; none from the changed lines) tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored (base ff0c364b is 2889; the new scalar_quadmask_b32_and_b64 passes, the new gpu_scalar_quadmask fails); failing: gpu::recomp::tests::gpu_scalar_quadmask (the PR's new test; it does not exist on the base, so it cannot fail there). The same run with XCL_DIRECT_DXIL=0: 2890 passed, 1 failed, 51 ignored - both new tests pass there, and the single failure is offline_compute_pipeline_is_reused_by_a_second_process (crates/xcl/tests/gpu_compute_e2e.rs, a D3D12.X driver-cache e2e this PR does not touch; it fails on the base ff0c364b in the same environment with the same panic at the same line, and passes in the default-environment run above). SKIPPED: 27, the standard set for this card, in both runs. review: (1) The PR's new GPU test fails in the default compute-backend configuration. With XCL_DIRECT_DXIL unset, compute kernels route to the direct DXIL backend by default (gpu/dxil/kernel.rs:46-62: `0` none, `1` compute, anything else (unset, `all`) both), and runner::run_code has no HLSL fallback by design (runner.rs:818-822, "an unsupported instruction is an error (no fallback)"). The direct backend's SALU tables (the 32-bit match at gpu/dxil/lower.rs:1486-1666 with catch-all `err(d, "SALU")` at lower.rs:1666, and the 64-bit table's catch-all at lower.rs:1921) have no s_quadmask_b32/b64, so the test's run_code returns Err("s_quadmask_b32 s1, s10: SALU") and the unwrap at tests.rs:354 panics. Measured on this card: default environment, gpu_scalar_quadmask FAILED (deterministic: three runs, targeted and full suite); with XCL_DIRECT_DXIL=0 it passes (1/1 targeted, ok in the full-suite run - see the tests line for that run's one pre-existing failure). The runtime is not affected: pso.rs falls back from the direct path to the HLSL path on a refusal (direct_fallback, pso.rs:1277-1283; the Err arm falls through to the HLSL translate at pso.rs:1466-1469), so a game kernel using S_QUADMASK works in the default environment through the logged fallback after this PR. The thread's reports (RTX 5090 + AMD iGPU: 2/2 on the new tests and 772/0/41 for the full suite; RTX 3070: 715/0/21 and the new tests 3/3 standalone) are green without mentioning XCL_DIRECT_DXIL; on this card, where the variable is unset, the GPU test passes only with XCL_DIRECT_DXIL=0. The sibling CPU test already omits direct_check() for the same reason (tests.rs:311-323). What is missing: the two ops in the direct backend's SALU tables (the per-quad any-lane-set fold the HLSL arm uses), or the test routed to the HLSL form when the direct backend refuses it (the routed_to_hlsl convention, tests.rs:79-83), or the GPU test restricted to the HLSL path. (2) The HLSL change itself is correct: quadmask() (emit.rs:6973) folds each 4-lane quad to one bit (m | m>>1 | m>>2 | m>>3, then & 0x11111111) and repacks the eight scattered quad bits down to bits 0-7 by staged shift-and; I hand-traced it against the AMD S_QUADMASK rule and recomputed the test vectors (0x0F00_F010 -> quads 1,3,6 -> 0x4A; 0x8765_4321 -> 0xFF; B64 (0x10, 0x800) -> (0x0402, 0) with the upper destination dword 0). The arms mirror the adjacent s_wqm_b32/s_wqm_b64 exactly (SCC = result != 0; for B64 the high word is 0 by construction, so scc = t0 != 0); the helper sits in the static preamble (always emitted, dead-code-eliminated, zero cost for programs that do not use the op); the encoder has both opcodes (rdna2_spec.rs:588-589, opcodes 44/45). With XCL_DIRECT_DXIL=0 the GPU test passes on this card with every result vector and SCC bit correct, and the CPU translate/DXC test passes in both configurations. (3) Dupe: open #814 (mastrr9, created 2026-11-24T05:48Z, 10h49m before this PR's 16:38Z, +51/-0 in the same two files, head 343bd2f3, MERGEABLE) implements the same two opcodes with the same quadmask helper and semantically the same arms, plus s_bitreplicate_b64_b32; it is not in the #3041 queue and in no #1607 group; if both land they collide in the same match arms, so one needs to drop the overlap. (4) Thread: nnonno91's temporary CPU-reference probe (each of the 64 single-bit positions plus six edge masks, result bits + SCC + B64 upper-dword clear, on AMD iGPU in wave32 and native wave64 and on the RTX 5090 in wave32 and split wave64, all matching), DavidM1911's lib all-pass on an RTX 3060 Ti with the branch merged into current main, upipibi's new tests 3/3 standalone on an RTX 3070. performance: none meaningful: one scalar helper in the static preamble (dead-code-eliminated for programs that do not use the op) and two translator match arms; the runtime's default behavior is unchanged - a kernel that uses S_QUADMASK takes the existing, already-logged direct-to-HLSL fallback until the direct backend learns the op. verdict: not yet: the PR's new GPU test fails in the default compute-backend configuration: with XCL_DIRECT_DXIL unset (the default), run_code routes to the direct DXIL backend, whose SALU tables lack S_QUADMASK_B32/B64, so the standard suite reports 1 failed on a GPU machine (with XCL_DIRECT_DXIL=0 both new tests pass, and the runtime handles the op through its existing direct-to-HLSL fallback). Add the two ops to the SALU tables in gpu/dxil/lower.rs, or route the test to the HLSL form. hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Foniass commented 2026-12-01 05:53:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:53:02Z.


Triage (#1607) – head be1fa02

#814 (opened earlier) adds the same quadmask() helper character for character, plus the same s_quadmask_b32 / s_quadmask_b64 arms in recomp/emit.rs. It also implements s_bitreplicate_b64_b32, with a translation test and a GPU test. The only difference here is the SCC expression for b64 (t0 != 0 instead of nz), which gives the same result because the high word is 0. This PR's GPU test values are correct (0x4A, 0xFF, 0x402) and could be added to #814.

Recommendation: close (duplicate of #814).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302239942 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7302239942). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:53:02Z. --- **Triage (#1607)** – head be1fa02 #814 (opened earlier) adds the same `quadmask()` helper character for character, plus the same `s_quadmask_b32` / `s_quadmask_b64` arms in `recomp/emit.rs`. It also implements `s_bitreplicate_b64_b32`, with a translation test and a GPU test. The only difference here is the SCC expression for b64 (`t0 != 0` instead of `nz`), which gives the same result because the high word is 0. This PR's GPU test values are correct (0x4A, 0xFF, 0x402) and could be added to #814. Recommendation: close (duplicate of #814). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 15:57:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T15:57:54Z.


Closing as superseded: the same change is in #814 (open, mergeable, required checks green). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7316809312 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1473#issuecomment-7316809312). Originally posted by [throny](https://github.com/throny) on 2026-12-01T15:57:54Z. --- Closing as superseded: the same change is in #814 (open, mergeable, required checks green). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5).

Pull request closed

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
xcl-dev/xcl!1463
No description provided.