AGC: agc_driver_mul_lo_u16_high_half fails on AMD's Windows driver since #7673 #8271

Closed
opened 2026-10-20 07:58:46 +00:00 by thuanquang · 3 comments
thuanquang commented 2026-10-20 07:58:46 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T07:58:46Z.


What

agc_driver_mul_lo_u16_high_half fails on main on an RX 6700 XT with AMD's Windows driver, 3 of 3 runs, since #7673:

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 emitted SPIR-V looks correct. The store gets the full 32-bit product, as if the driver's compiler dropped the & 0xffff.

Measured

RX 6700 XT (gfx1031), AMD's Windows driver 32.0.21045.5002, Windows 11 26200, Release, ANYPS5_REQUIRE_VULKAN=1. Each row ran 3 times; the test stops at its first failing case.

tree result
main a98590dec fails 3/3 as above
main a98590dec with #7673 reverted (git revert -m 1 1b0ff1e15) passes 3/3
main a98590dec with vMulLoU16 taking the low half as BitFieldUExtract(product, 0, 16), or as a u16 truncation then zero-extension fails 3/3, same value. The constant folder turns both back into the same & 0xffff, so the driver gets the same module and these say nothing new

The full suite fails it on main too, alongside the known log_macros pair and agc_driver_msaa_dcc_clear_4.

The module

Dumped with APS5_DUMP_COMPUTE_PIPELINES, the masked-factors case of the test (v_and_b32 of both factors and of the destination with 0xffff, then v_mul_lo_u16).

On main, #7673 folds the 24-bit factor extracts away, since the factors are already masked to 16 bits:

%393 = OpBitwiseAnd %uint %c_0xffff %196      ; x & 0xffff
%394 = OpBitwiseAnd %uint %c_0xffff %293      ; y & 0xffff
%395 = OpBitwiseAnd %uint %c_0xffff %390      ; destination & 0xffff
%396 = OpIMul %uint %393 %394
%397 = OpBitwiseAnd %uint %396 %c_0xffff
%399 = OpBitwiseAnd %uint %395 %c_0xffff0000  ; always 0
%400 = OpBitwiseOr %uint %399 %397
       OpStore %486 %400

For x = y = 0xffffffff this is 0 | (0xfffe0001 & 0xffff) = 1, but the GPU stores 0xfffe0001. With #7673 reverted, the factors stay OpBitFieldUExtract %393 0 24, and the result is right:

%397 = OpBitFieldUExtract %uint %393 %c_0 %c_24
%398 = OpBitFieldUExtract %uint %394 %c_0 %c_24
%399 = OpIMul %uint %397 %398
%400 = OpBitwiseAnd %uint %399 %c_0xffff

No NoUnsignedWrap/NoSignedWrap decorations are on these ids. So I think the driver's compiler, given a product of two factors it knows are 16-bit, treats the product as 16-bit and drops the mask. That would be an AMD compiler bug that #7673 exposes, not a folder bug. I haven't dumped the driver's ISA to confirm it, and I haven't run other drivers. The other three cases of the test (unmasked factors, a chain, a kept high half) pass on main here; the two packed cases after the failing one don't run.

Options

  • Keep the 24-bit factor extract in vMulLoU16 and vPkMulLoU16 out of #7673's BitFieldUExtract fold. The pre-#7673 form passes here, and it is what the hardware does (#7018).
  • Or find a form of the low half that the folder keeps and the driver compiles correctly. The obvious ones fold back to & 0xffff.

@tibzejoker, could you check whether NVIDIA or RADV pass this test on current main? That would show whether only AMD's Windows compiler is affected.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5938099869 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8271). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T07:58:46Z. --- ### What `agc_driver_mul_lo_u16_high_half` fails on `main` on an RX 6700 XT with AMD's Windows driver, 3 of 3 runs, since #7673: ``` 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 emitted SPIR-V looks correct. The store gets the full 32-bit product, as if the driver's compiler dropped the `& 0xffff`. ### Measured RX 6700 XT (gfx1031), AMD's Windows driver 32.0.21045.5002, Windows 11 26200, Release, `ANYPS5_REQUIRE_VULKAN=1`. Each row ran 3 times; the test stops at its first failing case. | tree | result | |---|---| | `main` `a98590dec` | fails 3/3 as above | | `main` `a98590dec` with #7673 reverted (`git revert -m 1 1b0ff1e15`) | passes 3/3 | | `main` `a98590dec` with `vMulLoU16` taking the low half as `BitFieldUExtract(product, 0, 16)`, or as a `u16` truncation then zero-extension | fails 3/3, same value. The constant folder turns both back into the same `& 0xffff`, so the driver gets the same module and these say nothing new | The full suite fails it on `main` too, alongside the known `log_macros` pair and `agc_driver_msaa_dcc_clear_4`. ### The module Dumped with `APS5_DUMP_COMPUTE_PIPELINES`, the masked-factors case of the test (`v_and_b32` of both factors and of the destination with 0xffff, then `v_mul_lo_u16`). On `main`, #7673 folds the 24-bit factor extracts away, since the factors are already masked to 16 bits: ``` %393 = OpBitwiseAnd %uint %c_0xffff %196 ; x & 0xffff %394 = OpBitwiseAnd %uint %c_0xffff %293 ; y & 0xffff %395 = OpBitwiseAnd %uint %c_0xffff %390 ; destination & 0xffff %396 = OpIMul %uint %393 %394 %397 = OpBitwiseAnd %uint %396 %c_0xffff %399 = OpBitwiseAnd %uint %395 %c_0xffff0000 ; always 0 %400 = OpBitwiseOr %uint %399 %397 OpStore %486 %400 ``` For x = y = 0xffffffff this is `0 | (0xfffe0001 & 0xffff)` = 1, but the GPU stores 0xfffe0001. With #7673 reverted, the factors stay `OpBitFieldUExtract %393 0 24`, and the result is right: ``` %397 = OpBitFieldUExtract %uint %393 %c_0 %c_24 %398 = OpBitFieldUExtract %uint %394 %c_0 %c_24 %399 = OpIMul %uint %397 %398 %400 = OpBitwiseAnd %uint %399 %c_0xffff ``` No `NoUnsignedWrap`/`NoSignedWrap` decorations are on these ids. So I think the driver's compiler, given a product of two factors it knows are 16-bit, treats the product as 16-bit and drops the mask. That would be an AMD compiler bug that #7673 exposes, not a folder bug. I haven't dumped the driver's ISA to confirm it, and I haven't run other drivers. The other three cases of the test (unmasked factors, a chain, a kept high half) pass on `main` here; the two packed cases after the failing one don't run. ### Options - Keep the 24-bit factor extract in `vMulLoU16` and `vPkMulLoU16` out of #7673's `BitFieldUExtract` fold. The pre-#7673 form passes here, and it is what the hardware does (#7018). - Or find a form of the low half that the folder keeps and the driver compiles correctly. The obvious ones fold back to `& 0xffff`. @tibzejoker, could you check whether NVIDIA or RADV pass this test on current `main`? That would show whether only AMD's Windows compiler is affected.
thuanquang commented 2026-10-20 08:05:50 +00:00 (Migrated from github.com)
Author
Contributor

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


A structural diff of the two dumped modules for this case (ids renumbered, names and decorations dropped) shows they are the same program except for this spot. The address arithmetic, bounds checks and store are the same instructions, shifted by 3 ids:

 %154 = OpBitwiseAnd %uint %c_0xffff %150          ; destination & 0xffff, both
-%155 = OpIMul %uint %152 %153                      ; main: factors x & 0xffff, y & 0xffff
-%156 = OpBitwiseAnd %uint %155 %c_0xffff
+%155 = OpBitFieldUExtract %uint %152 %c_0 %c_24    ; with #7673 reverted
+%156 = OpBitFieldUExtract %uint %153 %c_0 %c_24
+%157 = OpIMul %uint %155 %156
+%158 = OpBitwiseAnd %uint %157 %c_0xffff
+%159 = OpBitwiseAnd %uint %158 %c_0xffff
 ... OpBitwiseAnd %dest %c_0xffff0000, OpBitwiseOr, OpStore, unchanged

%152 and %153 are already & 0xffff, so the extracts and the second mask change nothing, and the two modules compute the same value. On this driver the first stores 0xfffe0001 and the second 1. So the difference comes from the driver's compiler, not from the module.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286408058 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8271#issuecomment-6286408058). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T08:05:50Z. --- A structural diff of the two dumped modules for this case (ids renumbered, names and decorations dropped) shows they are the same program except for this spot. The address arithmetic, bounds checks and store are the same instructions, shifted by 3 ids: ``` %154 = OpBitwiseAnd %uint %c_0xffff %150 ; destination & 0xffff, both -%155 = OpIMul %uint %152 %153 ; main: factors x & 0xffff, y & 0xffff -%156 = OpBitwiseAnd %uint %155 %c_0xffff +%155 = OpBitFieldUExtract %uint %152 %c_0 %c_24 ; with #7673 reverted +%156 = OpBitFieldUExtract %uint %153 %c_0 %c_24 +%157 = OpIMul %uint %155 %156 +%158 = OpBitwiseAnd %uint %157 %c_0xffff +%159 = OpBitwiseAnd %uint %158 %c_0xffff ... OpBitwiseAnd %dest %c_0xffff0000, OpBitwiseOr, OpStore, unchanged ``` `%152` and `%153` are already `& 0xffff`, so the extracts and the second mask change nothing, and the two modules compute the same value. On this driver the first stores 0xfffe0001 and the second 1. So the difference comes from the driver's compiler, not from the module.
thuanquang commented 2026-10-20 08:24:34 +00:00 (Migrated from github.com)
Author
Contributor

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


Closing as a duplicate of #8266, which reported the same failure first. The root cause and fix are in #8266 and #8280.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286732528 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8271#issuecomment-6286732528). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T08:24:34Z. --- Closing as a duplicate of #8266, which reported the same failure first. The root cause and fix are in #8266 and #8280.
thuanquang commented 2026-10-20 08:55:33 +00:00 (Migrated from github.com)
Author
Contributor

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


Reopening: I closed this as a duplicate of #8266 at the same moment @oneandonlydean closed #8266 as a duplicate of this one. Keeping this one open as the canonical issue; #8266's RDNA 2 iGPU result stays linked there. The fix is #8280.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6287276718 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8271#issuecomment-6287276718). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T08:55:33Z. --- Reopening: I closed this as a duplicate of #8266 at the same moment @oneandonlydean closed #8266 as a duplicate of this one. Keeping this one open as the canonical issue; #8266's RDNA 2 iGPU result stays linked there. The fix is #8280.
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#8271
No description provided.