cpp-migration: lower v_alignbit_b32, v_alignbyte_b32 and v_bfm_b32 in the direct C++ compute path #2985

Closed
opened 2026-11-27 03:14:20 +00:00 by legacy-code-archaeologist · 1 comment
legacy-code-archaeologist commented 2026-11-27 03:14:20 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T03:14:20Z.


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

Gap: the direct compute path refuses three VOP3 bit operations that gfx2hlsl.py lowers through its VOP3 table. Each fails in a source-built compute request (v_mov_b32 of v1 and v2 from v0, then the VOP3 form on v0, v1 and v2), compiled with compile_dxil ... gfx1013-direct-cs@0 from cpp-migration 05438d65:

direct DXIL lowering for v_alignbit_b32
direct DXIL lowering for v_alignbyte_b32
direct DXIL lowering for v_bfm_b32

I found them with a per-opcode probe of every VOP3 name in gfx1013_isa_tables.inl: 79 are refused, and these three have a gfx2hlsl.py lowering and no open issue or PR.

Plan: use the gfx2hlsl.py expressions.

  • v_alignbit_b32: bits [S2[4:0]+31 : S2[4:0]] of {S0, S1}; a zero shift returns S1.
  • v_alignbyte_b32: the same with S2[1:0] * 8.
  • v_bfm_b32: ((1 << S0[4:0]) - 1) << S1[4:0], like s_bfm_b32.

Shift amounts stay masked to five bits, so no shift reaches 32. The fixture is a source-built dispatch with per-lane operands that cover shifts 0, 1, 31, values above 31 and every byte count, against a CPU reference, with mutated references as controls (zero shift not special-cased, high and low words swapped).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6639191034 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2985). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-27T03:14:20Z. --- Target branch `cpp-migration`. Part of #2935 (instruction coverage: integer ALU). I am taking this; please say if you already have it locally and I will drop it. **Gap:** the direct compute path refuses three VOP3 bit operations that `gfx2hlsl.py` lowers through its VOP3 table. Each fails in a source-built compute request (`v_mov_b32` of v1 and v2 from v0, then the VOP3 form on v0, v1 and v2), compiled with `compile_dxil ... gfx1013-direct-cs@0` from `cpp-migration` `05438d65`: ```text direct DXIL lowering for v_alignbit_b32 direct DXIL lowering for v_alignbyte_b32 direct DXIL lowering for v_bfm_b32 ``` I found them with a per-opcode probe of every VOP3 name in `gfx1013_isa_tables.inl`: 79 are refused, and these three have a `gfx2hlsl.py` lowering and no open issue or PR. **Plan:** use the `gfx2hlsl.py` expressions. - `v_alignbit_b32`: bits [S2[4:0]+31 : S2[4:0]] of {S0, S1}; a zero shift returns S1. - `v_alignbyte_b32`: the same with S2[1:0] * 8. - `v_bfm_b32`: ((1 << S0[4:0]) - 1) << S1[4:0], like `s_bfm_b32`. Shift amounts stay masked to five bits, so no shift reaches 32. The fixture is a source-built dispatch with per-lane operands that cover shifts 0, 1, 31, values above 31 and every byte count, against a CPU reference, with mutated references as controls (zero shift not special-cased, high and low words swapped). AI-assisted.
MasterDomino commented 2026-11-27 04:35:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T04:35:48Z.


Completed by #2986, merged into cpp-migration as 24d92609. Merges into a non-default branch do not close issues automatically.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7209927286 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2985#issuecomment-7209927286). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-27T04:35:48Z. --- Completed by #2986, merged into `cpp-migration` as 24d92609. Merges into a non-default branch do not close issues automatically.
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#2985
No description provided.