Repository navigation
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
Conversation
… 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
left a comment
There was a problem hiding this comment.
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_u32count 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/0x94arev_cmpx_gt_f32/lg_f32/gt_u32/gt_i32.0xD415026Ais the VOP3v_cmpx_lg_f32with abs on src1.0x7FC00000is a quiet NaN. - VCC. On this target the CMPX writes only EXEC, so leaving VCC and
exec_valueuntouched (cleared) is right.
- Order. The lane-linear
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.
Part of #3703 (claimed in this comment).
Change
The mesh frontend narrowed EXEC for
v_cmpx_eq_u32,v_cmpx_ne_u32andv_cmpx_lt_u32. It handledv_cmpx_gt_u32only in the lane-linear vertex/primitive count form. Mesh86 programs also use:v_cmpx_lg_f32v_cmpx_gt_f32v_cmpx_gt_u32These three now get the same EXEC-only narrowing through the shared
comparison(), with no VCC ballot and no SGPR write:v_cmpx_lg_f32is an orderedfcmp one.v_cmpx_gt_f32is an orderedfcmp ogt. A lane with a NaN operand fails the compare and leaves EXEC.v_cmpx_gt_u32isicmp ugt.v_cmpx_gt_u32is still matched first and is unchanged.This is a new
else ifafterv_cmpx_lt_u32. It does not touchv_cmpx_eq_i32,v_cmpx_lt_f32orv_cmpx_le_f32from #3666.Tests
Source-built fixtures in
tests/native_direct_mesh_check.py, using the same save / CMPX / EXECZ / restore shape as thev_cmpx_lt_u32cases. Each one follows the predicate to themesh_workbranch 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_i32stays refused outside its paired-arms form.v_cmpx_gt_f32/v_cmpx_lg_f32:1.0against0.5, and1.0against a quiet NaN. Each case checks forogt/oneand that no unorderedfcmpappears.v_cmpx_lg_f32with|v2|stays refused.Mutation checks:
v_cmpx_lg_f32from the new branch fails the test.!i.absguard fails the test, on the|v2|case.ctest -R native_direct_meshpasses (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
maine1161e43+ #3708 + #3709 + #3710:v_cmpx_lg_f32/v_cmpx_gt_u32/v_cmpx_gt_f32beforeSo 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 nestedv_cmpx_lg_f32skips 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