Files
mandy/runtime/test/shaders/cs_div_fmas_f64.asm
DeSunShine ce75f144c7 docs/design.md, rdna2spirv: NVIDIA splits a binary64 Fma only when it folds an all-constant one
Correcting #6635's wording. On an RTX 4090 (621.24) the split 0 of the
fma(a, a, c) probe comes from the driver folding an all-constant GLSL Fma
while compiling the pipeline: cs_div_fmas_f64's operands are literals.
The same values read at run time from user SGPRs (VKC_SGPRS) give the
fused 2^-60, as #4536 saw on an RTX 4070. --fma khr is still what makes
both single-rounded. Wording only in design.md's floating-point row,
cs_div_fmas_f64.asm's header, Gen.emit_fma64's docstring, the runner's
split note and test_fma_khr_f64's docstring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 11:41:59 +03:00

18 lines
1.0 KiB
NASM

; group: 1,1,1
; v_div_fmas_f64 with VCC = 0 is a binary64 multiply-add with ONE rounding (RDNA2 ISA, VOP3). Low word first.
; a = 1 + 2^-30 (0x3ff00000_00400000), c = -(1 + 2^-29) (0xbff00000_00800000): a*a = 1 + 2^-29 + 2^-60 exactly, so
; fma(a, a, c) = 2^-60 = 0x3c300000_00000000 fused; rounding a*a first gives 1 + 2^-29 and a result of 0 ("split").
; out[0..1] = 0x00000000 0x3c300000 (split: 0x00000000 0x00000000). Under --fma khr (LEONIDA_FMA=khr) the translator
; emits OpFmaKHR on doubles (feature shaderFmaFloat64) and only the fused words pass; under the default GLSL Fma a
; driver may split. The operands here are literals, so a driver that folds the constant Fma while compiling can
; round it twice: NVIDIA RTX 4090 (621.24) does, while the same values as run-time operands are fused there.
s_mov_b64 vcc, 0
v_mov_b32 v0, 0x00400000
v_mov_b32 v1, 0x3ff00000
v_mov_b32 v2, 0x00800000
v_mov_b32 v3, 0xbff00000
v_div_fmas_f64 v[4:5], v[0:1], v[0:1], v[2:3]
v_mov_b32 v6, 0
buffer_store_dwordx2 v[4:5], v6, s[0:3], 0 offen
s_endpgm