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
mumba17 merged 1 commit from upstream-pr/3729 into main 2026-12-02 02:13:25 +00:00
mumba17 commented 2026-12-01 11:55:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T11:55:27Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5585166784 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3729). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T11:55:27Z. --- Part of #3703 (claimed in [this comment](https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7310088730)). ## 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](https://claude.com/claude-code)
lukaslw-lab commented 2026-12-01 18:54:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T18:54:19Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6137889002 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3729#pullrequestreview-6137889002). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T18:54:19Z. **Review:** APPROVED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3729
No description provided.