shader: lower compute v_bfm_b32 #1573
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1580"
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 Asimmimx on 2026-11-24T14:34:44Z.
Change
Refs #1546. This lowers
v_bfm_b32in the compute translator (tools/compute_store_aot.py).v_bfm_b32 vD, src0, src1becomes(((1u << (src0 & 31u)) - 1u) << (src1 & 31u)):0x7fffffff.Sources for these semantics:
SIInstructions.td,BFMPatterns:(shl (add (shl 1, a), -1), b)is selected toV_BFM_B32_e64 a, b.nir_opcodes.pybfm:((1u << (src0 & 0x1F)) - 1) << (src1 & 0x1F).The code change is one
ALUentry, plus the opcode appended to the two-source VOP3 matcher:(v_mul_lo_u32|v_bfm_b32). The fixture and controls are in a newtests/compute_alu_bfm_check.py, which imports the helpers oftests/compute_store_check.py. That file itself is unchanged.Fixture. It is a variant of
READ_COMPUTE:0x78000fff, 14 →0x0bffc000, 31 →0x78000000, 32 →0x07ff0fff, 149 →0xf81f8000.Checks that must fail:
- 1udropped, an inline width of 43, the cap operands swapped, and the cap read fromparams[0].z.Translator controls (refused with the existing messages):
|v1|,-v1,clamp,v[1:2],vcc_lo,exec_loand0.5forms;v_bfm_b32_e64,s_bfm_b32,s_bfm_b64,v_bfe_u32andv_bfi_b32;v256;s_waitcnt, the result used as an address or as a guard operand, and a chain that is too long.The new CTest is
compute_store_aot_alu_bfm_${adapter}, registered aftercompute_store_aot_f32. A "Bitfield mask (v_bfm_b32)" subsection is added todocs/experiments.md.Verification
Commit
6c0e5380(main) plus this change,devpreset, Windows 11 Pro build 26300.9974, DXC 1.8.2502.11.1002:73ff), driver 32.0.21045.29003, debug layer enabledThese also pass with the change:
compute_store_checkcontrol functions (alu,f32,scalar_alu,read,guard);draw-guard-readanddraw-f32on WARP;tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --check.Notes
llvm-mc19 for gfx1013._e64spelling is refused, on the assumption that LLVM 15 printsv_bfm_b32without it, as it does forv_mul_lo_u32.& 31ucannot be distinguished on the GPU, because DXIL masks shift amounts anyway. It is pinned by the translator text check.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:39:32Z.
Review: COMMENTED
Peer review at
993f4351(shader: lower compute v_bfm_b32): looks good, no blocking issues found.Code & Semantics Review
tools/compute_store_aot.py:v_bfm_b32lowers to(((1u << ({0} & 31u)) - 1u) << ({1} & 31u))and reuses the 2-sourceALU_SOURCE, ALU_SOURCEmatcher alongsidev_mul_lo_u32, enforcing known-word sources,v0–v255destination bounds, data-only usage, andALU_EXPRESSION_LIMIT.tests/compute_alu_bfm_check.py: covers VGPR, SGPR, literal, and inline-constant operands (including negative inline constants and widths 0–31), verifies hand-worked lanes and bit-by-bit CPU reference, rejects modifiers/other opcodes/unverified operands, and tests 7 wrong references + 4 DXC-compiled HLSL mutations indraw.CMakeLists.txt&docs/experiments.md: registerscompute_store_aot_alu_bfm_${adapter}and documents the lowering and controls.Local Verification
python3 tests/compute_alu_bfm_check.py controls— passedllvm-mc-19 -arch=amdgcn -mcpu=gfx1013 -show-encoding&-mcpu=gfx1030on fixturev_bfm_b32forms — passedpython3 tests/docs_links_check.py(16 Markdown files, 344 links) — passedpython3 tests/bidi_controls_check.py(1253 tracked files) — passed--preset devDebug &--preset release/O2):ctest --preset dev -R '^compute_store_aot_alu_bfm_warp$'(within 41/41 compute-store suite) — 41/41 passed (compute_store_aot_alu_bfm_warp3.81s)ctest --preset release -R '^compute_store_aot_alu_bfm_warp$'(within 41/41 compute-store suite) — 41/41 passed (compute_store_aot_alu_bfm_warp3.74s)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:08:23Z.
Review: COMMENTED
Re-review at
head_sha:fb05645f624a10e4ba4bd27799145db09ec7a34a(previously reviewed at993f4351).Findings
No P1/P2. No defect found.
main. I compared the patch of the old commit with the patch of this one (git range-diff, and a diff of the added and removed lines): the PR's own content is unchanged. Even the changed lines are the same; only the surrounding context differs.git merge-treeof the head against currentmain(80f413a7at the time) reports no conflicts (tree17774c0c).Verified
Limits: Linux x86-64 only. I did not rerun the Windows WARP/hardware
ctestfor this head (no Windows runner in this pass), so thedrawmode is covered only by the unchanged patch content and the earlier Windows results on the previous head.python3 -B tests/compute_alu_bfm_check.py controls-> exit 0.llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -show-encodingassemblesv_bfm_b32 v1, v2, v3andv_bfm_b32 v1, 5, s3.python3 -B tests/docs_links_check.py-> 16 files, 351 links OK.git diff --check HEAD^ HEADclean.v_bfm_b32template- 1uto- 2u;controlsfails with anAssertionError(exit 1). Restored withgit checkout -- .;git status --shortclean.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:39:54Z.
Review: COMMENTED
Thanks for this PR. The earlier review at
fb05645ffound no blocking issues, but #1596 has since been merged and this branch now conflicts withmain. Could you rebase onto the currentmainand push? After that I am happy to re-check the new head.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:44:19Z.
@Asimmimx could you rebase this branch onto current
mainand force-push?GitHub reports head
fb05645fas conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(b1a644ae):CMakeLists.txtdocs/experiments.mdtools/compute_store_aot.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:53:21Z.
Merged
origin/maininto this branch (plain merge, no rebase) to clear the conflicts, and pushedf32d6d1a.What I resolved (keep both sides):
CMakeLists.txt: kept main'sFORM_COVERAGE_RECORDenvironment on the neighbouring tests and added the same environment tocompute_store_aot_alu_bfm_*.tools/compute_store_aot.py: addedv_bfm_b32to main's current VOP3 binary regex (main had addedv_add_nc_i32,v_sub_nc_i32,v_bcnt_u32_b32there).docs/experiments.md: kept both sections.Commands executed locally:
python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check: okpython3 tests/compute_alu_bfm_check.py controls: okx2w_pipe.py win2025 1580 --patch <merge diff> --regex 'compute_store_aot_alu_bfm|compute_store_aot_.*_warp': dev 85/85, release 85/85 (includescompute_store_aot_alu_bfm_warpand_hardwareon WARP)compute_store_aot|compute_alu|startup_compute) had 3 failures outside this change:startup_compute_dispatch_texture_warp/_hardware(already failing on main) andcompute_store_aot_mac_f32_hardware(a mutation check of an existing test on the WARP adapter; its_warptwin passes).AI-assisted; commands listed were executed locally.