Skip to content

shader: lower v_cmpx_lg_f32, v_cmpx_gt_f32 and per-lane v_cmpx_gt_u32 in the mesh frontend (Part of #3703) - #3729

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
mumba17:shader/mesh-cmpx-lg-gt
Dec 2, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
mumba17:shader/mesh-cmpx-lg-gt

Conversation

@mumba17

@mumba17 mumba17 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Part of #3703 (claimed in this comment).

Change

The mesh frontend narrowed EXEC for v_cmpx_eq_u32, v_cmpx_ne_u32 and v_cmpx_lt_u32. It handled v_cmpx_gt_u32 only in the lane-linear vertex/primitive count form. Mesh86 programs also use:

  • v_cmpx_lg_f32
  • v_cmpx_gt_f32
  • a per-lane v_cmpx_gt_u32

These three now get the same EXEC-only narrowing through the shared comparison(), with no VCC ballot and no SGPR write:

  • v_cmpx_lg_f32 is an ordered fcmp one. v_cmpx_gt_f32 is an ordered fcmp ogt. A lane with a NaN operand fails the compare and leaves EXEC.
  • v_cmpx_gt_u32 is icmp ugt.
  • The count form of v_cmpx_gt_u32 is still matched first and is unchanged.
  • Float abs/neg (VOP3), SDWA, DPP, clamp and omod stay refused. The shared compare ignores float source modifiers, so accepting them would be wrong.

This is a new else if after v_cmpx_lt_u32. It does not touch v_cmpx_eq_i32, v_cmpx_lt_f32 or v_cmpx_le_f32 from #3666.

Tests

Source-built fixtures in tests/native_direct_mesh_check.py, using the same save / CMPX / EXECZ / restore shape as the v_cmpx_lt_u32 cases. Each one follows the predicate to the mesh_work branch and the joined position X:

  • v_cmpx_gt_u32: lane id > 2, unsigned wrap (all-ones > 0), and a self-compare that gives an empty EXEC. v_cmpx_gt_i32 stays refused outside its paired-arms form.
  • v_cmpx_gt_f32 / v_cmpx_lg_f32: 1.0 against 0.5, and 1.0 against a quiet NaN. Each case checks for ogt / one and that no unordered fcmp appears.
  • Refusal: the VOP3 v_cmpx_lg_f32 with |v2| stays refused.

Mutation checks:

  • Dropping v_cmpx_lg_f32 from the new branch fails the test.
  • Dropping the !i.abs guard fails the test, on the |v2| case.

ctest -R native_direct_mesh passes (Windows 11 26300, MSVC 14.44, SDK 10.0.26100 DXC, RTX 3090).

Census

On my local Mesh86 capture (1,569 distinct slot 86 programs), with main e1161e43 + #3708 + #3709 + #3710:

Programs
translate fully (before and after) 512
first refusal v_cmpx_lg_f32 / v_cmpx_gt_u32 / v_cmpx_gt_f32 before 224 / 50 / 5
same, after 0 / 0 / 0
programs that translated before and refuse now 0

So this PR on its own adds no fully translated programs. Most of the 279 now stop at graphics register undefined on an incoming path. The pattern is a chain of nested v_cmpx_lg_f32 skips that all exit to one EXEC restore, inside the vertex-count skip. The chain accumulates into VGPRs that were first written under the count mask. Those writes are not select-merged, because the old value is itself partial, so the restore to the count mask drops them. That is a change to partial-write tracking, not to compares, so I'll take it as a separate follow-up on #3703.

AI-assisted.

🤖 Generated with Claude Code

… in the mesh frontend

The mesh frontend narrowed EXEC only for v_cmpx_eq_u32, ne_u32 and lt_u32,
and for v_cmpx_gt_u32 only in the lane-linear count form. Mesh86 programs
also use v_cmpx_lg_f32, v_cmpx_gt_f32 and a per-lane v_cmpx_gt_u32.

They now get the same EXEC-only narrowing through the shared compare: lg is
an ordered fcmp one and gt_f32 an ordered ogt, so a NaN lane leaves EXEC,
and gt_u32 is icmp ugt. The count form of v_cmpx_gt_u32 is still matched
first. Float abs/neg, SDWA, DPP, clamp and omod stay refused.

Part of R0Y00#3703.

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 e3253523 by reading the diff; not built or run.

Verdict: approve. The new branch narrows EXEC exactly as the existing eq/ne/lt_u32 branches do, through the shared comparison(). That function maps lg to the ordered fcmp one and gt to ogt (gfx1013_direct_compute.inl:3738), and refuses op_sel (:3648). The new guard adds the refusal of abs/neg that the shared path would otherwise ignore for floats. No MUST.

  • NIT This is now the fourth copy of the same five-line body (gfx1013_direct_mesh.inl:1333-1368, new branch at :1358). One branch with a name list would keep the guards from drifting apart.
  • Checked, no finding:
    • Order. The lane-linear v_cmpx_gt_u32 count form sits earlier in the chain. An instruction that fails its conditions falls through to per-lane narrowing, which is still the instruction's real meaning; it just lacks the count proof.
    • Encodings. VOPC 0x14/0x15/0xD4/0x94 are v_cmpx_gt_f32/lg_f32/gt_u32/gt_i32. 0xD415026A is the VOP3 v_cmpx_lg_f32 with abs on src1. 0x7FC00000 is a quiet NaN.
    • VCC. On this target the CMPX writes only EXEC, so leaving VCC and exec_value untouched (cleared) is right.

Tests: the three gt_u32 cases pin icmp ugt, including the unsigned wrap and the empty self-compare. The four float cases pin the ordered predicates, and that no unordered fcmp appears, for both a value and a NaN. v-cmpx-gt-i32-refused and v-cmpx-lg-f32-abs keep the signed compare and the float modifiers refused. native_direct_mesh is in the pr preset filter, and CI ran it green at this head.

@R0Y00
R0Y00 merged commit 7195821 into R0Y00:main Dec 2, 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.

3 participants