Repository navigation
Conversation
|
The new float condition can give a branch the wrong target. In To reproduce on 6906e16, run this Python from the repository root: import sys
sys.path.insert(0, "tools")
import cf_diff as d
e = d.Emitter(32)
e.br("s_branch", "target")
e.fcompare(("lt", "0x80000000", 1), False)
e.place("target")
e.ins("s_nop 0")
e.ins("s_endpgm")
for text, size in e.assemble():
print(text)I assembled the printed output with AMD COMGR for Please count the inline constant as four bytes here. Add a branch-over-float-condition test with an independently derived offset. The reference and the translator can agree when both consume the same synthetic instruction sizes. The direct parent b06d031 and merge base 98fa503 do not generate this float condition. On Windows with CPython 3.14.7, all 323 tests in AI-assisted. |
|
Tested 6906e16 on Arch Linux (in a VM), CPython 3.14, LLVM 23.1.5, SPIRV-Tools v2026.4: pass.
I only looked at the last commit; the rest of the chain is #4909 and earlier. |
|
APPROVE, with a base/stack note. This branch is stacked: 10 commits ahead of
Minor: the class mask Approve. AI-assisted review, no game files. |
|
Verified merged with main 3faac55: compileall clean; test_cf_diff 268 passed (pytest, re-run here; under python -I it fails fast at import pytest as documented), test_cf_ref 33, tests/semantic/test_spirv_wave_interp 22, test_run_gpu_tests 41 — all green; cf-family, docs and guard regressions OK. The wave interpreter extends the one already on main rather than adding a parallel model, the guard allowlist entry predates the PR, both new .asm listings are hand-written with run recipes and attribution, and newline-pinning/stdlib/no-game-data all hold. The GPU-side expectations (cs_scc_mask32, cs_w64_exec_half) are unverifiable in a CPU-only run; CI pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Independent run on an AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64), Windows 11 23H2, head 6906e16: |
|
Thanks @tupacfan04, both points were right. Fixed in
Rerun on the new tip (#4947 rebased onto it, |
|
Tested 9d07681 on AMD Radeon 610M (RADV, subgroup 32..64), Linux: the new GPU fixtures pass with LEONIDA_VK_DEVICE=RADV, cs_scc_mask32 and ps_scc_mask32 (2/2) and cs_w64_exec_half (1/1). CPU side: tests/test_cf_diff.py plus tests/test_cf_ref.py give 306 passed, 64 subtests passed under pytest (the PR body says 301; I did not investigate the difference), test_spirv_wave_interp has 22 tests OK, and tools/cf_diff.py seeds 6160, 6161 and 6162 (1,400 programs) show 0 mismatch and 0 harness errors. test_cf_diff.py collects 0 tests under unittest discover, so it needs pytest. AI-assisted. |
|
Thanks @gertify. The 301 in the description was from the first push. The review fix |
|
Tested
|
…_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>
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>
|
Rebased the FUZZ-8 stack onto Tests (WSL Ubuntu, llvm-mc 21, CPU only; the PC's RTX 5070 Ti not used): on #615's head, |
|
Tested d4f19e4 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.
No game files. AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
FUZZ-8 follow-up, claimed on #4683 (comment).
Depends on #4909, which sits at the end of the FUZZ-8 chain #615 → #663 → #4077 → #4104 → #4134 → #4241 → #4909. Only the last two commits,
fae577f4and the review fixd4f19e4c, are new here.tools/cf_diff.pydrove EXEC and VCC with integer compares only. Compilers also branch on float conditions (NaN guards,discardtests,isinfchecks), and the translator lowers all 16 f32 conditions toOpFOrd*/OpFUnord*/OpIsNan, andv_cmp(x)_class_f32to class tests. Those paths had unit tests but were never exercised inside control flow. This adds:tools/cf_ref.py: IEEE f32 compares per the RDNA2 ISA. The ordered forms are false and thenforms true when either side is a NaN;o/utest for NaNs,f/truare constant, and -0 equals +0. It also has the 10 class bits ofv_cmp_class_f32, with S0 as the value and S1 as the mask.tools/cf_diff.py: two new shapes.fifisv_cmp_<cc>_f32orv_cmp_class_f32→s_and_saveexec→ [s_cbranch_execz] → body →s_or exec.fcmpxis thev_cmpx_...form, with EXEC saved and restored around it. Both compare a per-lane f32 built inv12from a data VGPR: ±1.0..1.75, ±0, ±inf or a quiet NaN. One wave32 ofv8already holds every one of those classes. The value is never a denormal, so the result doesn't depend on the denorm mode. It is compared against float inline constants, -0/±inf/NaN literals, or a class mask inv13(any of the 1,024 masks, 0 included).tests/semantic/spirv_wave_interp.py:OpIsNanandOpIsInfon floats, with unit tests.docs/design.mdrows "Floating-point class compare" and "Constant and ordered VOPC" note the fuzzer coverage, anddocs/shader_validation.mdadds the shapes to the FUZZ-8 list.tests/test_cf_ref.py's list of unsupported examples now uses an f16 compare, because f32 compares are modelled.No new findings. The translator agrees with the reference everywhere.
Tested (WSL Ubuntu, CPU) on
9d07681e:tests/test_cf_diff.py+tests/test_cf_ref.py: 306 passed, 64 subtests. (The first push had 301; the review fix added the mask-0 case andtest_fvalue_covers_every_class_in_one_wave32.)FCMP_CASES(16 cases, including a never-firing class mask 0:lt,nge,u,o,eq -0,neq inf,lg,nlg,ge -inf,ngt,tru,fand three class masks) match in wave32 and wave64, structured and dispatch loop.OpFOrd/OpFUnordslip) every compare case that has NaN lanes mismatches, and the class cases mismatch with the sign ignored._fcmpand_fclassare pinned by their own unit tests: NaN against everything, -0 == +0, and each of the 10 classes.tests/semantic/test_spirv_wave_interp.py: 22 passed.tools/cf_diff.py: seeds 8180–8182 on9d07681e(300 programs × wave32 and × wave64; 200 at--depth 4 --dispatch-loop; 200 at--depth 4 --spirv-val): 1,400 pass, 0 mismatch, 0 skipped, 0 harness errors. Seeds 6160–6162 on the first push gave the same.pytest tests --ignore=tests/semantic -n 2: 7227 passed, 157 skipped, 7 failed. The 7 failures are the ones plainmain98fa503fhas:test_joaat_agreement, fixed by find_hash_lookup: hash --hash names as latin-1, like hashdict (test_joaat_agreement fails on main) #4753, andtest_rdna2_decode's llvm-mc parity test, claimed by MichaelL401.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