AGC: agc_driver_mul_lo_u16_high_half fails on an AMD Radeon RDNA 2 iGPU (Windows driver 32.0.21045.5002): masked-factor v_mul_lo_u16 keeps the full product #8266

Closed
opened 2026-10-20 07:41:25 +00:00 by TheSovietWaffle · 2 comments
TheSovietWaffle commented 2026-10-20 07:41:25 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T07:41:25Z.


agc_driver_mul_lo_u16_high_half (added by #7018) fails 3 of 3 on main 7e12b3da8 on an AMD Radeon RDNA 2 iGPU (1002:164e, AMD Windows driver 32.0.21045.5002), Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0, Release. It passes on an RTX 3080 (617.42) in the same build.

AGC graphics: mul lo u16: v_mul_lo_u16 of factors masked to 16 bits into a register whose high half is zero: thread 0 (0xffffffff, 0xffffffff, 0x00000000) wrote 0xfffe0001, expected 0x00000001
  • The first three cases in the test (ZeroHighCode, ChainCode, KeptHighCode) pass; the failure is the fourth, MaskedFactorsCode (v_and_b32 of both factors with 0xffff, then v_mul_lo_u16).
  • 0xfffe0001 is 0xffff * 0xffff: the 32-bit product of the masked factors, with neither the low-16 truncation nor the zero high half of the destination applied. That looks like the driver's compiler folding the masks of the 24-bit field reads against the explicit 0xffff masks and dropping the final truncation, but I have not looked at the SPIR-V or the driver ISA, so it may also be something in how the recompiler emits this case.
  • It is deterministic (3 of 3, and in a full agc run). Not checked: other AMD devices on this driver (@thuanquang's RX 6700 XT on 32.0.21045.5002 in #7936 may tell whether it is specific to this iGPU), RADV.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5937879810 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8266). Originally posted by [TheSovietWaffle](https://github.com/TheSovietWaffle) on 2026-10-20T07:41:25Z. --- `agc_driver_mul_lo_u16_high_half` (added by #7018) fails 3 of 3 on main `7e12b3da8` on an AMD Radeon RDNA 2 iGPU (`1002:164e`, AMD Windows driver 32.0.21045.5002), Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0, Release. It passes on an RTX 3080 (617.42) in the same build. ```text AGC graphics: mul lo u16: v_mul_lo_u16 of factors masked to 16 bits into a register whose high half is zero: thread 0 (0xffffffff, 0xffffffff, 0x00000000) wrote 0xfffe0001, expected 0x00000001 ``` - The first three cases in the test (`ZeroHighCode`, `ChainCode`, `KeptHighCode`) pass; the failure is the fourth, `MaskedFactorsCode` (`v_and_b32` of both factors with `0xffff`, then `v_mul_lo_u16`). - `0xfffe0001` is `0xffff * 0xffff`: the 32-bit product of the masked factors, with neither the low-16 truncation nor the zero high half of the destination applied. That looks like the driver's compiler folding the masks of the 24-bit field reads against the explicit `0xffff` masks and dropping the final truncation, but I have not looked at the SPIR-V or the driver ISA, so it may also be something in how the recompiler emits this case. - It is deterministic (3 of 3, and in a full `agc` run). Not checked: other AMD devices on this driver (@thuanquang's RX 6700 XT on 32.0.21045.5002 in #7936 may tell whether it is specific to this iGPU), RADV. AI-assisted: yes (Claude Code).
oneandonlydean commented 2026-10-20 08:21:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T08:21:55Z.


This is the same failure as #8271: same test case, same value (0xfffe0001) and same driver 32.0.21045.5002. #8271 bisects it to #7673 and has the SPIR-V comparison, so I'm closing this one as a duplicate; the iGPU (1002:164e) result here is a useful second data point, please add it there if you can.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286688121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8266#issuecomment-6286688121). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T08:21:55Z. --- This is the same failure as #8271: same test case, same value (`0xfffe0001`) and same driver 32.0.21045.5002. #8271 bisects it to #7673 and has the SPIR-V comparison, so I'm closing this one as a duplicate; the iGPU (`1002:164e`) result here is a useful second data point, please add it there if you can.
thuanquang commented 2026-10-20 08:24:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T08:24:32Z.


@TheSovietWaffle the same failure on a discrete RDNA 2 card (RX 6700 XT, same driver 32.0.21045.5002), and it comes from our side of the pipeline. #7018 reads v_mul_lo_u16's factors as 24-bit fields partly to hide them from this driver, which stores the full 32-bit product when it knows both factors fit in 16 bits. #7673 then added a constant-folder rule that turns BitFieldUExtract(x, 0, 24) back into x when x is already masked to 16 bits. In MaskedFactorsCode both factors are v_and_b32 ..., 0xffff, so the workaround was folded away and the driver was handed the pattern it miscompiles.

  • main with #7673 reverted passes 3/3 here.
  • The dumped modules for that case differ only in the two factor extracts (details in #8271, which I opened before I found this issue and am closing as a duplicate).

#8280 keeps a field read that a multiply uses out of that fold, and adds two CPU cases to agc_constant_bit_test so CI catches the fold coming back. It passes 3/3 here, with all six cases of the test, including the two packed ones that never ran because the test stopped at the fourth.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286731833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8266#issuecomment-6286731833). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T08:24:32Z. --- @TheSovietWaffle the same failure on a discrete RDNA 2 card (RX 6700 XT, same driver 32.0.21045.5002), and it comes from our side of the pipeline. #7018 reads `v_mul_lo_u16`'s factors as 24-bit fields partly to hide them from this driver, which stores the full 32-bit product when it knows both factors fit in 16 bits. #7673 then added a constant-folder rule that turns `BitFieldUExtract(x, 0, 24)` back into `x` when `x` is already masked to 16 bits. In `MaskedFactorsCode` both factors are `v_and_b32 ..., 0xffff`, so the workaround was folded away and the driver was handed the pattern it miscompiles. - `main` with #7673 reverted passes 3/3 here. - The dumped modules for that case differ only in the two factor extracts (details in #8271, which I opened before I found this issue and am closing as a duplicate). #8280 keeps a field read that a multiply uses out of that fold, and adds two CPU cases to `agc_constant_bit_test` so CI catches the fold coming back. It passes 3/3 here, with all six cases of the test, including the two packed ones that never ran because the test stopped at the fourth.
Sign in to join this conversation.
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
boykopovar/AnyPS5#8266
No description provided.