tests: compute_store_aot_mac_f32_hardware fails on a GPU that fuses FMad, because DXC folds the constant word 0 unfused #2883

Closed
opened 2026-11-26 16:22:29 +00:00 by Not-Saii · 0 comments
Not-Saii commented 2026-11-26 16:22:29 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T16:22:29Z.


Commit or build

Fails on two builds whose test and lowering files match current main b505c32b: #2864 at 07222b46, and #2847 at 0a627028, which merges b505c32b. Both contain #2844 (3dfec4c1). The test passed on builds from before #2844.

Summary

#2844 added mac_f32_mad_fusion(). Before it checks the hardware mutation "fused mad() instead of unfused multiply+add", it requires the mutated shader's readback to match exactly one of two models, fused or unfused, across all 320 words. On a GPU that fuses FMad at run time, the readback matches neither, so the test fails:

AssertionError: mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False}

Cause

The two models differ at word 0 and at words 2, 4, 8, 10, … Word 0 is computed only from constants: f32_mac(0x45800800u, 0x45800800u, 0xcb801000u), which is 4097 * 4097 - 16785408. DXC folds that mad() at compile time, and the folded value is the unfused result. In the DXIL of the mutated shader, only the two thread-dependent words remain as run-time FMad, and word 0 is stored as the constant 0:

%5 = call float @dx.op.tertiary.f32(i32 46, float %4, float 0x3FF0000020000000, float 0xBFF0000040000000), !dx.precise !10  ; FMad(a,b,c)
%7 = call float @dx.op.tertiary.f32(i32 46, float 3.000000e+00, float %4, float -3.000000e+00), !dx.precise !10  ; FMad(a,b,c)
call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle %1, i32 %9, i32 undef, i32 0, i32 %6, i32 %8, i32 -1072693248, i8 15)

The GPU fuses the run-time FMad, so the readback mixes the two models:

mutated shader read back against first mismatch
unfused model word=2 expected=40400004 actual=40400003: the fused value
fused model word=0 expected=3f800000 actual=00000000: the unfused, constant-folded value

The unmutated shader still matches the unfused model exactly, so the translation itself is unaffected. Only the negative-control probe is wrong.

On the RX 5700 XT from #2730, the driver did not fuse the run-time FMad either, so the whole readback matched the unfused model. I expect any adapter that fuses FMad to fail this way with this DXC, but I tested only the one below.

Environment

  • NVIDIA GeForce RTX 4090 (10de:2684), driver 610.88 (32.0.16.1088)
  • Windows 11 build 26300.9974
  • DXC dxcompiler.dll 1.9.2602.17 (21d28f727), from Windows SDK 10.0.26100
  • dev preset, hardware backend, debug layer enabled by the test

Reproduce

ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' --output-on-failure

It fails when run alone. On the full suite it also failed under -j 4, so this isn't contention.

Expected

The probe classifies this adapter as fused, so the strict "fused mad()" mutation check applies, as #2844 intended.

Possible fixes

  • Decide fused or unfused only from words whose operands DXC cannot fold, i.e. the thread-dependent words 2, 10, 18, …, and check word 0 against the unfused model in both cases.
  • Or make word 0's operands opaque to DXC, for example by loading them or deriving them from tid.x, so it stays a run-time FMad like the others.

Either keeps the probe's intent: detect a fusing target, then require the mutation to be caught.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6630857589 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2883). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T16:22:29Z. --- ### Commit or build Fails on two builds whose test and lowering files match current main `b505c32b`: #2864 at `07222b46`, and #2847 at `0a627028`, which merges `b505c32b`. Both contain #2844 (`3dfec4c1`). The test passed on builds from before #2844. ### Summary #2844 added `mac_f32_mad_fusion()`. Before it checks the hardware mutation "fused mad() instead of unfused multiply+add", it requires the mutated shader's readback to match exactly one of two models, fused or unfused, across all 320 words. On a GPU that fuses `FMad` at run time, the readback matches neither, so the test fails: ```text AssertionError: mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False} ``` ### Cause The two models differ at word 0 and at words 2, 4, 8, 10, … Word 0 is computed only from constants: `f32_mac(0x45800800u, 0x45800800u, 0xcb801000u)`, which is `4097 * 4097 - 16785408`. DXC folds that `mad()` at compile time, and the folded value is the unfused result. In the DXIL of the mutated shader, only the two thread-dependent words remain as run-time `FMad`, and word 0 is stored as the constant `0`: ```text %5 = call float @dx.op.tertiary.f32(i32 46, float %4, float 0x3FF0000020000000, float 0xBFF0000040000000), !dx.precise !10 ; FMad(a,b,c) %7 = call float @dx.op.tertiary.f32(i32 46, float 3.000000e+00, float %4, float -3.000000e+00), !dx.precise !10 ; FMad(a,b,c) call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle %1, i32 %9, i32 undef, i32 0, i32 %6, i32 %8, i32 -1072693248, i8 15) ``` The GPU fuses the run-time `FMad`, so the readback mixes the two models: | mutated shader read back against | first mismatch | |---|---| | unfused model | `word=2 expected=40400004 actual=40400003`: the fused value | | fused model | `word=0 expected=3f800000 actual=00000000`: the unfused, constant-folded value | The unmutated shader still matches the unfused model exactly, so the translation itself is unaffected. Only the negative-control probe is wrong. On the RX 5700 XT from #2730, the driver did not fuse the run-time `FMad` either, so the whole readback matched the unfused model. I expect any adapter that fuses `FMad` to fail this way with this DXC, but I tested only the one below. ### Environment - NVIDIA GeForce RTX 4090 (`10de:2684`), driver 610.88 (32.0.16.1088) - Windows 11 build 26300.9974 - DXC `dxcompiler.dll` 1.9.2602.17 (`21d28f727`), from Windows SDK 10.0.26100 - `dev` preset, hardware backend, debug layer enabled by the test ### Reproduce ```powershell ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' --output-on-failure ``` It fails when run alone. On the full suite it also failed under `-j 4`, so this isn't contention. ### Expected The probe classifies this adapter as `fused`, so the strict "fused mad()" mutation check applies, as #2844 intended. ### Possible fixes - Decide fused or unfused only from words whose operands DXC cannot fold, i.e. the thread-dependent words 2, 10, 18, …, and check word 0 against the unfused model in both cases. - Or make word 0's operands opaque to DXC, for example by loading them or deriving them from `tid.x`, so it stays a run-time `FMad` like the others. Either keeps the probe's intent: detect a fusing target, then require the mutation to be caught.
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
R0Y00/Xbox2Windows#2883
No description provided.