shader: lower v_cvt_f64_f32 for statically known sources in pixel_aot #1439
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1446"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-24T11:39:37Z.
Refs #1325
Change
This is the f32 widening follow-up to #1363 that was agreed in #1325.
tools/pixel_aot.pylowersv_cvt_f64_f32into a VGPR pairv[d:d+1]when its source is known at translation time.Accepted sources. The domain is the one
require_proven_i32_f32_rangeuses:known_ssa_bitsrecordsAny other register is refused with
Unproven runtime input. The integer inline constants 1..64 and -16..-1 are subnormal or NaN patterns and are refused as well.Result words. Both words are computed in Python and emitted as constants, so the shader contains no HLSL
doubleand no runtime input. Normal finite values, ±0 and ±infinity convert exactly: -0 gives0x80000000_00000000, and infinity gives exponent0x7ffwith a zero fraction. A subnormal is refused, because the binary32 input-denormal modeMODE[5:4]has no declared profile here. A NaN is refused as well (#312).Encodings (LLVM 15.0.7, gfx1013).
Plain form: LLVM 15 prints the unmodified VOP1 form as
v_cvt_f64_f32_e32(v_cvt_f64_f32_e32 v[13:14], v1is01211a7e). The plain and_e32spellings are lowered.Modifiers: the source-modifier forms assemble and round-trip as
_e64:-v10d0090d5 01010020|v1|0d0190d5 01010000-|v1|neg(0x…),|0x…|,-|0x…|Exactly these spellings are lowered. Abs is applied first, then neg, as in
require_proven_i32_f32_range. A signed-zero control can tell the order apart:-|-0|must give -0, while the swapped order would give +0.Refused:
_e64without a modifier,-0x…(LLVM folds it into an integer literal, not a modifier),neg(v)/abs(v),clamp,omod, DPP and SDWA (neither assembles for this opcode in LLVM 15, which the test checks), an invalid pair and masked regions.Not verified: the semantics and the modifier order come from LLVM 15 and are not checked against the ISA document. They are not measured on a console.
Test
draw-cvt-f64-f32, registered aspixel_aot_cvt_f64_f32_hardwareand_warp. It has a 60 s timeout, skip code 77 and its ownFORM_COVERAGE_RECORD. The LLVM 15 round trip covers the programs, and a binary check confirms the encodings above.0x7f7fffff), the smallest normal value with its negative, ±infinity and0x3f800001(the last fraction bit set). Both words are exported through the uint target with per-row xor masks, so the comparison stays bit-exact, and the sentinels inv12/v15must stay unchanged.pixel_mismatch:0x00000001,0x807fffff), NaNs (0x7fc00000,0x7f800001), an unproven loaded VGPR,clamp,omodand an invalid pair.main'stools/pixel_aot.pythe mode fails withValueError: Unsupported instruction 22: v_cvt_f64_f32_e32 v[13:14], 0.Environment: commit
88dd9484, rebased on92bd3362. NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818, Windows 11 build 26200, debug layer unavailable.The pure checks pass, and so does the LLVM 15.0.7 binary round trip. On this machine the hardware test takes about 21–24 s under
-j4, with about 60 DXC compiles.AI-assisted (Claude Code).
🤖 Generated with Claude Code