cpp-migration: lower s_bfm_b64, s_cselect_b64 and s_not_b64 in the direct C++ compute path #2957

Closed
opened 2026-11-26 23:25:53 +00:00 by Leyukaka · 1 comment
Leyukaka commented 2026-11-26 23:25:53 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T23:25:53Z.


Target branch cpp-migration. Part of #2935 (instruction coverage). I am taking this; please say if you already have it locally and I will drop it.

Gap: the direct compute path lowers the bitwise 64-bit SALU ops (and, or, xor, andn2, orn2, nand, nor, xnor and their saveexec forms) and refuses the other _b64 ones. Three of the refused ones are plain 64-bit arithmetic:

  • s_bfm_b64 and s_cselect_b64 get "unsupported wave64 scalar mask operation";
  • s_not_b64 gets "unsupported wave64 scalar operation".

Measured on a local capture of 2,689 compute requests (counts and instruction shape only), with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests built from cpp-migration 49e0e36d. Requests stop first at:

Instruction Requests
s_bfm_b64, e.g. s[28:29], 32, 32 65
s_cselect_b64, e.g. s[40:41], -1, 0 and vcc, -1, 0 49
s_not_b64 24

The runtime uses the Python translator, so I matched request keys against a 600 s start-up run, on a build with the same compiler content as 49e0e36d. The s_bfm_b64 and s_cselect_b64 first stops among the dispatched pipelines account for about 13,500 dispatches.

Plan: ISA semantics on real 64-bit values. tools/startup/gfx2hlsl.py has the same s_bfm_b64 rule (op_s_bfm_b64). Its s_cselect_b64 and s_not_b64 use its one-bit-per-lane mask model, which does not apply here.

  • s_bfm_b64 D, S0, S1: D = ((1 << (S0 & 63)) - 1) << (S1 & 63), with both destination words written and SCC unchanged. S0 and S1 are single 32-bit operands: an SGPR or a constant.
  • s_cselect_b64 D, S0, S1: D = SCC ? S0 : S1 per word, with SCC unchanged.
    • Constants extend to 64 bits as pair_high already does: inline negatives are sign-extended, and inline non-negatives and literals get a zero high word.
    • The destination is an even SGPR pair or vcc, with the existing wave32/wave64 VCC layout.
    • exec as a destination is left out for now.
  • s_not_b64 D, S0: D = ~S0 per word, and SCC = (D != 0) over both words.
  • s_cselect_b64 and s_not_b64 take even SGPR pairs or constants as sources.
  • Out of scope: s_bcnt1_i32_b64 and s_ff1_i32_b64 on exec (13 and 11 first stops), whose results depend on the wave model.

Tests: a hardware readback against a CPU reference.

  • s_bfm_b64 with widths and offsets 0, 1, 31, 32, 33 and 63, plus the measured 32, 32.
  • s_cselect_b64 under both SCC values, with an SGPR pair, -1 and a literal.
  • s_not_b64 with its SCC result, read through s_cselect_b32.

Mutants: a 32-bit s_bfm_b64, zero-extending the inline constant in s_cselect_b64, and an SCC taken from the low word only in s_not_b64.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6636746193 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2957). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-26T23:25:53Z. --- Target branch `cpp-migration`. Part of #2935 (instruction coverage). I am taking this; please say if you already have it locally and I will drop it. **Gap:** the direct compute path lowers the bitwise 64-bit SALU ops (`and`, `or`, `xor`, `andn2`, `orn2`, `nand`, `nor`, `xnor` and their `saveexec` forms) and refuses the other `_b64` ones. Three of the refused ones are plain 64-bit arithmetic: - `s_bfm_b64` and `s_cselect_b64` get "unsupported wave64 scalar mask operation"; - `s_not_b64` gets "unsupported wave64 scalar operation". **Measured** on a local capture of 2,689 compute requests (counts and instruction shape only), with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` built from `cpp-migration` `49e0e36d`. Requests stop first at: | Instruction | Requests | |---|---:| | `s_bfm_b64`, e.g. `s[28:29], 32, 32` | 65 | | `s_cselect_b64`, e.g. `s[40:41], -1, 0` and `vcc, -1, 0` | 49 | | `s_not_b64` | 24 | The runtime uses the Python translator, so I matched request keys against a 600 s start-up run, on a build with the same compiler content as `49e0e36d`. The `s_bfm_b64` and `s_cselect_b64` first stops among the dispatched pipelines account for about 13,500 dispatches. **Plan:** ISA semantics on real 64-bit values. `tools/startup/gfx2hlsl.py` has the same `s_bfm_b64` rule (`op_s_bfm_b64`). Its `s_cselect_b64` and `s_not_b64` use its one-bit-per-lane mask model, which does not apply here. - `s_bfm_b64 D, S0, S1`: `D = ((1 << (S0 & 63)) - 1) << (S1 & 63)`, with both destination words written and SCC unchanged. S0 and S1 are single 32-bit operands: an SGPR or a constant. - `s_cselect_b64 D, S0, S1`: `D = SCC ? S0 : S1` per word, with SCC unchanged. - Constants extend to 64 bits as `pair_high` already does: inline negatives are sign-extended, and inline non-negatives and literals get a zero high word. - The destination is an even SGPR pair or `vcc`, with the existing wave32/wave64 VCC layout. - `exec` as a destination is left out for now. - `s_not_b64 D, S0`: `D = ~S0` per word, and SCC = (D != 0) over both words. - `s_cselect_b64` and `s_not_b64` take even SGPR pairs or constants as sources. - Out of scope: `s_bcnt1_i32_b64` and `s_ff1_i32_b64` on `exec` (13 and 11 first stops), whose results depend on the wave model. **Tests:** a hardware readback against a CPU reference. - `s_bfm_b64` with widths and offsets 0, 1, 31, 32, 33 and 63, plus the measured `32, 32`. - `s_cselect_b64` under both SCC values, with an SGPR pair, `-1` and a literal. - `s_not_b64` with its SCC result, read through `s_cselect_b32`. Mutants: a 32-bit `s_bfm_b64`, zero-extending the inline constant in `s_cselect_b64`, and an SCC taken from the low word only in `s_not_b64`. AI-assisted.
MasterDomino commented 2026-11-26 23:47:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T23:47:10Z.


Closed by #2959, merged into cpp-migration as f934df52. native_salu64_hardware passes on an RTX 5080 (author) and on an RX 9070 XT, and taking the s_not_b64 SCC from the low word only fails it. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7205856643 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2957#issuecomment-7205856643). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T23:47:10Z. --- Closed by #2959, merged into `cpp-migration` as `f934df52`. `native_salu64_hardware` passes on an RTX 5080 (author) and on an RX 9070 XT, and taking the `s_not_b64` SCC from the low word only fails it. AI-assisted.
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#2957
No description provided.