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

Manually merged
github merged 1 commit from github-bot/gh-3729 into gh-pr/3729/base 2026-12-02 02:20:37 +00:00 AGit
Owner

@⁠mumba17 on GitHub · 2026-12-01 11:55 UTC · original
mumba17:shader/mesh-cmpx-lg-gt → main · +47 −0 · 2 files · 1 commits · merged 2026-12-02 02:13 UTC

Part of #3705 (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 #3668.

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 + #3710 + #3711 + #3712:

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 #3705.

AI-assisted.

🤖 Generated with Claude Code

**@⁠mumba17** on GitHub · 2026-12-01 11:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3729) `mumba17:shader/mesh-cmpx-lg-gt` → `main` · +47 −0 · 2 files · 1 commits · merged 2026-12-02 02:13 UTC Part of #3705 (claimed in [this comment](https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/3705)). ## 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 #3668. ## 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` + #3710 + #3711 + #3712: | | 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 #3705. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 #3703.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 11:58:17 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-01 18:54 UTC · original · approved these changes

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.

**@⁠lukaslw-lab** on GitHub · 2026-12-01 18:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3729#pullrequestreview-6137889002) · **approved these changes** 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.
github-bot changed target branch from main to gh-pr/3729/base 2026-12-02 02:20:32 +00:00
github manually merged commit e325352364 into gh-pr/3729/base 2026-12-02 02:20:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.