shader: lower v_mad_u64_u32 and v_mad_i64_i32 in pixel_aot #1271
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1278"
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-24T06:30:30Z.
Change
tools/pixel_aot.pynow lowers the two gfx1013 VOP3b 64-bit multiply-adds,D = S0 * S1 + S2modulo 2^64. Their destination is a VGPR pair, andS2is 64 bits wide.v_mad_u64_u32vcc,vcc_lo, an SGPR or an SGPR pair) and tracked like a compare result forv_cndmask_b32v_mad_i64_i32nullis accepted, because the signed carry is not established herea * band the existingmul_hi_u32/mul_hi_i32helpers. The add runs on twouintwords, so no 64-bit HLSL type is needed. All operands are read before the destination is written.VOP3Instructions.tdatllvmorg-15.0.7, which defines both asVOP3b_I64_I1_I32_I32_I64(a 64-bit result and a 1-bit carry per lane). This is not checked against the ISA document and not measured on a console.S2can be a VGPR pair, an aligned SGPR pair or an inline constant from -16 to 64, sign-extended. A literalS2is refused, because its 64-bit extension is not established. LLVM 15 assembles unaligned VGPR pairs, so they are accepted; hardware legality is assumed, not measured.clamp, operand and output modifiers, the_e64spelling, an invalid pair or mask width, unwritten registers and DPP. A later read of a mask after the signed form is refused as an unwritten register.draw-mad64(pixel_aot_mad64_hardwareandpixel_aot_mad64_warp, 60 s timeout, skip code 77 on hardware, its ownFORM_COVERAGE_RECORD), sopixel_aot_predicate_rounding_*is unchanged.u64_pair,u64_mixed,i64_pairandi64_mixed.S2.pixel_mismatch. Among them are swapped signedness, a dropped carry, a dropped low-to-high carry, zero-extended inline negatives and a dropped high word ofS2.tests/form_coverage_check.pychecks both forms as covered.docs/experiments.mdhas one paragraph, after the carry-in paragraph.INTEGERorINT_MULTIPLYtables, so this does not overlap #532 or #526 (coordinated in #532).Testing
On commit
d5f83f7e(rebased on99cde8d6), with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818 and Windows 11 build 26200, debug layer unavailable:pixel_aot_check.py controls,form_coverage_check.py,rdna2_tools_check.py,pso_readiness_check.pyanddocs_links_check.py.pixel_aot_check.py binary) passes.main'stools/pixel_aot.pythe new mode fails withValueError: Unsupported instruction 23: v_mad_u64_u32 v[12:13], vcc_lo, ....pixel_aot_mad64_warpred: swapped signedness, a dropped carry-out, and a dropped low-to-high carry.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:31:00Z.
Review: COMMENTED
Reviewed PR #1278 at commit
d5f83f7ed5a3e2adb8ac2f604afbb79053d5d47b.Verification
git diff --check origin/main...HEAD: passed.tests/pixel_aot_check.py: passed.tests/rdna2_tools_check.py: passed (133 tests, 16 skipped).tests/form_coverage_check.py: passed.tests/docs_links_check.py: passed (16 Markdown files, 284 links).tests/bidi_controls_check.py: passed (1067 tracked files).tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: stopped earlier incheck_f16_cvt_int16_binaryonv_cvt_f16_i16_e32 v1, 0xfff0(pre-existing LLVM-19 vs LLVM-15 encoding difference, unrelated to this PR).tests/form_coverage_check.py: passed (40.03s).--preset dev):offscreen_checkbuilt cleanly;ctest -R '^(pixel_aot_mad64_warp|pixel_aot_warp|pixel_aot_integer_nc_warp)$'3/3 passed (pixel_aot_integer_nc_warp1.21s,pixel_aot_mad64_warp1.45s,pixel_aot_warp15.84s)./O2(--preset release): built cleanly; 3/3 passed (pixel_aot_integer_nc_warp1.25s,pixel_aot_mad64_warp1.46s,pixel_aot_warp15.51s).Code Findings
tools/pixel_aot.py:v_mad_u64_u32requires a validLANE_MASKcarry-out and computes exact 64-bit carry (m{i}h1 < m{i}ph || m{i}hi < m{i}h1);v_mad_i64_i32is restricted tonullcarry-out so no unverified signed carry state is exposed.src0,src1,src2lo/hi) are latched into locals before writingv[first:last]or updating the carry-out mask, safely handling overlapping source/destination pairs.int64_operand(..., encoding="e64", position=2)handles VGPR/SGPR pairs and sign-extended inline constants-16..64while rejecting literals, modifiers, unaligned pairs, andnull/invalid masks onu64_u32.tests/pixel_aot_check.pycovers static acceptance/rejection, carry-mask tracking, 4-program bit-for-bit WARP readback (u64_pair,u64_mixed,i64_pair,i64_mixed), andMAD64_WRONGnegative controls.