Repository navigation
fix(shader): reduce 16-bit multiply products by subtraction - #8315
TheSovietWaffle wants to merge 1 commit into
Conversation
On AMD's Windows driver 32.0.21045.5002 a Radeon RDNA 2 iGPU (1002:164e) still stored the full 32-bit product of v_mul_lo_u16 when the program masked both factors to 16 bits: the constant folder drops the 24-bit field read of a masked value, so the driver again saw (a & 0xffff) * (b & 0xffff) & 0xffff. A bitfield extract or a shift pair is folded into the same mask. The product is now reduced as p - ((p >> 16) << 16) for v_mul_lo_u16 and the low lane of v_pk_mul_lo_u16; the high lane is shifted into place unmasked. Fixes boykopovar#8266. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for this. #8280 fixes the same failure a different way: it keeps the 24-bit factor reads that #7018 introduced as the workaround for this driver, and it has passed review and CI. It hasn't been run on your iGPU yet, though, and that's the device #8266 was reported on. Could you run |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
@oneandonlydean ran it: #8280's head
So #8280 covers this device as well, and I'm fine with closing this one as covered. On the negated AI-assisted: yes (Claude Code). |
|
Thanks for running it on the iGPU, that settles it: #8280 covers this device, so we'll close this one as covered once #8280 merges. Yes please on the negated |
What
#8266:
agc_driver_mul_lo_u16_high_halffails on main on an AMD Radeon RDNA 2 iGPU (1002:164e, AMD Windows driver 32.0.21045.5002), on the case #7018 added for factors the program masks to 16 bits:#7018 works around this driver's miscompile (it keeps the full 32-bit product of two values it knows fit in 16 bits when the product is masked to 16 bits) by reading the factors as 24-bit fields. When the program has already masked a factor with
v_and_b32 0xffff, the constant folder drops that 24-bit read (BitFieldUExtract(x & 0xffff, 0, 24)isx & 0xffff), so the driver again sees(a & 0xffff) * (b & 0xffff) & 0xffff(APS5_DUMP_IR). A shift pair is folded back into the same mask, andBitFieldUExtract(p, 0, 16), which reaches the driver, loses the same bits.Changes:
v_mul_lo_u16and the low lane ofv_pk_mul_lo_u16reduce the product asp - ((p >> 16) << 16), which isp & 0xfffffor everypand survives the folder in that form. The high lane ofv_pk_mul_lo_u16is shifted into place without a mask, as its high bits are shifted out.docs/dev/debt/shader.mdnames the subtraction and this device.Tested
Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, Release, on main
661f8b717.agc_driver_mul_lo_u16_high_half(all six cases): fails on main on the Radeon, passes with the change on both GPUs below; on the RTX 3080 it passes either way. With onlyv_mul_lo_u16changed, the Radeon then fails the next case the same way (v_pk_mul_lo_u16 of factors whose high halves are zero ... wrote 0xfffe0001), which the first failure had hidden. With theBitFieldUExtractor shift-pair reduction instead of the subtraction, the Radeon still fails the masked-factor case.agcsuite (817 tests) on both GPUs with the change: all pass on the Radeon; on the RTX 3080 onlyagc_driver_pass_input_hazardfails, as it does on main.tools/check_conventions.py --base origin/mainandgit diff --checkpass.tools/pr_overlap.pywas not run (noghon this host).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)1002:164e), 32.0.21045.5002, Windows 10 22H2🤖 Generated with Claude Code