xshader: lower exact f64 rounding and f64/int32 conversions #99
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/brcly--TuxBox!99
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/99/head"
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?
@JohnVonWells on GitHub · 2026-11-24 22:17 UTC · original
xshader/exact-f64-rounding→main· +5017 −0 · 5 files · 1 commits · merged 2026-11-24 22:19 UTCFollow-up to #95, from the same synthetic opcode sweep. This PR takes the double-precision instructions whose results are exactly defined:
v_trunc_f64,v_floor_f64,v_ceil_f64,v_rndne_f64v_cvt_i32_f64,v_cvt_u32_f64v_cvt_f64_i32,v_cvt_f64_u32Semantics. LLVM's gfx1030 backend selects exactly these single instructions for
llvm.floor/ceil/trunc/roundeven.f64,llvm.fptosi.sat/fptoui.sat.i32.f64andsitofp/uitofp i32 to double. So rounding is IEEE (ties to even forrndne), and the conversions to int32 truncate, saturate and give 0 for NaN.Lowering (new
hlsl/float64.rs)compare.rs, it works onuint2(low, high) pairs with bit operations. No host FP64 is needed and every result is bit-exact.tb_fp_mode & 0x40), the same convention ascompare_float.live_innow counts the high register of an f64 source pair, and pair results mark both destination registers written, both in the live-in analysis and in the symbolic VGPR map.Verification
tools/check_f64_exact_gpu.pyruns three LLVM-assembled programs (VOP1, VOP3, and VOP1 afters_denorm_mode 0):v_rndne_f64aliases its source pair.2^52/2^53boundaries, int32 limits ±½, ±inf, quiet and signalling NaNs) plus random patterns.math.floor/ceil/trunc,round), not the HLSL bit algorithm. Hand-computed values for it are intests/test_f64_exact_gpu.py.1002:73a5, RADV): 576 inputs, 9,216 results, 27,648 GPU words, zero mismatches. The receipt isevidence/f64-exact-control.json.--baseline). For every instruction, a negated or clamped form and an SGPR source are refused.rndneties always rounding up. 16 of 72 dispatches then failed, only in the tworndneoutput columns (for example 2.5 → 3.0 instead of 2.0).Assumption: NaN quieting (signalling NaN in, quiet NaN with the same payload out) follows IEEE-754 and LLVM's constant folding. I could not observe the hardware's own NaN output for these instructions.
AI-assisted.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NhDbTJdTcjebsL5u7pwFoY