shader: lower compute v_ldexp_f32 #3884
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3884
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3882"
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?
@Leyukaka on GitHub · 2026-12-02 18:40 UTC · original
Leyukaka:take-1918→main· +322 −2 · 4 files · 2 commits · openCarries #1918 by @henriazz10 with their commits. Refs #721.
#1918 conflicts with
mainand has had no author update since 11-25. The author's commit is kept with its authorship and message (08620337b, a cherry-pick of89b9aa85onto currentmain); one commit on top adds the lane my review of 11-28 asked for. @henriazz10, if you would rather continue in #1918, say so and I will close this PR.Change
From #1918 (see its description for the full design, the fixture and the review history):
tools/compute_store_aot.pylowersv_ldexp_f32tof32_ldexp(S0, S1), only under the caller statementf32_mode="ieee-rne-denorm"(--f32-mode). With no statement, or any other mode, the instruction is refused.compute_store_aot_ldexp_f32_{warp,hardware}compare 320 words with an independent bit-level Python model.Conflicts with
mainare resolved inside the cherry-pick, the way pigalot's merge90b39c31resolved them:CMakeLists.txt:main'scompute_store_aot_alu_bfm_*block, then theldexp_f32block.tools/compute_store_aot.py:main's wave64 docstring and its laterwave_sizecheck are kept; the branch's olderwave_size not in (None, 32)check is dropped.Added here, in
e68698e83:if (e <= 0)->if (e < 0)inf32_ldexpsurvived the draw. Lanes 32..63 of word 0 now subtract 247 from S1 (three new fixture lines). Lane 32 scales0x3fc00000(1.5) by -127, and word 128 must read the denormal0x00600000; the edit gives0x00400000.ldexp_f32_controls()asserts the model value at word 128.ldexp_f32_drawadds the edit to its recompiled-HLSL mutations (six now).docs/experiments.mddescribes the new lane and mutation.Validation
Windows, MSVC, dev preset, head
e68698e83.Result: both passed, on WARP and on a hardware adapter. The draw runs the six recompiled-HLSL mutations, and each must fail.
Known limits
Still open from other reviews of #1918, not covered here:
e >= 255->e > 255changes no fixture word (pigalot, JohnConnorNPC). A lane with S00x3fffffff, S1128, expecting0x7f800000, would catch it.clamp(asint(b), -512, 512)->min(asint(b), 512)) changes no fixture word (JohnConnorNPC). A lane with S00x00000001, S10x80000000, expecting0x00000000, would catch it.F32_HELPERS["ldexp"]still says the translator does not read MODE and does not mention thef32_modegate.226e0d59(the mode gate) is answered by the author's commit, per pigalot and JohnConnorNPC, but still needs R0Y00's re-review.Other limits:
binaryround trip was not rerun with the three new fixture lines.@R0Y00 on GitHub · 2026-12-02 19:06 UTC · original · reviewed
I checked
e68698e8against thef32_moderequest on #1918. The offline lowerer and CLI require the explicit IEEE RNE mode with denormals preserved, and the new lane reaches the exact zero-exponent boundary. Independent MSVC Debugctest --preset dev --no-tests=error -V -j 1 -R '^compute_store_aot_ldexp_f32_(warp|hardware)$'passed 2/2, including all six HLSL mutation controls, on Windows 11 build 26300, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 with the debug layer on. Please coordinate the landing branch with @henriazz10, as offered on #1918. The same evidence can carry to the original PR if it takes the boundary fixture.@R0Y00 on GitHub · 2026-12-03 03:52 UTC · original · reviewed
I followed up on the two open #1918 boundary controls at
e68698e8(clean trial merge withmain41a83a9a).ldexp_f32_controls()and both existingtests/compute_store_check.py draw-ldexp_f32 <dxc> <offscreen_check> <warp|hardware>runs passed, including the existing controls. The original fixture also passed both adapters with eithere >= 255changed toe > 255orclamp(asint(b), -512, 512)changed tomin(asint(b), 512).I tried both suggested inputs in a temporary source fixture, varying the exponent delta per lane so DXC still compiled the branch. With both guards intact the entire 320-word readback matched on each adapter. With the first edit, lane 0 with S0
0x3fffffff, S1128read back0x7fffffffinstead of0x7f800000at word 0. With the second edit, lane 0 with S00x00000001, S10x80000000read back0x7f800000instead of zero at word 1. Both failures were identical on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 (Windows build 26300, SDK DXC, debug layer enabled, no skips). These inputs distinguish the two mutations independently and can be carried into whichever PR the original author chooses.@R0Y00 on GitHub · 2026-12-03 07:36 UTC · original
Independent check of
e68698e8: the existingcompute_store_aot_ldexp_f32_(warp|hardware)fixture passed 2/2 on Windows 11 build 26300, SDK DXC, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, with the debug layer on and no skips. I also verified the two outstanding boundary suggestions from #1918 by replacing the first result in the existing source-built program:v_ldexp_f32of0x3fffffffand128produced0x7f800000. Changinge >= 255toe > 255produced0x7fffffffon both adapters.v_add_nc_u32_e32 v10, 1, v3and use exponent0x80000000. The original produced positive zero. Replacing the exponent clamp withmin(asint(b), 512)produced0x7f800000on both adapters. Computing the source word from the lane lets this exercise the normal translator path; a literal subnormal as the float source is refused.Both original cases matched 320/320 words per adapter; each mutation mismatched 64/320. Please include these as regression rows and mention the explicit f32 mode gate in the helper comment. This checks desktop readback against the bit model.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.