pixel_aot: use binary16 encodings for inline float constants in v_pack_b32_f16 #1013
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!1013
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1013/head"
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-11-23 21:15 UTC · original
Leyukaka:pack-inline-f16→main· +48 −5 · 3 files · 3 commits · merged 2026-11-23 21:57 UTCChange
v_pack_b32_f16lowers through the integer table, so an inline float constant went throughscalar_u32, which packs a decimal token as binary32. Onmain,v_pack_b32_f16 v12, 1.0, v18emitsso the low half is
0x3f800000 & 0xffff = 0. LLVM types the sources ofv_pack_b32_f16as binary16 and prints an inline float constant on them as a decimal float, so its binary16 encoding is the operand (1.0is0x3c00), astools/pixel_aot.pyalready assumes for the packedVOP3Pforms; this is not measured on the console. This change maps the tokens of the existingINLINE_F16table (0.5,1.0,2.0,4.0, their negations and0.15915494) to those encodings for this opcode only, and refuses any other decimal float (llvm-mcprints those as hex on a binary16 operand). Registers, hex literals and integer inline constants are unchanged. With it the same line isdocs/experiments.mdsays so in thev_pack_b32_f16paragraph. Refs #1001.Verification
On
87c69f68(based onmainat1f34ba1), Windows 11, Python 3.14:check_pack_b32_lowering()now translates1.0,-0.5and0.15915494sources and requires15360u,47104uand12568u, and refuses3.0and0.25. The controls pass with this change. With the new check and themainversion oftools/pixel_aot.py, they fail on the first of those lines (AssertionError: precise float alu21 = asfloat((15360u & 0xffffu) | ...). Thepixel_aot_pack_b32draws, which use no inline float constant, still pass on WARP and on an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101, not skipped), and the docs check passes.Evidence and follow-up
The binary16 inline-constant encodings come from the
INLINE_F16table thattools/pixel_aot.pyalready uses for the packedVOP3Pforms. No new fixture is added; the draws do not use inline float constants, so the check is static.Checklist
AI-assisted.
@R0Y00 on GitHub · 2026-11-23 21:27 UTC · original
I independently assembled all three forms with LLVM 15 for gfx1013. They are inline selectors (242 for
1.0, 241 for-0.5, 248 for0.15915494), without a literal word, and the new Python lowering assertions pass. Please put one of those actual encodings into the existing pack draw/binary round-trip. Use a nonzero neighboring half so the raw readback catches0x0000from the old f32-low-half behavior. The desktop readback would verify the lowering path; keep the current qualification about console evidence.@R0Y00 on GitHub · 2026-11-23 21:41 UTC · original
I added the inline
1.0variant in23ab53d2and kept all existing pack cases. LLVM 15 assembles and round-trips it with the other binary fixtures. The draw compares0xc0003c00and catches0xc0000000, the old f32 low-half result, on both the local hardware and WARP runs (ctest --preset release --no-tests=error -R '^pixel_aot_pack_b32_(hardware|warp)$' -V, 2/2).