agc_driver_vopc_compare_table fails in wave32 for LG compares in the e32 encoding on AMD RDNA 3.5 #825

Closed
opened 2026-10-06 07:45:25 +00:00 by LeandroLP23 · 4 comments
LeandroLP23 commented 2026-10-06 07:45:25 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-06T07:45:25Z.


agc_driver_vopc_compare_table fails in the wave32 run on an AMD RDNA 3.5 GPU:

AGC graphics: vopc compare table wave32: lane 29 cmp_lg_f32_e32 is 1, expected 0

With the check turned into a log of every mismatch, all of them are LG compares in the e32 encoding of the wave32 run, on rows with a NaN operand:

wave32 lane 29 cmp_lg_f32_e32 row 00000000 fffffffe 00000000 fffffffe is 1
wave32 lane 29 cmp_lg_f16_e32 row 00000000 fffffffe 00000000 fffffffe is 1
wave32 lane 31 cmp_lg_f16_e32 row 007fffff 00007fff ff7fffff 7f7fffff is 1

The same compares pass in their e64 encoding, and the wave64 and wave64 split runs pass entirely. VCmpLgF32 is lowered to FPOrdNotEqual32 and emitted as OpFOrdNotEqual, and the module declares SignedZeroInfNanPreserve, so the difference between the e32 and e64 paths in wave32 has not been found yet.

Environment

  • main at 481c85e7, Release, MinGW-w64 GCC 15.2.0 (WinLibs r7), Windows 11 Home 10.0.26300
  • AMD Radeon 860M (RDNA 3.5, device 0x1114), driver 32.0.13058.8001, Vulkan 1.3.302, subgroup size 64 (wave32 compute runs on 32-wide subgroups)

Reproduce

ctest --test-dir build -R '^agc_driver_vopc_compare_table$' --output-on-failure
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5724871937 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/825). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-06T07:45:25Z. --- `agc_driver_vopc_compare_table` fails in the wave32 run on an AMD RDNA 3.5 GPU: ``` AGC graphics: vopc compare table wave32: lane 29 cmp_lg_f32_e32 is 1, expected 0 ``` With the check turned into a log of every mismatch, all of them are LG compares in the e32 encoding of the wave32 run, on rows with a NaN operand: ``` wave32 lane 29 cmp_lg_f32_e32 row 00000000 fffffffe 00000000 fffffffe is 1 wave32 lane 29 cmp_lg_f16_e32 row 00000000 fffffffe 00000000 fffffffe is 1 wave32 lane 31 cmp_lg_f16_e32 row 007fffff 00007fff ff7fffff 7f7fffff is 1 ``` The same compares pass in their e64 encoding, and the wave64 and wave64 split runs pass entirely. `VCmpLgF32` is lowered to `FPOrdNotEqual32` and emitted as `OpFOrdNotEqual`, and the module declares `SignedZeroInfNanPreserve`, so the difference between the e32 and e64 paths in wave32 has not been found yet. ### Environment - `main` at 481c85e7, Release, MinGW-w64 GCC 15.2.0 (WinLibs r7), Windows 11 Home 10.0.26300 - AMD Radeon 860M (RDNA 3.5, device 0x1114), driver 32.0.13058.8001, Vulkan 1.3.302, subgroup size 64 (wave32 compute runs on 32-wide subgroups) ### Reproduce ``` ctest --test-dir build -R '^agc_driver_vopc_compare_table$' --output-on-failure ```
LeandroLP23 commented 2026-10-06 08:02:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-06T08:02:07Z.


Narrowed down on the same machine:

  • In the IR the e32 and e64 compares are the same FPOrdNotEqual32; the only difference is that the e32 result goes through Ballot (VCC as a lane mask) and is read back by lane, while the e64 result feeds a Select.
  • Emitting ordered not-equal as OpFOrdNotEqual, as FOrdLessThan || FOrdGreaterThan, as FUnordNotEqual && !IsNan(a) && !IsNan(b), or as (select(lt,1,0) | select(gt,1,0)) != 0 gives the same wrong 1 on the NaN rows, only through the ballot in the wave32 run. LT and GT alone pass through the same path, and a constant false reads back correctly.
  • Checking for NaN on the integer bits instead, FUnordNotEqual(a, b) && (bits(a) & 0x7fffffff) <= 0x7f800000 && (bits(b) & 0x7fffffff) <= 0x7f800000, makes the test pass, f16 LG included, with no other test changing.

This points to the AMD driver's shader compiler folding any float form of ordered not-equal and miscompiling it when it feeds a ballot on a 32-wide subgroup, rather than to the recompiler's SPIR-V. The integer form above avoids it at the cost of a few ALU ops per LG compare on every GPU; I can open a PR with it if that workaround is wanted.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6012017944 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/825#issuecomment-6012017944). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-06T08:02:07Z. --- Narrowed down on the same machine: - In the IR the e32 and e64 compares are the same `FPOrdNotEqual32`; the only difference is that the e32 result goes through `Ballot` (VCC as a lane mask) and is read back by lane, while the e64 result feeds a `Select`. - Emitting ordered not-equal as `OpFOrdNotEqual`, as `FOrdLessThan || FOrdGreaterThan`, as `FUnordNotEqual && !IsNan(a) && !IsNan(b)`, or as `(select(lt,1,0) | select(gt,1,0)) != 0` gives the same wrong 1 on the NaN rows, only through the ballot in the wave32 run. `LT` and `GT` alone pass through the same path, and a constant false reads back correctly. - Checking for NaN on the integer bits instead, `FUnordNotEqual(a, b) && (bits(a) & 0x7fffffff) <= 0x7f800000 && (bits(b) & 0x7fffffff) <= 0x7f800000`, makes the test pass, f16 LG included, with no other test changing. This points to the AMD driver's shader compiler folding any float form of ordered not-equal and miscompiling it when it feeds a ballot on a 32-wide subgroup, rather than to the recompiler's SPIR-V. The integer form above avoids it at the cost of a few ALU ops per LG compare on every GPU; I can open a PR with it if that workaround is wanted.
oneandonlydean commented 2026-10-08 08:26:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T08:26:30Z.


The integer check gives the same result as OpFOrdNotEqual for every input, so a PR with it is fine. Please put the driver version and the failing rows in the description, and the same tests run on another GPU.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055873503 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/825#issuecomment-6055873503). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T08:26:30Z. --- The integer check gives the same result as `OpFOrdNotEqual` for every input, so a PR with it is fine. Please put the driver version and the failing rows in the description, and the same tests run on another GPU.
tezzgod74 commented 2026-10-09 04:53:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by tezzgod74 on 2026-10-09T04:53:38Z.


Same failure on RDNA 4, with the same three rows. An RDNA 2 iGPU in the same machine passes.

With the check turned into a log of every mismatch, as in the comment above:

wave32 lane 29 cmp_lg_f32_e32 row 00000000 fffffffe 00000000 fffffffe is 1
wave32 lane 29 cmp_lg_f16_e32 row 00000000 fffffffe 00000000 fffffffe is 1
wave32 lane 31 cmp_lg_f16_e32 row 007fffff 00007fff ff7fffff 7f7fffff is 1

The e64 encodings, wave64 and wave64 split pass on both devices.

ANYPS5_GPU Device Driver Vulkan Result
RX 9060 AMD Radeon RX 9060 XT (RDNA 4, 0x7590) 32.0.31041.1004 1.4.349 fails, rows above
Radeon(TM) Graphics Ryzen 9 7950X iGPU (RDNA 2, 0x164e) 32.0.21045.5002 1.4.315 passes

The rows match the RDNA 3.5 report exactly, and the RDNA 2 device passes the same SPIR-V. That fits a driver compiler issue on RDNA 3 and later, not a recompiler one. I can rerun the integer-NaN form on both devices once it's in a PR.

Environment: main at 79d23eb7, Release, MinGW-w64 GCC 15.2.0 (WinLibs r7), Windows 11 Pro 10.0.26300, wave32 compute on 32-wide subgroups.

$env:ANYPS5_GPU = "RX 9060"
ctest --test-dir build -R '^agc_driver_vopc_compare_table$' --output-on-failure
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074526808 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/825#issuecomment-6074526808). Originally posted by [tezzgod74](https://github.com/tezzgod74) on 2026-10-09T04:53:38Z. --- Same failure on RDNA 4, with the same three rows. An RDNA 2 iGPU in the same machine passes. With the check turned into a log of every mismatch, as in the comment above: ``` wave32 lane 29 cmp_lg_f32_e32 row 00000000 fffffffe 00000000 fffffffe is 1 wave32 lane 29 cmp_lg_f16_e32 row 00000000 fffffffe 00000000 fffffffe is 1 wave32 lane 31 cmp_lg_f16_e32 row 007fffff 00007fff ff7fffff 7f7fffff is 1 ``` The e64 encodings, wave64 and wave64 split pass on both devices. | `ANYPS5_GPU` | Device | Driver | Vulkan | Result | |---|---|---|---|---| | `RX 9060` | AMD Radeon RX 9060 XT (RDNA 4, 0x7590) | 32.0.31041.1004 | 1.4.349 | fails, rows above | | `Radeon(TM) Graphics` | Ryzen 9 7950X iGPU (RDNA 2, 0x164e) | 32.0.21045.5002 | 1.4.315 | passes | The rows match the RDNA 3.5 report exactly, and the RDNA 2 device passes the same SPIR-V. That fits a driver compiler issue on RDNA 3 and later, not a recompiler one. I can rerun the integer-NaN form on both devices once it's in a PR. Environment: `main` at 79d23eb7, Release, MinGW-w64 GCC 15.2.0 (WinLibs r7), Windows 11 Pro 10.0.26300, wave32 compute on 32-wide subgroups. ``` $env:ANYPS5_GPU = "RX 9060" ctest --test-dir build -R '^agc_driver_vopc_compare_table$' --output-on-failure ```
LeandroLP23 commented 2026-10-09 07:13:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-09T07:13:34Z.


The integer-NaN form is already in #1473. A run of agc_driver_vopc_compare_table with it on both devices would be very useful; I'll add the results to the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6076269284 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/825#issuecomment-6076269284). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-09T07:13:34Z. --- The integer-NaN form is already in #1473. A run of `agc_driver_vopc_compare_table` with it on both devices would be very useful; I'll add the results to the description.
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#825
No description provided.