shader: how should pixel_aot represent v_cmpx (EXEC-writing compares)? Proposed first stage on the #651 region #925

Closed
opened 2026-11-23 17:44:24 +00:00 by MasterDomino · 6 comments
MasterDomino commented 2026-11-23 17:44:24 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T17:44:24Z.


Question

How should tools/pixel_aot.py represent v_cmpx_*, the compares that write their result to EXEC? What is the smallest first stage you would accept?

lower() rejects every v_cmpx_* form today. In docs/coverage/gfx1013.tsv they are 95 VOPC (_e32), 95 VOP3 (_e64) and 62 SDWA forms, 252 of the 1,968 forms. #338 listed them among the rejected forms. #651 then landed the stage-one masked region (s_and_saveexec_b64 from a tracked comparison, optional s_cbranch_execz to the matching restore, s_or_b64 exec, exec, s[a:b], per-lane selects at the restore). I found no issue or PR since then that covers v_cmpx.

I would like to propose, and then implement, the stage below. I won't start without your direction.

Proposed first stage

Accept the region opener that LLVM 15 emits for gfx10.3:

s_mov_b64 s[a:b], exec
v_cmpx_<op>_<type>_e32 src0, vsrc1      (or _e64 src0, src1)
  ... REGION_ALU body ...
s_or_b64 exec, exec, s[a:b]

as equivalent to the existing v_cmp_<op>_<type> vcc, … + s_and_saveexec_b64 s[a:b], vcc opener. It would reuse the current region state, body restrictions and restore-time selects.

  • Scope: the comparison kinds that v_cmp_* already lowers (f32, f16, i16/u16, i32/u32, i64/u64 and class f16/f32), in both _e32 and _e64. That is 156 forms. f64 (34 forms) and SDWA (62 forms) stay rejected.
  • Same restrictions as the existing opener: a known full entry mask, no nesting, the s_mov_b64 save immediately before the v_cmpx, and the optional s_cbranch_execz only at the matching restore.
  • Every other v_cmpx use stays rejected. That includes a v_cmpx with no saved EXEC, and so the whole-program discard pattern.

Evidence so far

  • The ISA definition. The AMD "RDNA 2" ISA reference guide §6.2.2 (p. 42 of 283) says: "All V_CMPX instructions write the result of their comparison (one bit per thread) the EXEC mask." §12.9 "VOPC Instructions" (p. 152) gives e.g. V_CMPX_GT_F32: EXEC[threadId] = (S0 > S1). The same section 6.2.2 says "A thread only writes a result if the associated bit in the EXEC mask is set to 1." This is the RDNA 2 guide, not a gfx1013-specific document.

  • gfx1013 has no separate destination on _e64. LLVM 15.0.7 llvm-mc -mcpu=gfx1013 assembles v_cmpx_gt_f32_e32 v12, v13, v_cmpx_gt_f32_e64 v12, v13, v_cmpx_gt_f32_e64 v12, s44 and v_cmpx_class_f32_e64 v12, 3, and rejects an explicit exec or s[0:1] destination on _e64. v_cmpx_gt_f32_sdwa assembles; the DPP form is rejected ("dpp variant of this instruction is not supported").

  • Where LLVM 15 emits it (llc -O2, wave64, a pixel shader with a non-flattenable if):

    • For gfx1030 it emits s_mov_b64 s[0:1], exec / v_cmpx_gt_f32_e32 v0, v1 / … / s_or_b64 exec, exec, s[0:1].
    • For gfx1013 the same IR still gives v_cmp_gt_f32_e32 vcc, v0, v1 / s_and_saveexec_b64 s[0:1], vcc, which #651 already handles.
    • With llvm.amdgcn.kill, LLVM 15 emits no v_cmpx for either target.

    So LLVM itself doesn't produce this pattern for gfx1013. I don't know whether the compiler that built the gfx1013 programs uses v_cmpx, or how often. An aggregate count from someone with a local input, like the counts in #711, would set the priority.

  • Inference, not measured. The proposal assumes the inactive-lane rule (a thread writes only if its EXEC bit is set), so the new mask is EXEC_old & cond. That would make the opener equivalent to s_and_saveexec_b64 from a full entry mask. LLVM's gfx10.3 rewrite of v_cmp + s_and_saveexec into s_mov + v_cmpx depends on the same equivalence. I haven't checked this on hardware.

Questions for you

  1. Is "s_mov_b64 save + v_cmpx" as an alternative region opener the right first stage? Or would you rather model v_cmpx as a general EXEC write first?
  2. Is the EXEC_old & cond definition acceptable, given the ISA text and the LLVM equivalence, or do you want separate evidence?
  3. Should _e32 and _e64 land together, or one encoding first?

Completion condition (for the first stage)

  • Binary. The fixtures round-trip through LLVM 15 llvm-mc/llvm-objdump for gfx1013, using the pixel_aot_check.py binary path.
  • Draws. A draw mode, registered with FORM_COVERAGE_RECORD, runs the cmpx-opened regions on WARP:
    • mixed, empty and full masks, as in the #651 draws;
    • each accepted comparison kind;
    • bit-exact readback through the R32G32B32A32_UINT target.
  • Negative controls, each of which must mismatch:
    • a reversed predicate;
    • the region lowered without the mask;
    • for _e64, a source swap on a non-commutative comparison.
  • Rejection controls: v_cmpx with no preceding save, a save that isn't immediately before it, nesting, f64, SDWA, and a body instruction outside REGION_ALU.

Required environment

The translation and LLVM 15 round trip run on Linux. The WARP draws need Windows (CI on the PR). No physical GPU and no game files.

  • The task can be reproduced with public or source-built inputs.
  • I did not include game files, dumps, distribution links or credentials.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6565291837 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/932). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-23T17:44:24Z. --- ### Question How should `tools/pixel_aot.py` represent `v_cmpx_*`, the compares that write their result to EXEC? What is the smallest first stage you would accept? `lower()` rejects every `v_cmpx_*` form today. In `docs/coverage/gfx1013.tsv` they are 95 VOPC (`_e32`), 95 VOP3 (`_e64`) and 62 SDWA forms, 252 of the 1,968 forms. #338 listed them among the rejected forms. #651 then landed the stage-one masked region (`s_and_saveexec_b64` from a tracked comparison, optional `s_cbranch_execz` to the matching restore, `s_or_b64 exec, exec, s[a:b]`, per-lane selects at the restore). I found no issue or PR since then that covers `v_cmpx`. I would like to propose, and then implement, the stage below. I won't start without your direction. ### Proposed first stage Accept the region opener that LLVM 15 emits for gfx10.3: ``` s_mov_b64 s[a:b], exec v_cmpx_<op>_<type>_e32 src0, vsrc1 (or _e64 src0, src1) ... REGION_ALU body ... s_or_b64 exec, exec, s[a:b] ``` as equivalent to the existing `v_cmp_<op>_<type> vcc, …` + `s_and_saveexec_b64 s[a:b], vcc` opener. It would reuse the current region state, body restrictions and restore-time selects. - **Scope:** the comparison kinds that `v_cmp_*` already lowers (f32, f16, i16/u16, i32/u32, i64/u64 and `class` f16/f32), in both `_e32` and `_e64`. That is 156 forms. f64 (34 forms) and SDWA (62 forms) stay rejected. - **Same restrictions as the existing opener:** a known full entry mask, no nesting, the `s_mov_b64` save immediately before the `v_cmpx`, and the optional `s_cbranch_execz` only at the matching restore. - **Every other `v_cmpx` use stays rejected.** That includes a `v_cmpx` with no saved EXEC, and so the whole-program discard pattern. ### Evidence so far - **The ISA definition.** The [AMD "RDNA 2" ISA reference guide](https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf) §6.2.2 (p. 42 of 283) says: "All V_CMPX instructions write the result of their comparison (one bit per thread) the EXEC mask." §12.9 "VOPC Instructions" (p. 152) gives e.g. `V_CMPX_GT_F32: EXEC[threadId] = (S0 > S1)`. The same section 6.2.2 says "A thread only writes a result if the associated bit in the EXEC mask is set to 1." This is the RDNA 2 guide, not a gfx1013-specific document. - **gfx1013 has no separate destination on `_e64`.** LLVM 15.0.7 `llvm-mc -mcpu=gfx1013` assembles `v_cmpx_gt_f32_e32 v12, v13`, `v_cmpx_gt_f32_e64 v12, v13`, `v_cmpx_gt_f32_e64 v12, s44` and `v_cmpx_class_f32_e64 v12, 3`, and rejects an explicit `exec` or `s[0:1]` destination on `_e64`. `v_cmpx_gt_f32_sdwa` assembles; the DPP form is rejected ("dpp variant of this instruction is not supported"). - **Where LLVM 15 emits it** (`llc -O2`, wave64, a pixel shader with a non-flattenable `if`): - For **gfx1030** it emits `s_mov_b64 s[0:1], exec` / `v_cmpx_gt_f32_e32 v0, v1` / … / `s_or_b64 exec, exec, s[0:1]`. - For **gfx1013** the same IR still gives `v_cmp_gt_f32_e32 vcc, v0, v1` / `s_and_saveexec_b64 s[0:1], vcc`, which #651 already handles. - With `llvm.amdgcn.kill`, LLVM 15 emits no `v_cmpx` for either target. So LLVM itself doesn't produce this pattern for gfx1013. I don't know whether the compiler that built the gfx1013 programs uses `v_cmpx`, or how often. An aggregate count from someone with a local input, like the counts in #711, would set the priority. - **Inference, not measured.** The proposal assumes the inactive-lane rule (a thread writes only if its EXEC bit is set), so the new mask is `EXEC_old & cond`. That would make the opener equivalent to `s_and_saveexec_b64` from a full entry mask. LLVM's gfx10.3 rewrite of `v_cmp` + `s_and_saveexec` into `s_mov` + `v_cmpx` depends on the same equivalence. I haven't checked this on hardware. ### Questions for you 1. Is "`s_mov_b64` save + `v_cmpx`" as an alternative region opener the right first stage? Or would you rather model `v_cmpx` as a general EXEC write first? 2. Is the `EXEC_old & cond` definition acceptable, given the ISA text and the LLVM equivalence, or do you want separate evidence? 3. Should `_e32` and `_e64` land together, or one encoding first? ### Completion condition (for the first stage) - **Binary.** The fixtures round-trip through LLVM 15 `llvm-mc`/`llvm-objdump` for gfx1013, using the `pixel_aot_check.py binary` path. - **Draws.** A draw mode, registered with `FORM_COVERAGE_RECORD`, runs the cmpx-opened regions on WARP: - mixed, empty and full masks, as in the #651 draws; - each accepted comparison kind; - bit-exact readback through the `R32G32B32A32_UINT` target. - **Negative controls, each of which must mismatch:** - a reversed predicate; - the region lowered without the mask; - for `_e64`, a source swap on a non-commutative comparison. - **Rejection controls:** `v_cmpx` with no preceding save, a save that isn't immediately before it, nesting, f64, SDWA, and a body instruction outside `REGION_ALU`. ### Required environment The translation and LLVM 15 round trip run on Linux. The WARP draws need Windows (CI on the PR). No physical GPU and no game files. - [x] The task can be reproduced with public or source-built inputs. - [x] I did not include game files, dumps, distribution links or credentials. AI-assisted.
MasterDomino commented 2026-11-24 06:49:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T17:54:19Z.


Aggregate counts from one local input, for the priority question above. It is the same population as #711: 12,101 PS records. Only counts here; no names, paths or disassembly from the input.

Method. tools/extract_shaders.py --stage pixel --format native, then decoded with tools/disasm_rdna2.py (what tools/scan_unsupported_shaders.py uses), at a8a88e1. Cross-check: on a random sample of 300 records, LLVM 15.0.7 (pixel_aot.disassemble, gfx1013) over the same byte ranges gives the same v_cmpx count (3,764 in both). The Python decoder stops at the first s_endpgm, so the numbers below are lower bounds.

Measurement Result
PS records containing any v_cmpx_* 9,932 of 12,101 (82.1%)
v_cmpx_* instructions 174,201: _e32 173,316, _e64 885, no SDWA
Most frequent eq_u32 53,180 · lt_f32 39,471 · ne_u32 26,800 · gt_f32 21,063 · lg_f32 11,281 · lt_i32 4,499 · gt_u32 4,468 · ge_f32 3,256
v_cmpx directly preceded by s_mov_b64 s[a:b], exec 48,736 (plus 9,462 with s_mov_b32 s, exec_lo), in 6,677 records

What the first EXEC write after a saved v_cmpx is (58,198 saved v_cmpx; the wave32 _b32/exec_lo forms are counted with their _b64 equivalents):

Next EXEC write Count
s_mov_b64 exec, s[a:b] (restore) 15,683
s_andn2_b64 exec, s[a:b], exec (else branch) 14,080
another v_cmpx (nested or chained) 14,787
s_and_saveexec_* (nested) 5,114
other (s_mov/s_and to EXEC from another register) 8,534
s_or_b64 exec, exec, s[a:b] 0

So this compiler restores with s_mov_b64 exec, s[a:b], not the s_or_b64 exec, exec, s[a:b] the proposal assumed. 14,450 of the restores, in 4,379 records (36%), have the shape below: no branch in the body other than at most one s_cbranch_execz. I did not check the branch target or whether the body stays within REGION_ALU.

s_mov_b64 s[a:b], exec
v_cmpx_<op>_<type>_e32 src0, vsrc1
s_cbranch_execz L          ; optional
  ... body ...
L:
s_mov_b64 exec, s[a:b]

Revised first-stage proposal. Same as above, except that the region closes with either s_mov_b64 exec, s[a:b] or s_or_b64 exec, exec, s[a:b] naming the saved pair. With a full entry mask and the EXEC_old & cond definition, the region mask is a subset of the saved mask, so the two restores give the same EXEC. That again rests on the inactive-lane inference, not a hardware measurement. Unchanged from above:

  • _e32 and _e64;
  • no nesting;
  • else branches (s_andn2_b64 exec, saved, exec), chained v_cmpx, f64 and SDWA stay rejected.

The else branch and nesting are the next most common shapes, and I'd suggest them as later stages.

Side observation: the 64-bit shifts in #928 are rare in this input. Only v_lshlrev_b64 occurs: 255 records (2.1%), 3,083 instructions.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7109354969 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/932#issuecomment-7109354969). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-23T17:54:19Z. --- Aggregate counts from one local input, for the priority question above. It is the same population as #711: 12,101 PS records. Only counts here; no names, paths or disassembly from the input. **Method.** `tools/extract_shaders.py --stage pixel --format native`, then decoded with `tools/disasm_rdna2.py` (what `tools/scan_unsupported_shaders.py` uses), at `a8a88e1`. Cross-check: on a random sample of 300 records, LLVM 15.0.7 (`pixel_aot.disassemble`, gfx1013) over the same byte ranges gives the same `v_cmpx` count (3,764 in both). The Python decoder stops at the first `s_endpgm`, so the numbers below are lower bounds. | Measurement | Result | |---|---| | PS records containing any `v_cmpx_*` | **9,932 of 12,101 (82.1%)** | | `v_cmpx_*` instructions | 174,201: `_e32` 173,316, `_e64` 885, no SDWA | | Most frequent | `eq_u32` 53,180 · `lt_f32` 39,471 · `ne_u32` 26,800 · `gt_f32` 21,063 · `lg_f32` 11,281 · `lt_i32` 4,499 · `gt_u32` 4,468 · `ge_f32` 3,256 | | `v_cmpx` directly preceded by `s_mov_b64 s[a:b], exec` | 48,736 (plus 9,462 with `s_mov_b32 s, exec_lo`), in 6,677 records | **What the first EXEC write after a saved `v_cmpx` is** (58,198 saved `v_cmpx`; the wave32 `_b32`/`exec_lo` forms are counted with their `_b64` equivalents): | Next EXEC write | Count | |---|---| | `s_mov_b64 exec, s[a:b]` (restore) | 15,683 | | `s_andn2_b64 exec, s[a:b], exec` (else branch) | 14,080 | | another `v_cmpx` (nested or chained) | 14,787 | | `s_and_saveexec_*` (nested) | 5,114 | | other (`s_mov`/`s_and` to EXEC from another register) | 8,534 | | `s_or_b64 exec, exec, s[a:b]` | **0** | So this compiler restores with `s_mov_b64 exec, s[a:b]`, not the `s_or_b64 exec, exec, s[a:b]` the proposal assumed. 14,450 of the restores, in **4,379 records (36%)**, have the shape below: no branch in the body other than at most one `s_cbranch_execz`. I did not check the branch target or whether the body stays within `REGION_ALU`. ``` s_mov_b64 s[a:b], exec v_cmpx_<op>_<type>_e32 src0, vsrc1 s_cbranch_execz L ; optional ... body ... L: s_mov_b64 exec, s[a:b] ``` **Revised first-stage proposal.** Same as above, except that the region closes with either `s_mov_b64 exec, s[a:b]` or `s_or_b64 exec, exec, s[a:b]` naming the saved pair. With a full entry mask and the `EXEC_old & cond` definition, the region mask is a subset of the saved mask, so the two restores give the same EXEC. That again rests on the inactive-lane inference, not a hardware measurement. Unchanged from above: - `_e32` and `_e64`; - no nesting; - else branches (`s_andn2_b64 exec, saved, exec`), chained `v_cmpx`, f64 and SDWA stay rejected. The else branch and nesting are the next most common shapes, and I'd suggest them as later stages. Side observation: the 64-bit shifts in #928 are rare in this input. Only `v_lshlrev_b64` occurs: 255 records (2.1%), 3,083 instructions. AI-assisted.
R0Y00 commented 2026-11-24 06:49:28 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T18:30:15Z.


The structured opener fits #651. Please start with VOPC _e32 and already-supported 32-bit comparisons. Allow the immediate EXEC save and exact s_mov_b64 exec, saved restore. The existing OR restore is also equivalent for lane selection when the inner mask is a subset of the saved mask. Keep the two restore instructions distinct for SCC: MOV preserves it and OR writes it. CMPX does not write VCC. Preserve those observable values or reject readers of any state this profile cannot track.

Use the known entry mask and the existing pure per-lane body, no nesting or side effects, and verify any optional EXECZ branch targets the actual restore instruction. Under that supported entry state, intersect the compare result with the incoming EXEC. General partial-entry masks, chained CMPX, wave32 save/restore, kill/else, and _e64 can follow separately if independently validated. The 4,379 records are structural candidates until the target and body checks run.

Please include LLVM 15 gfx1013 binary round-trips and mixed/empty/full bit-exact WARP cases. Keep the reversed predicate, ignored mask, wrong branch target, overwritten save pair, and unsupported body controls. WARP establishes the translated behavior of the source-built fixture.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7110255733 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/932#issuecomment-7110255733). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T18:30:15Z. --- The structured opener fits #651. Please start with VOPC `_e32` and already-supported 32-bit comparisons. Allow the immediate EXEC save and exact `s_mov_b64 exec, saved` restore. The existing OR restore is also equivalent for lane selection when the inner mask is a subset of the saved mask. Keep the two restore instructions distinct for SCC: MOV preserves it and OR writes it. CMPX does not write VCC. Preserve those observable values or reject readers of any state this profile cannot track. Use the known entry mask and the existing pure per-lane body, no nesting or side effects, and verify any optional EXECZ branch targets the actual restore instruction. Under that supported entry state, intersect the compare result with the incoming EXEC. General partial-entry masks, chained CMPX, wave32 save/restore, kill/else, and _e64 can follow separately if independently validated. The 4,379 records are structural candidates until the target and body checks run. Please include LLVM 15 gfx1013 binary round-trips and mixed/empty/full bit-exact WARP cases. Keep the reversed predicate, ignored mask, wrong branch target, overwritten save pair, and unsupported body controls. WARP establishes the translated behavior of the source-built fixture.
MasterDomino commented 2026-11-24 06:49:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T18:46:07Z.


Taking the first stage you scoped above. It's up as #957: VOPC _e32 v_cmpx on the binary32 and 32-bit integer predicates (32 forms) with the immediate s_mov_b64 save; the s_mov_b64 and s_or_b64 restores kept distinct for SCC; VCC untouched; the optional s_cbranch_execz checked against the actual restore.

Re-measured with those rules, as you asked, on the same local input (aggregates only): 3,719 records have the save + v_cmpx + restore shape, but only 152 regions in 112 records (0.9%) also pass the existing #651 body rule. The rest are blocked mainly by scalar loads, s_nop, conversions and v_rcp in the body. Details are in the PR.

The WARP draws will run for the first time in that PR's CI.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7110624235 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/932#issuecomment-7110624235). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-23T18:46:07Z. --- Taking the first stage you scoped above. It's up as #957: VOPC `_e32` `v_cmpx` on the binary32 and 32-bit integer predicates (32 forms) with the immediate `s_mov_b64` save; the `s_mov_b64` and `s_or_b64` restores kept distinct for SCC; VCC untouched; the optional `s_cbranch_execz` checked against the actual restore. Re-measured with those rules, as you asked, on the same local input (aggregates only): 3,719 records have the save + `v_cmpx` + restore shape, but only 152 regions in 112 records (0.9%) also pass the existing #651 body rule. The rest are blocked mainly by scalar loads, `s_nop`, conversions and `v_rcp` in the body. Details are in the PR. The WARP draws will run for the first time in that PR's CI. AI-assisted.
MasterDomino commented 2026-11-24 06:49:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T18:51:09Z.


Proposal for the next stage, which I'd like to take after #957: widen the masked-region body. This is about the body, not the opener.

The #651 body rule (REGION_ALU: v_mov_b32 and binary32 add/sub/subrev/mul/min/max) is what blocks almost all real regions. Same local input as above (aggregates only), counting the regions #957 accepts structurally: save + f32/i32/u32 _e32 v_cmpx + restore of the same pair. That is 10,827 regions in 3,719 records.

I added body instructions one at a time, greedily, and leave out any region containing a further branch (nesting stays out of scope):

Body rule Regions accepted Records with ≥1
current REGION_ALU 152 112
+ v_fmac_f32_e32, v_mul_legacy_f32_e32 284 244
+ v_cvt_f32_ubyte2_e32 1,776 744
+ v_rcp_f32_e32, v_rsq_f32_e32 2,630 1,304
+ v_cvt_f32_ubyte1_e32, v_fma_f32, v_sqrt_f32_e32, v_med3_f32, v_mul_legacy_f32_e64 3,116 1,494
the proposed set below (the above plus v_mac_f32_e32, v_mad_f32, v_cvt_f32_ubyte0/3) 3,151 1,529 (12.6%)

A record also needs everything outside its regions to translate, so these count regions, not translatable shaders.

Proposed stage 2. Admit to the region body the per-lane binary32 VALU forms that lower() already handles outside regions, each through its existing lowering and the existing restore-time select:

  • v_fmac, v_mac
  • v_mul_legacy (e32/e64)
  • v_cvt_f32_ubyte0..3
  • v_rcp, v_rsq, v_sqrt
  • v_fma, v_mad, v_med3

Like the current body, they write only VGPRs, read only VGPRs, SGPRs and constants, and have no side effects or traps. A false lane's speculated value, including a NaN or infinity from rcp/rsq/sqrt out of domain, is discarded by the select. The accumulator forms (fmac/mac) read their destination, so a destination still conditional from an earlier region would reject, as reads do today.

Out of this stage:

  • scalar instructions in the body (s_mov_b32, s_waitcnt, scalar loads). They run regardless of EXEC but are skipped with the region by s_cbranch_execz;
  • memory, LDS and ds_swizzle;
  • nesting and else.

Questions for you:

  1. Is admitting already-lowered per-lane VALU forms the right shape for stage 2, or would you rather name a different first set?
  2. Should each admitted form get its own in-region draw (inner and outer values distinguishable per lane, plus a control whose wrong reference ignores the mask), or one draw per lowering family?

I won't start until #957 has your verdict, so the two don't overlap.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7110745431 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/932#issuecomment-7110745431). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-23T18:51:09Z. --- Proposal for the next stage, which I'd like to take after #957: widen the masked-region body. This is about the body, not the opener. The #651 body rule (`REGION_ALU`: `v_mov_b32` and binary32 `add`/`sub`/`subrev`/`mul`/`min`/`max`) is what blocks almost all real regions. Same local input as above (aggregates only), counting the regions #957 accepts structurally: save + f32/i32/u32 `_e32` `v_cmpx` + restore of the same pair. That is 10,827 regions in 3,719 records. I added body instructions one at a time, greedily, and leave out any region containing a further branch (nesting stays out of scope): | Body rule | Regions accepted | Records with ≥1 | |---|---|---| | current `REGION_ALU` | 152 | 112 | | + `v_fmac_f32_e32`, `v_mul_legacy_f32_e32` | 284 | 244 | | + `v_cvt_f32_ubyte2_e32` | 1,776 | 744 | | + `v_rcp_f32_e32`, `v_rsq_f32_e32` | 2,630 | 1,304 | | + `v_cvt_f32_ubyte1_e32`, `v_fma_f32`, `v_sqrt_f32_e32`, `v_med3_f32`, `v_mul_legacy_f32_e64` | 3,116 | 1,494 | | **the proposed set below** (the above plus `v_mac_f32_e32`, `v_mad_f32`, `v_cvt_f32_ubyte0/3`) | **3,151** | **1,529 (12.6%)** | A record also needs everything outside its regions to translate, so these count regions, not translatable shaders. **Proposed stage 2.** Admit to the region body the per-lane binary32 VALU forms that `lower()` already handles outside regions, each through its existing lowering and the existing restore-time select: - `v_fmac`, `v_mac` - `v_mul_legacy` (e32/e64) - `v_cvt_f32_ubyte0..3` - `v_rcp`, `v_rsq`, `v_sqrt` - `v_fma`, `v_mad`, `v_med3` Like the current body, they write only VGPRs, read only VGPRs, SGPRs and constants, and have no side effects or traps. A false lane's speculated value, including a NaN or infinity from `rcp`/`rsq`/`sqrt` out of domain, is discarded by the select. The accumulator forms (`fmac`/`mac`) read their destination, so a destination still conditional from an earlier region would reject, as reads do today. **Out of this stage:** - scalar instructions in the body (`s_mov_b32`, `s_waitcnt`, scalar loads). They run regardless of EXEC but are skipped with the region by `s_cbranch_execz`; - memory, LDS and `ds_swizzle`; - nesting and else. **Questions for you:** 1. Is admitting already-lowered per-lane VALU forms the right shape for stage 2, or would you rather name a different first set? 2. Should each admitted form get its own in-region draw (inner and outer values distinguishable per lane, plus a control whose wrong reference ignores the mask), or one draw per lowering family? I won't start until #957 has your verdict, so the two don't overlap. AI-assisted.
MasterDomino commented 2026-11-24 06:49:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T19:18:16Z.


#957 is merged, thanks. Starting stage 2 as proposed above. The body set is exactly the listed per-lane binary32 forms, in the encodings measured: v_fmac_f32_e32, v_mac_f32_e32, v_mul_legacy_f32_e32/_e64, v_cvt_f32_ubyte0..3_e32, v_rcp/v_rsq/v_sqrt_f32_e32, v_fma_f32, v_mad_f32 and v_med3_f32. Each form gets its own in-region draw: inner and outer values differ per lane, and a wrong reference that ignores the mask must mismatch. Please redirect if you'd prefer a different set or one draw per family.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7111404416 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/932#issuecomment-7111404416). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-23T19:18:16Z. --- #957 is merged, thanks. Starting stage 2 as proposed above. The body set is exactly the listed per-lane binary32 forms, in the encodings measured: `v_fmac_f32_e32`, `v_mac_f32_e32`, `v_mul_legacy_f32_e32/_e64`, `v_cvt_f32_ubyte0..3_e32`, `v_rcp/v_rsq/v_sqrt_f32_e32`, `v_fma_f32`, `v_mad_f32` and `v_med3_f32`. Each form gets its own in-region draw: inner and outer values differ per lane, and a wrong reference that ignores the mask must mismatch. Please redirect if you'd prefer a different set or one draw per family. AI-assisted.
R0Y00 commented 2026-11-24 06:49:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T19:19:54Z.


The scoped stage one from this thread merged in #957. The translated source-built cases passed on WARP and RTX 4060 Laptop, and LLVM 15 round-tripped the gfx1013 binary fixtures. The tests cover mixed, empty and full masks, both restore forms, genuine skip targets and wrong-predicate/wrong-mask controls. This closes the VOPC e32 32-bit structured region stage. General EXEC writes, wave32 save/restore, nesting, class forms and e64 remain separate.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7111443280 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/932#issuecomment-7111443280). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T19:19:54Z. --- The scoped stage one from this thread merged in #957. The translated source-built cases passed on WARP and RTX 4060 Laptop, and LLVM 15 round-tripped the gfx1013 binary fixtures. The tests cover mixed, empty and full masks, both restore forms, genuine skip targets and wrong-predicate/wrong-mask controls. This closes the VOPC e32 32-bit structured region stage. General EXEC writes, wave32 save/restore, nesting, class forms and e64 remain separate.
Sign in to join this conversation.
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#925
No description provided.