shader: lower v_cvt_f32_f64 for exact static pairs in pixel_aot #1653
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1660"
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-24T16:39:16Z.
Refs #1606
Change
This is the mode-independent slice agreed in #1606.
tools/pixel_aot.pylowersv_cvt_f32_f64on a binary64 pair whose provenance is the static record from #1575 (v_cvt_f64_f32of a known source), usingf64_wordsand the existing join rule.cvt_f32_f64_exact_bitsnarrows the value withstruct, widens it again withcvt_f64_f32_words, and requires the same two words bit for bit. The binary32 word is emitted as a constant, so the shader uses no HLSLdouble, and the result depends neither on the rounding field (MODE[1:0]vsMODE[3:2]) nor on the denorm field. Which field governs the narrowing stays open, as requested.is not finite)requires rounding)v_cvt_f64_i32/_u32, even where the integer would fit)_e64,clamp,omod,neg,abs, DPP and SDWA_e32(v_cvt_f32_f64_e32 v13, v[20:21]=141f1a7e). The plain and_e32spellings are accepted, as for the neighbouring forms.check_cvt_f64_f32_lowering,v_cvt_f32_f64_e32of the 1.0 pair used to be listed as a refused consumer. It is now a positive check, as in #1575. The integer-pair control and the round-toward-zero refusal are unchanged.requires roundingfor1 + 2^-24,2^24 + 1, ±0.1,1e300,FLT_MAX * 2,FLT_MAX + 2^102/2^103,1e-50and two values just below the smallest normal.v_cvt_f64_i32pair of the known source 16777217 as integer origin.Test
draw-cvt-f32-f64, registered aspixel_aot_cvt_f32_f64_hardwareand_warp, with a 60 s timeout, skip code 77 and its ownFORM_COVERAGE_RECORD. The LLVM 15 round trip covers the fixture.0x00800000,0x80800000,0x7f7fffff,0xff7fffff, ±1.0 and0x3f800001/0xbf800001. The results are exported raw through the uint target with xor masks and compared bit for bit with the original binary32 pattern.pixel_mismatch.main: with thetools/pixel_aot.pyfrommain, the mode fails withValueError: Unsupported instruction 23: v_cvt_f32_f64_e32 v13, v[16:17].The semantics come from LLVM 15 and are not checked against the ISA document or measured on a console.
On commit
d6624c0e(rebased onf0c0ed86), with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818 and Windows 11 build 26200, debug layer unavailable:The pure checks and the LLVM 15.0.7 binary round trip pass.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:47:22Z.
Review: COMMENTED
Peer review at
head_sha:d6624c0eba9c624c96b9b1901ad45e947b9b058cFindings
No defects found.
tools/pixel_aot.py:cvt_f32_f64_exact_bitscleanly restricts lowering to exact normal binary32 values and signed zeros (round-tripping throughstructandcvt_f64_f32_words, rejecting non-finite, subnormal, and rounding cases), andlower()enforces("static", low, high)provenance, entry-mask execution, register bounds, and non-pending/non-sample-dest operands without emitting HLSLdouble.tests/pixel_aot_check.py,tests/form_coverage_check.py,CMakeLists.txt,docs/experiments.md: thorough negative controls, wrong-reference pixel mismatch checks, and coverage records; 100% title-neutral.Verification
python3 -B -c "... pixel_aot_check.check_cvt_f32_f64_lowering()": PASS (exit 0).python3 -B -c "... pixel_aot_check.check_cvt_f32_f64_binary(Path(d), 'llvm-mc-19', 'llvm-objcopy-19', '/usr/lib/llvm-19/lib/libLLVM-19.so')": PASS (exit 0).if record[0] != "static":withif False:intools/pixel_aot.pyand rancheck_cvt_f32_f64_lowering()— failed as expected (IndexErroron integer-origin pair test, exit 1); restored cleanly (git status --shortclean).tests/form_coverage_check.py: PASS (16.6s, exit 0).--preset dev):cmake --build --preset dev --target offscreen_check -- -j 6(10.32s);ctest --preset dev -R '^(pixel_aot_cvt_f32_f64_warp|pixel_aot_cvt_f64_f32_warp|pixel_aot_cvt_int_f64_warp)$' --parallel 4 --no-tests=error --output-on-failure: 3/3 passed (7.06s:pixel_aot_cvt_f32_f64_warp2.26s,pixel_aot_cvt_int_f64_warp4.37s,pixel_aot_cvt_f64_f32_warp6.98s)./O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 6(7.86s);ctest --preset release -R '^(pixel_aot_cvt_f32_f64_warp|pixel_aot_cvt_f64_f32_warp|pixel_aot_cvt_int_f64_warp)$' --parallel 4 --no-tests=error --output-on-failure: 3/3 passed (6.96s:pixel_aot_cvt_f32_f64_warp2.28s,pixel_aot_cvt_int_f64_warp4.79s,pixel_aot_cvt_f64_f32_warp6.88s).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:36:18Z.
Review: COMMENTED
Verified at
head_sha:d6624c0eba9c624c96b9b1901ad45e947b9b058c(0 P1, 0 P2).Scope & Semantics
tools/pixel_aot.py,tests/pixel_aot_check.py,tests/form_coverage_check.py,CMakeLists.txt(test-onlypixel_aot_cvt_f32_f64_{hardware,warp}), anddocs/experiments.md.v_cvt_f32_f64lowers only exact staticv_cvt_f64_f32pairs (normal binary32 or ±0.0), verified by round-trip bit equality incvt_f32_f64_exact_bitswithout reading any MODE rounding/denorm field; rejects infinities, NaNs, subnormals, values requiring rounding, integer-origin pairs, unknown/clobbered/divergent pairs, masked regions,_e64, and all modifiers.Verified
git diff --check origin/main...HEAD-> cleanpython3 tests/docs_links_check.py-> passed (16 Markdown files, 349 links)python3 tests/bidi_controls_check.py-> passed (1277 tracked files)pixel_aot_check.check_cvt_f32_f64_lowering()andpixel_aot_check.check_cvt_f64_f32_lowering()-> OKllvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -show-encoding:v_cvt_f32_f64 v13, v[20:21]->14 1f 1a 7e,v_cvt_f32_f64_e64 v13, v[20:21]->0d 00 8f d5 14 01 00 00--preset dev):offscreen_checkbuilt (10.40s),ctest --preset dev -R 'pixel_aot_cvt_f32_f64|pixel_aot_cvt_f64_f32'4/4 passed (7.58s)/O2(--preset release):offscreen_checkbuilt (8.32s),ctest --preset release -R 'pixel_aot_cvt_f32_f64|pixel_aot_cvt_f64_f32'4/4 passed (7.51s)tests/form_coverage_check.py-> passed (16.96s)cvt_f32_f64_exact_bits->pixel_aot_check.check_cvt_f32_f64_lowering()failed as expected (AssertionErroron subnormal diagnostic).record[0] != "static"integer-origin guard intools/pixel_aot.py->pixel_aot_check.check_cvt_f32_f64_lowering()failed as expected.AI-assisted; commands listed were executed locally.