shader: lower v_ashrrev_i64 and v_mad_i32_i24 in the direct C++ compute path #2994
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!2994
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@legacy-code-archaeologist on GitHub · 2026-11-27 03:36 UTC · original
legacy-code-archaeologist:shader/direct-signed-forms→cpp-migration· +228 −3 · 4 files · 1 commits · merged 2026-11-27 03:47 UTCChange
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
@MasterDomino on GitHub · 2026-11-27 03:47 UTC · original · approved these changes
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.