isa_sweep: 6 single-precision FMA/rounding 1-ULP deviations on Windows 11 WARP (build 26200) #126
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator#126
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ComputerScape04 on GitHub · 2026-11-22 13:40 UTC · original
Environment
@omonkeyz on GitHub · 2026-11-22 13:48 UTC · original
Thanks for writing this up! On our side the same isa_sweep passes on WARP on Windows 11 build 26200 with the MSVC toolchain and DXC 1.9.2609, with none of these six on the known list. The main difference from your setup is DXC 1.8.2505 (and the GNU toolchain), so a different FMA contraction / rounding in the older compiler is the first suspect. Could you rerun with DXC 1.9 (current Windows SDK or the DXC 1.9 release) and post whether the six still deviate, plus the generated HLSL for one failing case (v_fma_f32)? That tells us whether it is the compiler or WARP.
@ComputerScape04 on GitHub · 2026-11-22 15:09 UTC · original
Investigated the setup, verified DXC, and ran isolated comparisons across toolchains. Here are the findings:
The deviation is neither in WARP nor in DXC. It was caused by the host reference calculation in isa_sweep/ops_v.rs (fma32(a, b, c) -> f(a).mul_add(f(b), f(c))) when compiled under the GNU toolchain (x86_64-pc-windows-gnu):
When compiled with native CPU instructions (RUSTFLAGS="-C target-cpu=native" or -C target-cpu=x86-64-v3), fma32 emits hardware vfmadd213ss, the reference produces 0x3f9fffff, and:
All 6 previously failing operations pass on WARP with 0 failures:
SOP1: 29 pass, 0 fail, 0 known WARP deviations
SOP2: 51 pass, 0 fail, 0 known WARP deviations
SOPC: 18 pass, 0 fail, 0 known WARP deviations
SOPK: 21 pass, 0 fail, 0 known WARP deviations
VOP1: 71 pass, 0 fail, 7 known WARP deviations
VOP2: 46 pass, 0 fail, 2 known WARP deviations
VOP3: 96 pass, 0 fail, 2 known WARP deviations
VOP3P: 8 pass, 0 fail, 0 known WARP deviations
VOPC: 190 pass, 0 fail, 0 known WARP deviations
isa_sweep on WARP: 541 mnemonics, 530 pass, 0 fail, 11 known WARP deviations (the original main list), 28 skipped, 94 compiles, 19.3s
test result: ok. 2 passed; 0 failed
Instruction Emission (v_fma_f32 slot):
// 0x0074 v_fma_f32
v20 = TB_WV(asuint(tb_fma((-asfloat(v10)), abs(asfloat(v11)), (-asfloat(v12)))), v20);
Helper Definition (tb_fma in shader prologue):
float tb_fma(float a, float b, float c) {
precise double p = (double)a * (double)b;
precise double dc = (double)c;
precise double s = p + dc;
precise double bb = s - p;
precise double e = (p - (s - bb)) + (dc - bb);
uint lo, hi;
asuint(s, lo, hi);
uint fin = (uint)(abs(s) < 1.0e300);
uint adj = fin & (uint)(e != 0.0) & (~lo & 1u);
uint dn = adj & (uint)((e > 0.0) != (s > 0.0));
precise float r = (float)asdouble(lo + adj - 2u * dn, hi - (dn & (uint)(lo == 0u)));
uint m = 0x7fffffffu;
float q = ((asuint(r) & m) > 0x7f800000u) ? asfloat(0x7fc00000u) : r;
float sp = (max(max(asuint(a) & m, asuint(b) & m), asuint(c) & m) > 0x7f800000u) ? asfloat((((asuint(a) & m) > 0x7f800000u) ? asuint(a) : (((asuint(b) & m) > 0x7f800000u) ? asuint(b) : asuint(c))) | 0x400000u) : q;
return ((fin | (uint)(abs(p) < 1.0e300)) != 0u) ? r : sp;
}
@omonkeyz on GitHub · 2026-11-22 15:29 UTC · original
Great investigation, thank you! That settles it: the translator and WARP are right, and the reference value in the test was off by one ULP because the
x86_64-pc-windows-gnutarget takesf32::mul_addfrom MinGW's softwarefmaf, which doesn't round correctly in this halfway-adjacent case. With hardware FMA or the MSVC CRT, the reference matches WARP and the whole sweep passes.The supported toolchain is MSVC (see CONTRIBUTING.md). I added a note there in
7e41abethat the GNU target's softwarefmafbreaks the FMA reference values. I'm closing this as not an emulator bug. If you run into anything else with the MSVC toolchain, please reopen.