cpp-migration: lower v_sad_u8, v_sad_hi_u8, v_sad_u16, v_sad_u32 and v_msad_u8 in the direct C++ compute path #2987

Closed
opened 2026-11-27 03:28:46 +00:00 by github-bot · 1 comment
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-27 03:23 UTC · original

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 the five sum-of-absolute-differences operations that gfx2hlsl.py lowers: v_sad_u8, v_sad_hi_u8, v_sad_u16, v_sad_u32 and v_msad_u8. I compiled each through compile_dxil ... gfx1013-direct-cs@0 from cpp-migration 05438d65, as a VOP3 instruction on VGPRs in a source-built request. All five fail with direct DXIL lowering for <name>. I found them with the same per-opcode VOP3 probe as #2985.

Plan: use the gfx2hlsl.py helpers sad_u8, sad4_u8, sad_u16 and sad_u32, which match tools/pixel_aot.py.

  • v_sad_u8: the sum of the four unsigned byte differences, plus S2.
  • v_sad_hi_u8: that sum shifted left by 16, plus S2.
  • v_sad_u16: the two unsigned halfword differences, plus S2.
  • v_sad_u32: |S0 - S1| unsigned, plus S2.
  • v_msad_u8: like v_sad_u8, but skipping each byte whose S1 byte is zero.

All results wrap modulo 2^32. Source abs/neg and clamp are refused, as gfx2hlsl.py refuses the modifiers. The fixture is a source-built dispatch with per-lane operands against a CPU reference, plus mutated references: signed byte differences, msad without its mask, sad_hi without its shift, and S2 dropped.

AI-assisted.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-27 03:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2987) 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 the five sum-of-absolute-differences operations that `gfx2hlsl.py` lowers: `v_sad_u8`, `v_sad_hi_u8`, `v_sad_u16`, `v_sad_u32` and `v_msad_u8`. I compiled each through `compile_dxil ... gfx1013-direct-cs@0` from `cpp-migration` `05438d65`, as a VOP3 instruction on VGPRs in a source-built request. All five fail with `direct DXIL lowering for <name>`. I found them with the same per-opcode VOP3 probe as #2985. **Plan:** use the `gfx2hlsl.py` helpers `sad_u8`, `sad4_u8`, `sad_u16` and `sad_u32`, which match `tools/pixel_aot.py`. - `v_sad_u8`: the sum of the four unsigned byte differences, plus S2. - `v_sad_hi_u8`: that sum shifted left by 16, plus S2. - `v_sad_u16`: the two unsigned halfword differences, plus S2. - `v_sad_u32`: |S0 - S1| unsigned, plus S2. - `v_msad_u8`: like `v_sad_u8`, but skipping each byte whose S1 byte is zero. All results wrap modulo 2^32. Source abs/neg and clamp are refused, as `gfx2hlsl.py` refuses the modifiers. The fixture is a source-built dispatch with per-lane operands against a CPU reference, plus mutated references: signed byte differences, msad without its mask, sad_hi without its shift, and S2 dropped. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:28:46 +00:00
Author
Owner

@⁠MasterDomino on GitHub · 2026-11-27 03:47 UTC · original

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

**@⁠MasterDomino** on GitHub · 2026-11-27 03:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2987#issuecomment-7209270957) Completed by #2990, merged into `cpp-migration` as b69c111f. Merges into a non-default branch do not close issues automatically.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#2987
No description provided.