Skip to content

shader: lower v_rcp_iflag_f32 and v_ashrrev_i32 in the mesh frontend - #3709

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
mumba17:shader/mesh-rcp-iflag
Dec 2, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
mumba17:shader/mesh-rcp-iflag

Conversation

@mumba17

@mumba17 mumba17 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Refs #3641, #3703, #2413. Independent of #3708, but measured on top of it, since most of these programs only reach these instructions after #3708.

Problem

On a native Mesh86 capture with #3708 applied, v_rcp_iflag_f32 is the first refusal for 371 of the 1,569 distinct slot 86 programs, and v_ashrrev_i32 for 50. Both refuse with unsupported mesh instruction or EXEC state. The shared ALU already lowers both:

  • v_rcp_iflag_f32 takes the v_rcp_f32 path: fdiv float 1.0, a. The flag only changes IEEE exception reporting, which DXIL doesn't expose.
  • v_ashrrev_i32 is ashr src1, src0 & 31.

Change

Both join the mesh lane ALU list in src/gfx1013_direct_mesh.inl. The full_exec || exec_skip rule and the partial-write merge apply unchanged. Both have alu_rules entries, so, as for v_rcp_f32, a result whose sources are all uniform is recorded as uniform.

Census

Same capture as #3708 (main 1c634037, X2W_REFUSE_FIXED_MESH=1, X2W_NATIVE_MESH86=1, 600 s, 1,569 distinct .m86). Every request goes through compile_dxil … gfx1013-container-ms-texture-heap. Counts only.

First refusal #3708 #3708 + this PR
v_rcp_iflag_f32 371 0
v_ashrrev_i32 50 0
v_and_or_b32 — 144 (accepted by @SimSalabimse's #3659)
mesh heap slot lacks masked root constant provenance — 142
s_cmp_le_u32 — 85
raw buffer load needs offen with zero scalar offset and no modifiers 1 51
translate fully 389 389

So this PR moves 421 programs one wall further. None of them translates fully yet, and their next walls are listed above.

Tests

tests/native_direct_mesh_check.py:

  • v-ashrrev-i32 (v_ashrrev_i32 v1, 2, v0): an ashr of v0 by 2 & 31 reaches the exported X position.
  • v-rcp-iflag-f32 (v_rcp_iflag_f32 v1, v0): fdiv float 1.0, v0, whose bits reach the exported X.
  • Mutation. With the source change reverted, the check fails at v-ashrrev-i32 with unsupported mesh instruction or EXEC state: v_ashrrev_i32.
  • Regression. ctest -R "native_|mesh|gfx1013" -E "hardware|_warp": 786/788 pass. The same two local-only failures as in shader: lower s_not_b32, s_brev_b32 and s_bfe_i32 in the mesh frontend #3708: the SDK 10.0.26100 validator here only supports DXIL 1.7. They don't touch the mesh frontend.

Environment: Windows 11 build 26300, RTX 3090, MSVC 14.44, DXC from SDK 10.0.26100.

AI-assisted.

🤖 Generated with Claude Code

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed ecb4a19f by reading the diff; not built or run.

Verdict: approve. Both ops join the mesh lane ALU list and reach shared lowerings that already exist. v_rcp_iflag_f32 is the same 1.0 / x as v_rcp_f32 (gfx1013_compute_alu.inl:48-49, gfx1013_direct_compute.inl:3615). v_ashrrev_i32 is ashr src1, src0 & 31 (gfx1013_compute_alu.inl:10, :5779). No MUST.

  • NIT The PR body says neither op "counts as a uniform-proving source". Both have alu_rules entries (arity 2 and 1), so the mesh branch takes sources from them (gfx1013_direct_mesh.inl:1935). A result whose sources are all uniform is therefore recorded as uniform, exactly as for v_rcp_f32. That is correct; only the wording differs.
  • NIT v-rcp-iflag-f32 checks that the fdiv exists, not that it reaches the exported X, as v-ashrrev-i32 does with assert_position_x.
  • Checked, no finding:
    • 0x30020082 is VOP2 0x18 (v_ashrrev_i32 v1, 2, v0), and 0x7e025700 is VOP1 0x2b (v_rcp_iflag_f32 v1, v0).
    • The ashr pattern excludes an lshr.
    • For the iflag form, the only difference from v_rcp_f32 is exception reporting, which DXIL does not expose.
  • Note: this changes the same allowlist lines as #3704, so whichever of the two lands second needs a one-line rebase. I'll do it on #3704 if this one lands first.

Tests: v-ashrrev-i32 proves the signed shift reaches the export, and v-rcp-iflag-f32 proves the reciprocal path. The reverted-source mutation in the PR body hits the first. CI is still running at this head.

mumba17 added a commit to mumba17/Xbox2Windows that referenced this pull request Dec 1, 2026
Review follow-up on R0Y00#3709: v-rcp-iflag-f32 now checks that the reciprocal's
bits reach the exported X, as v-ashrrev-i32 already does.

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

mumba17 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @lukaslw-lab. Both NITs are fixed:

  • Wording. The description now says the two ops have alu_rules entries, so a result with all-uniform sources is recorded as uniform, the same as v_rcp_f32.
  • v-rcp-iflag-f32. It now follows the fdiv through the bitcast to the exported X with assert_position_x (745d65b5).

On the overlap with #3704: whichever of the two lands second needs a one-line rebase, so I'll take it if mine is second.

AI-assisted.

mumba17 and others added 2 commits December 1, 2026 12:25
Both are already lowered by the shared ALU (the reciprocal as v_rcp_f32,
the shift as an arithmetic right shift by src0 & 31). The mesh lane ALU
list now admits them, so the full_exec || exec_skip rule and the
partial-write merge apply unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on R0Y00#3709: v-rcp-iflag-f32 now checks that the reciprocal's
bits reach the exported X, as v-ashrrev-i32 already does.

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

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 95e4d369 by reading the diff; not built or run.

Verdict: approve. Both NITs from our earlier review are fixed, and nothing new came up. No MUST.

  • Encodings checked: 0x30020082 = v_ashrrev_i32 v1, 2, v0 (VOP2 op 0x18). 0x7e025700 = v_rcp_iflag_f32 v1, v0 (VOP1 op 0x2b).
  • The branch is based on 1c634037, but it merges cleanly with current main, including #3704's edits to the same allowlist lines. No rebase is needed.

Tests: v-ashrrev-i32 requires ashr by 2 & 31. v-rcp-iflag-f32 requires fdiv float 1.0. Both follow their result to the exported X through assert_position_x. native_direct_mesh is in the pr preset filter, and CI ran it green at this head.

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.

3 participants