shader: lower v_cvt_f64_f32, the widening half of the pair #140
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/140"
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 Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T13:56:39Z.
What this adds
#138 lowers
v_cvt_f32_f64(adoublenarrowed to one dword). This is the other direction — anf32widened to adoublein two VGPRs — and it was refused for the same reason: before #138 nothing inemithad adoubleat all.The lowering is the mirror: an
i32(every VALU source is one) bitcasts tof32, widens withfpext, and its bits become ani64thatsplit64writes to the pair. That is the shape every 64-bit VALU result already takes (v_lshlrev_b64and friends).Three refusals, each masking the next
The validator caught three separate mistakes. Worth recording because a test that only proves "it translated" would have hidden all of them:
1.
FPExt only operates on FP—%10 = fpext i32 %9 to doubleThe source register holds an
i32, not anf32. Bitcast first. This is exactly whyv_cvt_f32_f16goes throughlegacyF16ToF32(integer in, float out) instead of casting the raw register.2.
Flags must match usage. declared=…4, actual=…0— theDOUBLESbitI had removed it after an earlier experiment suggested widening did not need it. That experiment was invalid: it passed only because the
fpextwas still malformed, so the module never contained a realdouble. Once the bitcast was right, the bit was required. Both directions needD3D_SHADER_FEATURE_DOUBLES.A false green that teaches the wrong lesson is worse than a red — this is the second time in this pair of PRs that an error message looked like progress.
3.
Flags must match usage. declared=…40000004, actual=…40100004—flags::INT64Taking the widened value's bits as an
i64and splitting them is 64-bit integer work.v_lshlrev_b64sets that flag before itssplit64call for the same reason; I had not.The test checks the value, not the lowering
v_cvt_f64_f32_widens_one_dword_into_twomoves the pair's high dword intov0(whichbuild_csstores) and compares it againstf64::from(f).to_bits() >> 32for 1.0, 2.0, −1.0 and 0.0, on both the hardware adapter and WARP.My first version asserted only
!shader.dxil.is_empty()— and it passed with a lowering that wrote only the low half. I found that by mutating the code, not by reading it. That is a test that measures nothing, so it is gone.Verification
Windows 11, RTX 5070 Ti, Rust 1.98.1 (pinned), MSVC 14.44.35207, Windows SDK 10.0.26100.0,
VICTORY_DXILset. No game files.215 rather than #138's 214 because two weak tests were removed and one strong one replaced them.
What is not claimed
Neither instruction appears in #132's log. The two shaders that stop on
v_cvt_f32_f64(5dc3b25986622949,6f225b641c5b0708) contain the narrowing one. Whether they also contain this one, or stop at something else next, I do not know. This completes a pair, it does not fix a reported failure.Only the conversion pair exists.
gfx10/fields.rsnamesv_add_f64,v_mul_f64,v_min_f64,v_max_f64,v_ldexp_f64and the compare forms; none of them lower. Now thatTypes::f64,TypeDef::Double,Cast::FPTruncandCast::FPExtall exist, each is a small addition — but each is a claim I have not tested, so none are here.Relation to #138
Independent branch, same files. #138 adds
Double/f64/FPTruncand the narrowing; this addsFPExtand the widening. This one does not apply tomainwithout #138 (it usesTypes::f64), so it should land after it — or I can squash both into one branch if you would rather review the pair together.Imported from Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T14:10:35Z.
Superseded by #142, which is all three of these in one branch.
They were split because each was verifiable on its own, but two of them cannot apply to
mainwithout the first — so reviewing them apart means reviewing a branch that does not build. #142 has the same content with one description and one diff.Closing rather than leaving three open PRs for one feature.
Pull request closed