shader: lower v_ashrrev_i64 and v_mad_i32_i24 in the direct C++ compute path #2994
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2994"
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 legacy-code-archaeologist on 2026-11-27T03:36:40Z.
Change
The direct compute frontend lowered
v_lshrrev_b64,v_lshlrev_b64(#2952) andv_mad_u32_u24, but refused their signed counterparts withdirect DXIL lowering for <name>. It now lowers both. Refs #2991, part of the integer-ALU coverage in #2935.v_ashrrev_i64: an arithmeticashr i64of S1 by S0[5:0]. The shifted value accepts the same operands as the logical shifts. The one difference followsgfx2hlsl.py'si64_words(signed=True): a 32-bit literal is sign-extended for this form. The logical shifts still zero-extend it.v_mad_i32_i24: sext(S0[23:0]) * sext(S1[23:0]) + S2 modulo 2^32, thegfx2hlsl.pyVOP3-table expression. Modifiers stay refused, as for the other integer VOP3 forms.Verification
Commit
f7a27220oncpp-migration4ff5e36d, Windows 10.0.26100.9711,devpreset. NVIDIA Quadro M1000M, driver 32.0.15.7371, debug layer unavailable.ctest --preset dev --no-tests=error -R '^native_signed_forms_|^native_shift64_|^native_direct_container$': 3 passed, 2 skipped.native_signed_forms_controlspassed. It compiles sixv_ashrrev_i64sources and the multiply-add, and checks the modules withdxc -dumpbin: exactly oneashr i64per shift program, and an arithmetic shift right withmul i32for the multiply-add. It also checks that the zero-extended-literal, logical, unsigned and unmasked references each differ.native_signed_forms_hardwareandnative_shift64_hardwareskipped (77). They need shader model 6.6 with wave32. The readback is not measured here.native_shift64_controlspassed, so the logical shifts are unchanged.python -B tests/docs_links_check.py: ok.Evidence and follow-up
The words were assembled with LLVM 15.0.7 (
clang -cc1as -triple amdgcn -target-cpu gfx1013 -filetype asm -show-encoding).Shift dispatches. They reuse
native_shift64_check.compute_programand its store layout (8 bytes per lane, 256 bytes per group of 32), with thev_ashrrev_i64opcode (VOP3 0x301). The amounts are 0, 1, 31, 32, 33 and 63. The sources are inline -1, -16, 64 and 1, the literal 0x80000001, and the negative SGPR pair 0x89abcdef:01234567.Multiply-add dispatch. With n = lane + 32 * group:
Bit 23 is set in many factors, and the bits above it are nonzero in all of them.
tools/compute_store_aot.pystill refusesv_mad_i32_i24. That is a separate path and is not touched here. The note isdocs/experiments/native-direct-signed-forms.md.Checklist
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T03:47:18Z.
Review: APPROVED
Review of head
f7a27220. CI on the head is green. This is the wave32 SM 6.6 readback that was not measured on your adapter. Approving and merging.Code read:
v_ashrrev_i64: it joins the 64-bit shift path and emitsashr i64. A 32-bit literal is sign-extended only for this form, asgfx2hlsl.py'si64_words(signed=True)does, while the logical shifts keep zero-extending it.v_mad_i32_i24:(x << 8) >> 8arithmetic on each source, thenmulandaddmodulo 2^32.Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), plus WARP, release. This was tested together with #2989, #2990 and #2992 merged onto
cpp-migration4ff5e36d; all four merge cleanly with each other.ctest --preset release --no-tests=error -R '^(native_.*|startup_compute_dispatch(_.*)?_(warp|hardware)|startup_slot67_indirect_dispatch_warp|startup_compute_translate_e2e_warp|startup_stream_draw.*|startup_native_graphics.*)$'gives 88 tests, 84 passed and 4 skipped (77, WARP has no 32-lane waves).native_signed_forms_hardwarepassed: "v_ashrrev_i64 by 0, 1, 31, 32, 33 and 63: all 6 sources and guards matched", and "v_mad_i32_i24: 64 words of two groups and the guards matched".native_signed_forms_controls,native_shift64_controlsandnative_shift64_hardwarepassed, so the logical shifts are unchanged.Mutations here:
lshrforv_ashrrev_i64failsnative_signed_forms_hardware: inline -1 shifted by 1 got0x7fffffffin the high word.v_mad_i32_i24fails it too ((8, '0x6f000000', '0x91000000')).Open, not blocking: the literal extension is inherited from the Python translator and is not measured on the console. Signedness-dependent extension of a 64-bit integer literal is an assumption. The fixture's literal case pins it, so a later measurement will show up as a fixture change. I will close #2991 by hand.
AI-assisted; the commands above were run locally.