Skip to content

cf_diff: s_bitcmp0/1 of a lane mask and s_cmpk_* in the FUZZ-8 fuzzer - #4947

Open
tunczzz wants to merge 12 commits into
ItsNotRexed:mainfrom
tunczzz:fuzz-8-bitcmp
Open

tunczzz wants to merge 12 commits into
ItsNotRexed:mainfrom
tunczzz:fuzz-8-bitcmp

Conversation

@tunczzz

@tunczzz tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

FUZZ-8 follow-up, claimed on #4683 (comment).

Depends on #4930, which sits at the end of the FUZZ-8 chain #615 → … → #4909 → #4930. Only the last commit, 992c082d, is new here.

s_bitcmp0/1 and s_cmpk_* set SCC, and the fuzzer never generated either. s_bitcmp on a lane mask is a wave-uniform question: is lane N set in VCC or EXEC? The translator answers it through a lane-mask path, Gen.bitcmp, which reads the whole mask, or one wave64 half via mask_half. The obvious slip there is reading the lane's own bit.

  • tools/cf_ref.py: s_bitcmp0/1_b32/b64 (bit S1 & 31, or & 63 for _b64, of S0, with masks read whole) and s_cmpk_<cc>_u32/i32 (SIMM16 zero-extended for u32, sign-extended for i32).
  • tools/cf_diff.py: bitcmp tests bit N of VCC (after a compare) or of EXEC, as the whole mask (_b64 in wave64) or one 32-bit half, then branches on s_cbranch_scc0/1. N is a constant or a uniform SGPR. scmpk is s_cmpk of a uniform SGPR against 16-bit immediates, including 0x8000 and 0xffff, then s_cbranch_scc0/1. An s_cmpk is 4 bytes whatever its immediate.
  • Docs: the docs/design.md row "Wave64 mask ballot" notes the fuzzer coverage, and docs/shader_validation.md lists the shapes.

No new findings. The translator agrees with the reference on all of these.

Tested (WSL Ubuntu, CPU):

  • tests/test_cf_diff.py + tests/test_cf_ref.py: 337 passed, 64 subtests.
    • BITCMP_CASES (wave32 and wave64, structured and dispatch loop) and BITCMP_W64_CASES (vcc_hi bit 4, i.e. lane 36; _b64 bits 4 and 40) match.
    • Every one of those cases mismatches when the translator's bitcmp treats the mask as data and reads the lane's own bit. That includes s_bitcmp1 exec, 5 inside an if that leaves lanes 4 and 20: bit 5 of EXEC is 0, but each running lane's own bit is 1.
    • SCMPK_CASES match, and a unit test pins the extension: -5 < sext(0xffff) holds as i32 and not as u32.
  • tools/cf_diff.py: seed 7170, 300 programs × wave32 and × wave64; seed 7171, 200 programs --depth 4 --dispatch-loop; seed 7172, 200 programs --depth 4 --spirv-val. Total 1,400 pass, 0 mismatch, 0 skipped, 0 harness errors.
  • Full pytest tests --ignore=tests/semantic -n 2: 7263 passed, 157 skipped, 7 failed. The 7 failures are the ones plain main has: test_joaat_agreement, fixed by find_hash_lookup: hash --hash names as latin-1, like hashdict (test_joaat_agreement fails on main) #4753, and test_rdna2_decode's llvm-mc parity test, claimed by MichaelL401. tests/semantic/test_spirv_wave_interp.py: 22 passed.

No GPU needed: this is a fuzzer/reference change. The PC has an RTX 5070 Ti, and nothing here runs on it. No game files.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@SphyserX

Copy link
Copy Markdown

Tested 992c082 on Arch Linux (in a VM), CPython 3.14, LLVM 23.1.5, SPIRV-Tools v2026.4: pass.

  • pytest tests/test_cf_diff.py tests/test_cf_ref.py: 337 passed, 64 subtests.
  • cf_diff.py --programs 300 --wave both --spirv-val with seeds 21-23: 1,800 pass, 0 mismatches, 0 skipped. Seed 24 with --dispatch-loop: 599 pass, 0 mismatches, 1 skipped (wave interp: step limit 2000000 reached). cf_diff: float compares and class tests into VCC and EXEC in the FUZZ-8 fuzzer #4930's head gives the same 599/1 result on that seed. The new shapes are present: of the first 60 programs of seed 21, 13 contain an s_bitcmp and 18 an s_cmpk_.
  • Code read of cf_ref.py: the bit index is masked with 31/63, a 64-bit source is read as a whole lane mask (anything else raises Unsupported), and SIMM16 is zero-extended for _u32 and sign-extended for _i32. All of that matches the RDNA2 SOPC/SOPK definitions.

Only the last commit was reviewed; the rest is #4930 and earlier.

@tupacfan04

Copy link
Copy Markdown
Contributor

Approve; no correctness defect found.

337 passed / 64 subtests, plus semantic wave-interp + test_run_gpu_tests 63 passed, lane_masks/crosslane/bitcmp/control-flow 133 passed / 2 skipped, docs tests OK, compileall/git diff --check clean, merge clean. Fuzzer smoke 80/80. The reference arithmetic matches the ISA: S1&31/&63, mask read whole or mask_half, s_cmpk zero-/sign-extended (the test pins -5 < sext(0xffff) as i32 only), 4-byte encoding. Negative controls: monkeypatching per-lane bitcmp and a low-word-only b64 reference both fail the expected cases. GPU skipped (no cmake in PATH and no prebuilt vk_compute_test); the PR is CPU-only and those shaders come from the #4930 stack.

Two coverage notes:

  • tools/cf_diff.py:180-186 never emits a whole-mask _b32 in wave64, so cf_ref.py:356's b32-mask-in-wave64 path is unexercised.
  • tools/cf_ref.py:350-356 rejects _b64 immediates/VGPRs that the translator handles (rdna2spirv.py:1638).

Sequencing: head 992c082d touches 5 files, and its diff vs main includes the unmerged #4930 chain (merge-base 98fa503f). Mergeable, but land after that stack.

AI-assisted review, no game files, no GPU.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at \992c082d. Tested on Windows 11:

  • \pytest tests/test_cf_diff.py -v\ -> 304 passed in 15.93s.
  • \python -m unittest tests/test_docs_design_rows.py\ -> 4 passed, OK.
  • \git diff --check\ clean.

The reference additions correctly model uniform \s_bitcmp0/1\ on whole masks and \s_cmpk_*\ sign/zero extension, with full generator and minimizer test coverage. Approve.

@Atomic258

Copy link
Copy Markdown
Contributor

Independent CPU check of 992c082d — pass on the Python side; GPU fixtures not run.

Environment: Windows 11, CPython 3.15.2 + pytest 9.2.0 venv, CPU only. Synthetic inputs, no game files, no GPU.

  • python -I -m unittest discover -s tests/semantic -p test_spirv_wave_interp.py → 22/22
  • pytest tests/test_cf_diff.py → 304 passed
  • pytest tests/test_cf_ref.py → 33 passed + 64 subtests
  • Negative control: semantic tests against main's spirv_wave_interp.py → 1 error (UnsupportedConstruct: OpIsNan %bool — the new op coverage isn't in the old evaluator), so the tests pin the addition
  • compileall clean, git diff --check main...HEAD clean

Not run: the two new .asm GPU fixtures (cs_scc_mask32, cs_w64_exec_half) — they need a runtime build plus llvm-mc-assembled SPIR-V; deferred to keep this check light. The check.py registration and run_gpu_tests.py filter wiring read correctly in the diff.

AI-assisted (Devin).

@theswiss24

Copy link
Copy Markdown

GPU run of 992c082d on an NVIDIA GeForce RTX 2060 SUPER (580.178.04, Ubuntu 24.04), to add to the CPU checks above. Full scripts/run_gpu_tests.py with LEONIDA_W64_EMULATE=1, PR merged onto main 3faac557, compared with main at the same commit and test programs built from it.

Result: pass.

main PR
RTX 2060 SUPER 201/217 passed, 16 skipped 203/219 passed, 16 skipped

The two extra fixtures, cs_scc_mask32 and cs_w64_exec_half, pass; every other test has the same result as on main.

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

@XFlawless1

Copy link
Copy Markdown
Contributor

Tested 992c082d on Windows 11 Pro 26300 with both GPUs of one machine: pass. This adds the AMD native-wave64 run of the two new fixtures, which the RTX 2060 run above couldn't give.

  • GPUs: AMD Radeon iGPU of a Ryzen 7 9800X3D (RDNA2, gfx1036, driver 32.0.21042.62, subgroup 32..64) and NVIDIA RTX 5080 (621.14, subgroup 32).
  • Tools: Vulkan SDK 1.4.363.0, llvm-mc 21.1.8.
  • Build: the PR head as-is (git merge-tree onto main 3faac557 is clean); it changes no C++, so the test programs are from main 3faac557.
  • Device check: each GPU selected with LEONIDA_VK_DEVICE and confirmed from vk_compute_test's device: line.

scripts/run_gpu_tests.py --filter <fixture>:

fixture Radeon native Radeon LEONIDA_W64_EMULATE=1 RTX 5080 native RTX 5080 LEONIDA_W64_EMULATE=1
cs_scc_mask32 (wave32) PASS 7 0 0 9 11 13 7 13 PASS PASS PASS
cs_w64_exec_half (wave64) PASS 1 0 1 1 0 3 9 9 (real 64-wide subgroup) PASS SKIP (no 64-wide subgroup) PASS

The expected words in check.py / run_gpu_tests.py are the same in both files. I also read the diff of the two scripts: it only adds the fixtures to the existing lists. Synthetic fixtures only, no game files.

AI-assisted (Claude Code).

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 992c082 on AMD Radeon 610M (RADV RAPHAEL_MENDOCINO, subgroup 32..64, native wave64), CachyOS Linux, LEONIDA_VK_DEVICE=RADV: the two new GPU fixtures pass.

  • scripts/run_gpu_tests.py --filter cs_w64_exec_half: 1 translated, 1 pass spirv-val; PASS cs_w64_exec_half 1 0 1 1 0 3 9 9; 1/1 passed.
  • scripts/run_gpu_tests.py --filter cs_scc_mask32: 1 translated, 1 pass spirv-val; PASS cs_scc_mask32 7 0 0 9 11 13 7 13; 1/1 passed.
  • Both with LEONIDA_VK_DEVICE=NoSuchDevice fail with "no Vulkan physical device matches", so the RADV device ran them.

AI-assisted.

@KkelebekK

Copy link
Copy Markdown

Tested 992c082 on AMD Radeon 780M (RADV PHOENIX, gfx1103 / RDNA3, Mesa 26.2.6, subgroup 32..64) and NVIDIA GeForce RTX 4070 Laptop (620.70.06, subgroup 32..32), Linux (CachyOS, kernel 7.3.4): pass.

Merge-base 98fa503f; the PR merges cleanly into main 3faac557 (git merge-tree). It changes no C++ or CMake file and stacks on the earlier FUZZ-8 PRs (the diff against the merge-base includes cs_scc_mask32 and cs_w64_exec_half, and tools/rdna2spirv.py is not touched), so the test programs come from an existing build of main af70fc78 (same Vulkan harness sources; the only runtime differences are in the xgameruntime shims and their CMake entries).

  • scripts/run_gpu_tests.py full suite, 219 cases, no FAIL. 780M: 204 passed, 15 skipped (merge-base: 202/217, 15). 4070 plain: 171 passed, 48 skipped (170/217, 47). 4070 with LEONIDA_W64_EMULATE=1: 203 passed, 16 skipped (201/217, 16). Per-test, the only differences from the merge-base are the two new rows.
  • --filter cs_scc_mask32: PASS 7 0 0 9 11 13 7 13 on the 780M, the 4070 and the 4070 emulated. --filter cs_w64_exec_half: PASS 1 0 1 1 0 3 9 9 on the 780M and the emulated 4070; SKIP "no 64-wide compute subgroup on this device" on the plain 4070. Both fixtures pass with the translator unchanged, so they pin existing behaviour; I did not find a red-before case for them.
  • tests/test_cf_diff.py, tests/test_cf_ref.py, tests/test_run_gpu_tests.py: 378 passed, 113 subtests; tests/semantic/test_spirv_wave_interp.py: 22 OK.
  • tools/cf_diff.py --programs 300 --wave both --spirv-val: seeds 21, 22, 23, 31, 32: 600 pass each, 0 mismatches, 0 skipped. Seed 24 with --dispatch-loop: 599 pass, 0 mismatches, 1 skipped (wave interp: step limit 2000000 reached).
  • Independent encoding check with llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1036 -show-inst -show-encoding, since the reference model and the fuzzer's emitter agree with each other by construction: s_cmpk_lt_i32 s0, 0xffff / s_cmpk_lt_u32 s0, 0xffff assemble to SIMM16 0xffff with different opcodes (0xb3 / 0xb6), -5 to 0xfffb, and s_cmpk_* take a 16-bit immediate, so the model's & 0xFFFF then sign-extension for _i32 only is consistent with the encoding. s_bitcmp0/1_b32 take an inline constant up to 64 (33, 64 encode as inline constants), and _b64 takes exec, vcc and an SGPR pair as the first operand. This confirms operands and encodings only. The & 31 / & 63 masking of the bit index and the sign/zero extension are ISA semantics that llvm-mc does not show, and no fixture here drives an index above 31 on hardware, so I did not verify those on a GPU.

Synthetic inputs only, no game data. AI-assisted.

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto #4930's review fix (9d07681e); this PR's commit is now eb0f7431 (force-pushed), with no change of its own. Thanks @KkelebekK, @gertify, @XFlawless1 and others for the runs. The rerun on this head: tests/test_cf_diff.py + test_cf_ref.py 306 passed; cf_diff.py seeds 8180–8182, 1,400 programs, 0 mismatch, 0 skipped. The full suite has only main's 7 known failures. CPU only (WSL); RTX 5070 Ti not used. AI-assisted (Claude Code).

@lunarminus

Copy link
Copy Markdown

Tested eb0f7431 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • What was tested: d0835dd9 is an ancestor of this PR's merge-base 98fa503f, so the merge fast-forwarded and the tree tested is eb0f7431 itself. That tree changes runtime C++ (shims, src and tests) compared with d0835dd9, so I rebuilt the Linux Vulkan test tools of runtime/ from it (RelWithDebInfo). This is the rebased head; the earlier GPU runs above were on 992c082d.
  • CPU tests:
    • pytest tests/test_cf_diff.py tests/test_cf_ref.py tests/test_run_gpu_tests.py: 383 passed, 113 subtests.
    • tests/semantic/test_spirv_wave_interp.py: 22 OK.
    • tools/cf_diff.py --programs 200 --seed 4947 --wave both --spirv-val: 400 pass, 0 mismatch, 0 skipped, 0 harness errors.
  • Full scripts/run_gpu_tests.py:
    • Native: 204/219 passed, 15 skipped, no FAIL.
    • LEONIDA_W64_EMULATE=1: 204/219 passed, 15 skipped, no FAIL.
  • Per-test comparison with main d0835dd9 without the PR (196/210, 14 skipped, both modes):
    • No test changes result and none is missing.
    • The new rows are cs_scc_mask32 PASS and cs_w64_exec_half PASS. The rest came in with main after d0835dd9: cs_smem_sconst_off, ps_far_branch, ps_sample_c, ps_sample_c_b, ps_texture_cl and ps_texture_b_cl PASS, ps_m2_literal SKIP.
  • Per-test comparison with the merge-base 98fa503f (earlier run on this machine, 202/217, 15 skipped): no test changes result in either mode, and the only new rows are this PR's two fixtures, both PASS.
  • --filter runs of each fixture, native and emulated:
    • cs_scc_mask32: PASS 7 0 0 9 11 13 7 13 in both modes.
    • cs_w64_exec_half: PASS 1 0 1 1 0 3 9 9 in both modes, native one on the 760M's 64-wide subgroup.
    • Both match the earlier 780M / 610M / gfx1036 reports.

Synthetic fixtures only, no game files.

AI-assisted (Claude Code).

@KkelebekK

Copy link
Copy Markdown

Tested eb0f7431 on AMD Radeon 780M (RADV PHOENIX, gfx1103 / RDNA3, Mesa 26.2.6, subgroup 32..64) and NVIDIA GeForce RTX 4070 Laptop (620.70.06, subgroup 32..32), Linux (CachyOS, kernel 7.3.4): pass

This retests the rebased head. My earlier run was on 992c082d. The range-diff against that head is one new commit underneath, #4930's 9d07681e (the fvalue bit layout and class mask 0), and this PR's own commit is unchanged apart from that. Merge-base 98fa503f; the head merges cleanly into current main 3faac557 (git merge-tree). Between 98fa503f and 3faac557 only the xgameruntime shims, their tests and CMake entries change, so the Vulkan test programs are built from 3faac557 (RelWithDebInfo). main 3faac557 runs the same GPU suite as the merge-base. Each GPU was picked with LEONIDA_VK_DEVICE and confirmed from the device: line.

  • Full scripts/run_gpu_tests.py, head vs main 3faac557. Per test, the only differences are the two new rows; no other test changes result:
    • 780M native: 204/219 passed, 15 skipped (main: 202/217, 15).
    • 780M LEONIDA_W64_EMULATE=1: 204/219, 15 skipped (main: 202/217, 15).
    • 4070 native: 171/219, 48 skipped (main: 170/217, 47).
    • 4070 LEONIDA_W64_EMULATE=1: 203/219, 16 skipped (main: 201/217, 16).
  • New fixtures, from those runs:
    • cs_scc_mask32: PASS 7 0 0 9 11 13 7 13 in all four runs.
    • cs_w64_exec_half: PASS 1 0 1 1 0 3 9 9 on the 780M (native wave64 and emulated) and on the 4070 emulated. SKIP on the plain 4070 ("no 64-wide compute subgroup on this device").
    • The words are the same as on 992c082d. Both fixtures pass with main's translator, so they pin existing behaviour; there is no red-before case on the GPU.
  • CPU, at the head:
    • tests/test_cf_diff.py + test_cf_ref.py + test_run_gpu_tests.py: 383 passed, 113 subtests.
    • tests/semantic/test_spirv_wave_interp.py: 22 OK.
  • Negative control for the new fuzzer change: the head's tests with 992c082d's tools/cf_diff.py (the old fvalue) give 1 failed, 341 passed. The failure is test_fvalue_covers_every_class_in_one_wave32, so that test pins 9d07681e.
  • tools/cf_diff.py at the head, 0 mismatches and 0 harness errors throughout:

Not verified: the fuzzer is CPU-only (reference vs the translator through the SPIR-V wave interpreter), so its new s_bitcmp/s_cmpk shapes and the wider float classes didn't run on either GPU. Also not covered: a bit index above 31 on hardware, and @tupacfan04's two coverage notes (whole-mask _b32 in wave64, _b64 immediate/VGPR sources).

Synthetic inputs only, no game data. AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested eb0f743 on Windows Server 2022, CPython 3.13.12: pass

  • pytest tests/test_cf_diff.py -> 309 passed; python -I -m unittest discover -s tests/semantic -p "test_spirv_wave_interp.py" -> OK
  • Negative control (cf_diff.py + cf_ref.py swapped to upstream/main): collection errors - differentiates

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

tunczzz and others added 7 commits November 23, 2026 11:54
…_mask32 GPU test

The translator side of this PR (s_not_b32 on a wave32 lane mask votes its
SCC) landed on main through ItsNotRexed#3225 (SweatierKey), so the branch now keeps
main's tools/rdna2spirv.py and adds the checks around it:

- tools/cf_ref.py models s_not_b32/b64; tools/cf_diff.py generates s_not
  in the sccmask/csel shapes; tests/test_cf_diff.py has the two s_not
  regression cases (they fail with the old per-lane SCC).
- runtime/test/shaders/cs_scc_mask32.asm: @kotorvr's compute test for
  s_and + s_cselect, s_andn2 + s_cbranch_scc1, s_not, s_or, s_xnor,
  registered as a wave32 dump in check.py and run_gpu_tests.py (skipped
  below 32 lanes).
- docs/design.md: s_not_b32 in the rule, the GPU results and @kotorvr's
  corpus count.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alf GPU test

The translator side of this PR (wave64 32-bit ops on one half of EXEC/VCC:
exec_lo writes and the half's SCC vote) landed on main through ItsNotRexed#3225
(SweatierKey), so the branch now keeps main's tools/rdna2spirv.py. The
new shapes below pass on it; they found both bugs on the translator
before ItsNotRexed#3225:

- A register written to exec_lo set all 64 lanes, and any op but
  s_mov_b32 into exec_hi was rejected ("destination exec_hi").
- The SCC of a 32-bit op on one half of a mask took the lane's own bit.

Fuzzer: cf_ref treats every _b32 op as a 32-bit word op (halves
included) and models s_cmp_eq/lg_u64 and s_cselect_b64; cf_diff adds
e64 compares into SGPR masks (saveexec, v_cndmask), constant EXEC,
half-EXEC ops, half-mask SCC, s_cmp on masks and s_cselect between
masks, and counts literals in instruction sizes. GPU test
cs_w64_exec_half (wave64 dump; expected 1 0 1 1 0 3 9 9).

Depends on: ItsNotRexed#615

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two loop shapes: per-lane trip counts closed by s_cbranch_vccnz (the
wave loops while any lane wants to, EXEC unchanged), and loops that drop
finished lanes with v_cmpx and close on s_cbranch_execnz. cf_ref models
s_andn1/andn2_wrexec (EXEC = ~S0 & EXEC / S0 & ~EXEC, D = EXEC, SCC).

No new findings: 2,600 cases with the loop shapes (structured, dispatch
loop, depth 4) and s_andn2_wrexec in both wave sizes and forms match.
s_andn1_wrexec and the xor/orn2/nand/nor/xnor/andn1/orn1 saveexec forms
are not translated (Unsupported); every corpus shader translates, so the
game does not use them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two new program shapes cover translator rules the fuzzer did not reach:

- mread: s_bcnt1 / s_ff1 of EXEC, VCC or an SGPR compare mask into a
  uniform SGPR (wave64: _b64, or _b32 on one half), added to every
  active lane, optionally followed by s_cmp on it and a branch.
- waterfall: v_readfirstlane of a lane value -> v_cmp_eq ->
  s_and_saveexec -> body -> s_xor exec, closed by s_cbranch_execnz or
  by the SCC of the s_xor (the descriptor-per-group-of-lanes loop).

cf_ref models v_readfirstlane_b32 (lowest active lane, lane 0 when
none), s_bcnt1_i32_b32/b64 (SCC = count != 0) and s_ff1_i32_b32/b64
(-1 when no bit is set); a _b32 form reads one 32-bit word, one half of
the mask in wave64.

Both shapes are sensitive: with v_readfirstlane read per lane (the
pre-2026-11-21 translation) or s_bcnt1 counting the lane's own bit,
seed 3 gives 5 and 4 mismatches of 120. Waterfalls take v1/v2/v3
(8 or 16 distinct values); v8 (one value per lane) nested inside other
loops ran past the wave interpreter's step limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `wqm` shape: s_wqm of EXEC after narrowing it to a compare, or of VCC
into EXEC, around a body [-> s_cbranch_execz / scc0 / scc1], with EXEC
restored by s_mov; or s_wqm of a compare into an SGPR feeding an SCC
branch (SCC = some quad has a lane on). Wave64 also gets the _b32 form on
one half. Nested inside a divergent if, it turns quad-mates the if had
turned off back on, which the translator must do through %active.

- cf_ref: s_wqm_b32/b64 (each 4-bit group all ones when any bit of it is
  set; SCC = D != 0; a _b32 form is one 32-bit word).
- spirv_wave_interp: OpGroupNonUniformQuadSwap (direction 0/1/2 reads
  lane ^ 1 / ^ 2 / ^ 3) and QuadBroadcast (lane 4n + index); the
  translator's WQM path in fragment shaders uses QuadSwap.

With s_wqm put back to the identity it was before SHADER-34, 12 of the
38 generated WQM programs of seed 3 mismatch; test_whole_quad_mode_cases_
catch_an_identity_wqm pins one of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uzzer

A `lanes` shape at any nesting depth: v_readlane_b32 of a data VGPR
(added to every active lane) or v_writelane_b32 into one (v8/v9 are
preferred, since they go straight to the export), with a constant lane
(also past the wave, which wraps: S1[4:0] in wave32, S1[5:0] in wave64)
or an SGPR lane. Both ignore EXEC, so a lane an enclosing if or loop
turned off is still read and written. cf_ref models both ops.

With writelane changed to honour EXEC (a planted bug, not committed),
the LANE_CASES mismatch in wave32 and wave64 and seed 7 gives 6 of 600
mismatches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tsNotRexed#4134)

- test_cf_diff: the wrap case writes lane 100 (lane 4 in wave32, lane 36
  in wave64) from s11 (5); lane 84 was lane 20 in both waves, and s12 is
  0 like the v9 it overwrote, so the write wasn't observable. With the
  wave64 writelane masked by 31 the case now mismatches in both forms.
- test_cf_ref: a wave64 test pins lane 45 read while off and lane
  100 & 63 = 36 written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tunczzz and others added 5 commits November 23, 2026 11:55
A `far` shape: s_getpc_b64 -> s_add_u32 K -> s_addc_u32 0 -> s_setpc_b64
jumping forward over a block that never runs, or as the back edge of a
uniform counter loop (s_sub_u32 K / s_subb_u32 0, or s_add_u32 -K /
s_addc_u32 -1), at any nesting depth. The emitter resolves K from label
positions at assembly time (the s_add/sub literal always takes 4 bytes),
and s[2:3] is the scratch pair. This runs the translator's
fold_far_branches in context; ItsNotRexed#2697 GPU-tests the idiom by itself.

cf_ref: s_getpc_b64 (byte address of the next instruction, code at 0),
s_setpc_b64, s_addc_u32 and s_subb_u32 (carry / borrow through SCC).

With the s_sub_u32 form read as +K in the fold, the loop case mismatches
(test_far_branch_cases_catch_a_lost_sign); with the s_addc_u32 -1 high
word ignored, the translator rejects the target as outside the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e FUZZ-8 fuzzer

The translator has handled every saveexec kind and both wrexec forms since
6cfcf7c, and cf_ref models them, but the fuzzer generated neither wrexec
form and never drew andn1/orn1 for its saveexec shape.

- wrelse: s_and_saveexec -> then -> s_andn2_wrexec D, save (EXEC = save &
  ~EXEC, the else lanes) -> [s_cbranch_execz/scc0] -> else -> s_mov exec.
- wrloop: per-lane trip counts closed by s_andn1_wrexec D, vcc (EXEC =
  ~done & EXEC), back edge s_cbranch_scc1 or s_cbranch_execnz.
- saveexec draws andn1 and orn1 too.
D is the sccmask scratch SGPR (nothing reads it).

Tests: WREXEC_CASES in tests/test_cf_diff.py (wave32/64, structured and
dispatch loop) match, and each mismatches with andn1/andn2 and orn1/orn2
swapped in the translator's EXEC_LOGIC. No new findings: 1,700 programs
(seeds 5150-5152, depth 3-4, dispatch loop, spirv-val), 0 mismatch.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-8 fuzzer

The fuzzer drove EXEC/VCC with integer compares only. Compilers also
branch on float conditions (NaN guards, discard tests), and the
translator maps all 16 f32 conditions to OpFOrd*/OpFUnord*/OpIsNan and
v_cmp(x)_class_f32 to class tests.

- cf_ref: IEEE f32 compares (ordered forms false and n forms true on a
  NaN, o/u, f/tru, -0 == +0) and the 10 class bits.
- cf_diff: fif (v_cmp_<cc>_f32 / v_cmp_class_f32 -> s_and_saveexec) and
  fcmpx (v_cmpx_...) on a per-lane f32 built in v12 from a data VGPR:
  +-1.0..1.875, +-0, +-inf or a NaN, never a denormal (so denorm mode
  does not matter), against float constants, specials or a class mask.
- spirv_wave_interp: OpIsNan / OpIsInf on floats.

Tests: FCMP_CASES (15 cases, wave32/64, structured and dispatch loop)
match; they mismatch with ordered and unordered swapped on NaN lanes,
and the class cases with the sign ignored; unit tests pin _fcmp and
_fclass. No new findings: 1,400 programs (seeds 6160-6162, depth 3-4,
dispatch loop, spirv-val), 0 mismatch, 0 skipped.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of ItsNotRexed#4930 (tupacfan04): fvalue took the specials from bits 4-5 and
the sign from bit 3 of the source, and no wave32 source reaches bit 5,
so wave32 never compared against +-inf or +-0 (only NaNs and normals).
The mantissa now comes from bits 0-1, the specials from bits 2-3 and
the sign from bit 4: one 32-lane wave of v8 (9 ^ lane) holds every
value. The class mask can also be 0 (never true).

test_fvalue_covers_every_class_in_one_wave32 checks it in the
reference: with the old bits, wave32 saw qNaN, -normal and +normal
only. FCMP_CASES gains a mask-0 class case.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
s_bitcmp on EXEC/VCC is a wave-uniform test of one lane's bit, and the
translator has a lane-mask path for it (whole mask, or one wave64 half
via mask_half). s_cmpk_* compares against a zero- or sign-extended
16-bit immediate. Neither was generated by the fuzzer.

- cf_ref: s_bitcmp0/1_b32/b64 (bit S1 & 31 / & 63 of S0, masks read
  whole) and s_cmpk_<cc>_u32/i32.
- cf_diff: bitcmp (bit N, a constant or a uniform SGPR, of VCC after a
  compare or of EXEC; _b64 or one half in wave64 -> s_cbranch_scc0/1)
  and scmpk (s_cmpk of a uniform SGPR -> s_cbranch_scc0/1). s_cmpk is
  4 bytes whatever its immediate.

Tests: BITCMP_CASES / BITCMP_W64_CASES match in both forms and mismatch
when the translator's bitcmp reads the lane's own mask bit; SCMPK_CASES
match; the reference's s_cmpk extension is pinned (-5 < sext(0xffff)
as i32, not as u32). No new findings: 1,400 programs (seeds 7170-7172,
depth 3-4, dispatch loop, spirv-val), 0 mismatch, 0 skipped.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased the FUZZ-8 stack onto main 561b65a8 (main's large merge had made every PR in the stack conflict). This PR's commit is now 8811c2b2 (force-pushed). No conflicts.

Tests (WSL Ubuntu, llvm-mc 21, CPU only; the PC's RTX 5070 Ti not used): on #615's head, tests/test_cf_diff.py + test_cf_ref.py + test_run_gpu_tests.py give 121 passed, 148 subtests. On the stack tip 8811c2b2 (#4947) the same three give 393 passed, tests/semantic/test_spirv_wave_interp.py 23 passed, and tools/cf_diff.py seeds 9180–9182 give 1,400 programs (wave32 and wave64, depth 3/4, dispatch loop, --spirv-val) with 0 mismatch and 0 skipped. The full pytest tests --ignore=tests/semantic -n 2 on the tip has 7 failures, the same 7 plain main 561b65a8 has: test_joaat_agreement (fixed by #4753) and test_rdna2_decode's llvm-mc parity test. AI-assisted (Claude Code).

@nullmarsh

Copy link
Copy Markdown

Tested 8811c2b2, the rebased FUZZ-8 tip (12 commits on main 561b65a8), natively on Windows 11 26200 with an AMD Radeon RX 9060 XT (RDNA4, AMD 26.11.2 / 32.0.32029.2010, subgroups 32..64), MSVC 14.44 RelWithDebInfo: pass. This is the first GPU run since the 12:08 rebase.

  • scripts/run_gpu_tests.py: 218/234 passed, 16 skipped. cs_scc_mask32 (7 0 0 9 11 13 7 13) and cs_w64_exec_half (1 0 1 1 0 3 9 9) pass. Every other test has the same verdict as main 561b65a8 on this card (216/232, the same 16 skips). No test changed state.
  • pytest tests/test_cf_diff.py tests/test_cf_ref.py tests/test_run_gpu_tests.py tests/semantic/test_spirv_wave_interp.py: 415 passed, 174 subtests passed, 1 failed. The failure is test_no_arguments_prints_usage timing out (5 s), and it isn't from this stack:

Synthetic tests only, no game files. AI-assisted (Claude Code).

@IxMxAMAR

Copy link
Copy Markdown

Tested 8811c2b on Windows 11 Pro 26200: pass, no regressions. AMD Radeon RX 9070 XT (AMD 26.11.2, Vulkan 1.4.359, subgroup 32..64, native wave64) and the Intel Graphics iGPU of a Core Ultra 5 225 (driver 101.8860, subgroup 8..32, LEONIDA_W64_EMULATE=1). Runtime built from 561b65a with MSVC 19.50 (its runtime sources are identical to this head), Vulkan SDK 1.4.350, llvm-mc AMD LLVM 23.

  • run_gpu_tests.py: RX 9070 XT 218/234 passed, 16 skipped, 0 failed. Intel 200/234 passed, 33 skipped, 1 failed. cs_scc_mask32 and cs_w64_exec_half pass on both GPUs, and every other test has the same result as on main 561b65a. The Intel failure is ms_wave_info_s3, which fails the same way on main (ms_wave_info_s3 intermittently fails on RX 7900 XT / RADV NAVI31 (pass rate 100% -> 2.5%, same binaries) #6172).
  • test_cf_diff.py 313 passed, test_cf_ref.py 33 OK, test_run_gpu_tests.py 47 OK, tests/semantic 6154 run OK.
  • cf_diff.py --self-test OK, and --programs 300 --seed 20261123 --wave both --spirv-val: 600 pass, 0 mismatch.
  • Main has since moved to 1cc6e3c, and this head now conflicts with it in docs/design.md, runtime/test/shaders/check.py and scripts/run_gpu_tests.py.

No game files. AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested 8811c2b2 (the rebased head, on main 561b65a8) on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • What was tested: this run is of the rebased head 8811c2b2; my earlier run was on eb0f7431. d0835dd9 is an ancestor of the PR's new base 561b65a8, so the merge onto it fast-forwarded and the tree tested is 8811c2b2 itself. That tree's runtime/ differs from d0835dd9 because of main, not this PR's commits, so I rebuilt the Linux Vulkan test tools from it (RelWithDebInfo).
  • CPU tests:
    • pytest tests/test_cf_diff.py tests/test_cf_ref.py tests/test_run_gpu_tests.py: 393 passed, 148 subtests.
    • tests/semantic/test_spirv_wave_interp.py: 23 OK.
    • pytest tests/test_docs_*.py: 33 passed, 6 subtests.
    • tools/cf_diff.py --programs 200 --seed 8811 --wave both --spirv-val (a seed of my own): 400 pass, 0 mismatch, 0 skipped, 0 harness errors.
  • Full scripts/run_gpu_tests.py:
    • Native: 218/234 passed, 16 skipped, no FAIL.
    • LEONIDA_W64_EMULATE=1: 218/234 passed, 16 skipped, no FAIL.
  • Per-test comparison with main d0835dd9 without the PR (196/210, 14 skipped, both modes):
    • No test changes result and none is missing, in either mode. Only ps_bitmask_perm's detail text differs (pixels exact instead of pixels in lanes 0-31 exact), from main's change to that message.
    • Two of the 24 new rows are this PR's: cs_scc_mask32 PASS 7 0 0 9 11 13 7 13 and cs_w64_exec_half PASS 1 0 1 1 0 3 9 9, in both modes.
    • The other 22 came in with main 561b65a8. 20 of them PASS. ps_live_width and ps_m2_literal SKIP because another harness runs them. They have no d0835dd9 baseline on this machine.
  • --filter runs of each fixture: cs_scc_mask32 PASS 7 0 0 9 11 13 7 13 and cs_w64_exec_half PASS 1 0 1 1 0 3 9 9, both natively and with LEONIDA_W64_EMULATE=1. These are the same words as on eb0f7431 and in the earlier 780M / 610M / gfx1036 reports. There is no baseline run because the fixtures don't exist at d0835dd9.
  • Merge with current main: git merge-tree of this head with main 1cc6e3c1 conflicts in docs/design.md, runtime/test/shaders/check.py and scripts/run_gpu_tests.py.

Synthetic fixtures only, no game files.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.