Repository navigation
v_pk_{lshl,lshr,ashr}rev_b16: lower without bit-field extract to avoid the AMD Windows driver wave32 miscompile (SHADER-777) - #4461
Conversation
…ows driver keeps the high half (SHADER-777) The OpBitFieldUExtract amount and the identical lo/hi expressions gave a wrong high half in wave32 on AMD driver 25.10.36 and 26.10.1 (valu_fuzz f16 seed 1, programs 534, 1146, 1540, 1556 at 32 lanes). Adds the semantic test over all op_sel combinations, GPU test cs_w32_pk_shift, the design.md row, and re-anchors the pk_lshl mutation. AI-assisted.
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 79be6dc5 on Windows 11: tests/semantic/test_pk_shift_16.py -> 2 tests, OK; compileall and git diff --check clean.
The three packed 16-bit shift forms now lower to plain shifts (no bit-field extract), avoiding the AMD Windows driver wave32 miscompile while keeping the high-half behavior; the new GPU fixture cs_w32_pk_shift and the semantic cases cover it. I cannot run the AMD driver path here, but the CPU translation is pinched. No blocking issue.
|
SHADER-777 raw-ISA check on AI-assisted verification using synthetic inputs. |
Flyander
left a comment
There was a problem hiding this comment.
Reviewed 79be6dc: the lowering keeps each 16-bit result half independent and implements shift amounts from the selected source half without bit-field extracts. Semantic cases cover all op_sel combinations; the independent raw-ISA run confirms the hardware result on AMD wave32.
|
Apple M2 no-regression check at head 79be6dc (macOS 26.4, MoltenVK 1.4.2 direct, subgroup 4..32, llvm-mc 23.1.6, clean full build exit 0).
AI-assisted. |
|
Tested
No GPU, no game data. AI-assisted. |
|
AI-assisted Windows hardware & semantic verification for SHADER-777 (
|
|
The miscompile goes back further than 25.10.36: the AMD Windows driver 24.10.24 has it too, on the same four wave32 programs, and this PR fixes all four. AI-assisted (Claude Code), synthetic programs only, no game files. Hardware: AMD Ryzen 5 7600X, Windows 11 Home 26300. GPU: AMD Radeon(TM) Graphics iGPU (RDNA2 gfx1036, subgroup 32..64), AMD driver 24.10.24 (Vulkan driver 2.0.302). MSVC 14.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8, Python 3.12.10. Implicit layers off,
Every mismatch is in a register last written by
Together with @BetterJdue's raw-ISA run (1557/1557 on the hardware itself), this points at the driver's compilation, not the GPU, from 24.10 through 26.10. Whole-suite run of this head,
The new
|
Kam471
left a comment
There was a problem hiding this comment.
Overlap to resolve: #4622 (fiestorra, opened after this) fixes the same SHADER-777 high-half read with a smaller change — shift + mask for the high half, leaving the low half's offset-0 OpBitFieldUExtract in place — and also updates the v_pk_lshlrev_b16 mutation anchor and the docs row. git merge-tree --write-tree refs/remotes/pr/4461 refs/remotes/pr/4622 -> conflict in docs/design.md, tests/semantic/test_mutations.py and tools/rdna2spirv.py.
This PR is the earlier claimant, removes the field extract for both halves and carries the GPU fixture cs_w32_pk_shift.asm plus a semantic test; #4622 is the smaller minimal form. Please have one close or drop its overlapping hunk so the coordinator is not choosing between two conflicting translations of the same fix.
|
Tested Fuzzer, same machine and driver,
GPU suite at this head (
The extra test is the new Note: Tools: llvm-mc 23.1.6 (conda-forge), Vulkan SDK 1.4.363.0, Python 3.11.9, AI-assisted. Synthetic programs and counts only, no game files. Created with Perplexity |
|
Tested
Scope on RDNA4, @Vonsek, in case it helps a follow-up. Each program: a 16-bit producer writes
So on this card the trigger is the AI-assisted (Claude Code). Synthetic inputs only, no game files. |
|
@Vonsek: since this PR is scoped to the shifts, I'll look for a driver-proof lowering of the |
Requested by Lucas · project thread
Claimed in the coordination issue as: SHADER-777, #4257
What and why
v_pk_lshlrev_b16,v_pk_lshrrev_b16andv_pk_ashrrev_i16were lowered withOpBitFieldUExtractfor the shift amount and two near-identical lo/hi expressions. On the AMD Windows driver (25.10.36, and still 26.10.1) the compiled wave32 pipeline returns a wrong high half for some programs:valu_fuzz --family f16 --seed 1programs 534, 1146, 1540, 1556 at 32 lanes (plus 378 at 64) mismatch the hardware oracle on the Radeon with the old lowering. The minimal trigger found by bisection is the three-instruction shift sequence inside the fuzz prologue; it is not reproducible with a small standalone shader, so the regression evidence is those programs, not a red GPU fixture.New lowering: the amount per half is
(src0 >> 16*sel) & 15, each value half is placed in bits 31:16, and the result halves come from a right shift of that word (lshl: shift left then mask), so no bit-field extract is used and the two halves are different expressions. The result is bit-identical to the old lowering in the translator reference.Tested
6/6 programs that ran match, 378 at 64 lanes skipped by the harness: no full 64-wide subgroups). With the old lowering the Radeon mismatches on the four 32-lane programs.tools/pk16_diff.py --programs 150over the three ops: 150 pass on both GPUs.tests/semantic/test_pk_shift_16.py: all 16op_sel/op_sel_hicombinations x 3 ops x 6 value pairs against a Python reference, plus the expected words of the new GPU testcs_w32_pk_shift(registered incheck.pyandscripts/run_gpu_tests.py; PASS on both GPUs, old lowering also passes it, so it guards semantics, not the driver bug).test_mutations.py: thev_pk_lshlrev_b16mutation re-anchored on the new amount read; it is caught.python -m unittest discover -s tests/semantic: 7458 tests; the only failures (loop_ballot_barrier, cmp_class_f64, and thev_mul_legacy_f32mutation anchor) fail identically on upstream main, none touch this change.tests/test_docs_design_rows.py: OK.Checklist
docs/design.md, with how it was confirmed (new row "Packed 16-bit shifts").AI-assisted.