shader: lower v_cvt_i32_f64 and v_cvt_u32_f64 on proven pairs in pixel_aot #1568
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1575"
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-24T14:31:39Z.
Fixes #1492
Change
tools/pixel_aot.pynow lowersv_cvt_i32_f64andv_cvt_u32_f64, but only when it can prove where the binary64 pair came from. This is the restricted slice agreed in #1492, and no HLSLdoubleis emitted.Provenance tracking.
lower()gains af64_wordsmap from each word's SSA name to(record, 0|1), which says which pair the word belongs to and whether it is the low or the high word.v_cvt_f64_i32andv_cvt_f64_u32record("i32"|"u32", <uint source>).v_cvt_f64_f32of a static source records("static", low, high).v_mov_b32carries the entry to its new SSA value, including copies of copies.close_region(one-armed and if/else masked regions) keeps an entry only when every path carries the same record and role. The conversions themselves stay refused inside a masked region.What is accepted. Both words must carry the same record, with the low word as word 0 and the high word as word 1.
v_cvt_f64_i32pair read byv_cvt_i32_f64, and av_cvt_f64_u32pair read byv_cvt_u32_f64, return the original source word. Every 32-bit integer is exact in binary64.v_cvt_f64_f32value is truncated toward zero at translation time withmath.trunc. It is accepted only if it is finite and the result fits the destination.What is refused:
_e64and every modifier (clamp,omod,neg,abs)LLVM 15 prints the unmodified form as
_e32(v_cvt_i32_f64_e32 v13, v[20:21]=14071a7e,v_cvt_u32_f64_e32=142b1c7e). DPP and SDWA do not assemble for these opcodes.Changed controls.
check_cvt_f64_int_loweringandcheck_cvt_f64_f32_loweringused to listv_cvt_i32_f64of an i32 pair and both out-conversions of a 1.0 pair as refused consumers. This slice supports those cases, so they move out of the reject tuples and into the new mode as positive checks, like the comparison control in #1363. The cross casev_cvt_u32_f64of an i32 pair stays refused there, as dov_cvt_f32_f64, binary64 arithmetic and the other consumers.Test
New mode
draw-cvt-int-f64, registered aspixel_aot_cvt_int_f64_hardwareand_warp. It has a 60 s timeout, skip code 77 and its ownFORM_COVERAGE_RECORD, and the LLVM 15 round trip covers its programs.Round trips: the #1363 rows (0,
INT_MIN,INT_MAX, -1,UINT_MAX,0x7fffffff, around 2^24). They are checked both directly and through a copy of the pair into another pair.Static truncation: ±1.5, ±0.75, -0.0, and the largest values below 2^31 and 2^32.
Export: values go out through the uint readback with xor masks, and each result is compared bit for bit against an independent reference.
Refusals: the lowering controls check every refusal listed above, including one-word clobbers on each half and joins with different sources, signedness or words. Joins with equal provenance are accepted.
Wrong references: swapped signedness, rounding instead of truncation at ±1.5, and a swapped word each have to report
pixel_mismatch.Mutations: each of these makes the checks fail:
roundinstead ofmath.truncWith
main'stools/pixel_aot.pythe mode fails withValueError: Unsupported instruction 23: v_cvt_i32_f64 v13, v[16:17].The semantics come from LLVM 15
VOP1Instructions.td. They are not checked against the ISA document and not measured on a console.Run on commit
f90f1c3c, rebased on800a4500, 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 also pass.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:37:58Z.
Review: COMMENTED
Looks good overall. Reviewed the provenance-restricted
v_cvt_i32_f64/v_cvt_u32_f64lowering intools/pixel_aot.pyand the tests intests/pixel_aot_check.pyatf90f1c3cfe97de6067715b04e286e5c3ff57c399.Semantic & Edge-Case Review
f64_words):v_cvt_f64_i32/v_cvt_f64_u32and staticv_cvt_f64_f32tag both destination words with(record, 0)and(record, 1).v_mov_b32preserves provenance when copying a VGPR, while any other write assigns a freshalu*name not inf64_words, invalidating partial overwrites.i32 <-> u32), swapped/clobbered words, divergent joins, raw constants,_e64spellings/modifiers (clamp,-v,|v|,mul:2), DPP/SDWA, masked execution, and pending/overlapping sample registers are all refused.v_cvt_f64_f32sources checkmath.isfinite(value), truncate toward zero (math.trunc(value)), and verify exact range ([-0x80000000, 0x7fffffff]fori32,[0, 0xffffffff]foru32), emitting{result & 0xffffffff}uwithout HLSLdouble.check_cvt_int_f64_lowering(),check_cvt_int_f64_binary(), andcheck_cvt_int_f64_draws()cover round-trips, static truncations (including-0.75,-0.0,±1.5,2^31,INT_MIN), signedness/rounding/word/slot/sentinel mismatches, and LLVM encoding/disassembly round-trips.Verification
python3 -B tests/pixel_aot_check.py— passed.check_cvt_int_f64_binarywithllvm-mc-19,llvm-objcopy-19,libLLVM-19.so— passed.python3 -B tests/docs_links_check.pyandpython3 -B tests/bidi_controls_check.py— passed.--preset dev):offscreen_checkbuilt (3.96s),ctest --preset dev -R '^pixel_aot_cvt_int_f64_'2/2 passed (4.95s)./O2(--preset release):offscreen_checkbuilt (1.45s),ctest --preset release -R '^pixel_aot_cvt_int_f64_'2/2 passed (4.65s).tests/pixel_aot_check.py— passed (13.5s).AI-assisted; commands listed were executed locally.