Skip to content

shader: lower v_bfm_b32 and v_bcnt_u32_b32 in the mesh frontend (Part of #2413) - #3655

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
mumba17:shader/mesh-bfm
Dec 1, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
mumba17:shader/mesh-bfm

Conversation

@mumba17

@mumba17 mumba17 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Part of #2413.

The shared ALU already lowers both instructions for direct compute: v_bfm_b32 since #2986, and v_bcnt_u32_b32 through unaryBits (popcount) plus the second source. The mesh frontend's vector ALU list did not admit either one, so they were refused as unsupported mesh instruction or EXEC state. This PR adds both to that list as two-source operations, so the uniform-result proof checks both operands.

Census (454 cached slot 57 requests, #3416 layout, main plus #3635/#3645/#3646):

  • Before: v_bfm_b32 is the first refusal for 40 requests.
  • After: none of the 40 stops at v_bfm_b32 or v_bcnt_u32_b32. They now stop at later refusals: 19 unsupported mesh SAVEEXEC operands, and the rest at several smaller reasons (v_cvt_f16_f32, v_cmpx_*, other SAVEEXEC shapes).
  • On main alone, v_bfm_b32 is no longer a refusal reason.

Tests (tests/native_direct_mesh_check.py):

  • v-bfm-b32: v_bfm_b32 v1, v0, 2 feeds the position. The check pins shl 1, width, the - 1 and the & 31 offset of 2.
  • v-bcnt-u32-b32: v_bcnt_u32_b32 v1, v0, 5 feeds the position. The check pins unaryBits op 31 plus 5.

Each of these mutations fails native_direct_mesh:

  • v_bfm_b32 not admitted;
  • width and offset swapped in the shared lowering;
  • the - 1 dropped;
  • v_bcnt_u32_b32 not admitted;
  • the + src1 dropped.

ctest -R "mesh|compile_dxil|bfm": 215/215 with the v_bfm_b32 change; native_direct_mesh passes again with v_bcnt_u32_b32 added.

🤖 Generated with Claude Code

The shared ALU already lowers v_bfm_b32 for direct compute (R0Y00#2986):
((1 << (S0 & 31)) - 1) << (S1 & 31). Admit it in the mesh frontend's
vector ALU list with two sources, so uniformity proofs see both.

The test builds v_bfm_b32 v1, v0, 2 into the position and pins the width,
the minus one and the offset operand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the mesh ALU admission for v_bfm_b32 and v_bcnt_u32_b32. Both reuse the shared lowering and declare both operands for the uniformity analysis. The tests tie the resulting mask/count to the exported position. ctest --test-dir <build> --no-tests=error -j1 -R '^native_direct_mesh$' --output-on-failure passed on the Windows Release integration.

@R0Y00
R0Y00 merged commit 436242d into R0Y00:main Dec 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants