cpp-migration: lower v_mad_u64_u32 and v_mad_i64_i32 in the direct C++ compute path #3000

Closed
opened 2026-11-27 04:02:11 +00:00 by github-bot · 0 comments
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-27 03:59 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 v_mad_u64_u32 and v_mad_i64_i32 with direct DXIL lowering for <name>. I found this with the same per-opcode VOP3 probe as #2985, on cpp-migration 05438d65.

gfx2hlsl.py lowers both (mad64): D = S0 * S1 + S2 modulo 2^64, with two 32-bit factors and a 64-bit S2. The unsigned form also writes the carry-out of the 64-bit add to a lane mask (VCC or an SGPR). The signed carry-out is not established, so the signed form is accepted only with the discarding null destination.

Plan:

  • Use the same contract. Zero- or sign-extend the factors, add the 64-bit S2, and write the low and high words.
  • For the unsigned form, write the carry (sum < S2, unsigned) as a lane mask through the existing write_ballot path of the carry instructions.
  • Refuse v_mad_i64_i32 with any SDST other than null, and refuse modifiers.
  • S2 may be a VGPR pair or an aligned SGPR pair. Other S2 forms are refused here.
  • Fixture: a source-built dispatch with per-lane factors near 2^32 and S2 near 2^64, so that some lanes carry and some do not, against a CPU reference. The stored carry mask must equal the reference ballot. References that drop the high word, zero-extend the signed factors, or report no carry must differ.

AI-assisted.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-27 03:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/3000) 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 `v_mad_u64_u32` and `v_mad_i64_i32` with `direct DXIL lowering for <name>`. I found this with the same per-opcode VOP3 probe as #2985, on `cpp-migration` `05438d65`. `gfx2hlsl.py` lowers both (`mad64`): D = S0 * S1 + S2 modulo 2^64, with two 32-bit factors and a 64-bit S2. The unsigned form also writes the carry-out of the 64-bit add to a lane mask (VCC or an SGPR). The signed carry-out is not established, so the signed form is accepted only with the discarding null destination. **Plan:** - Use the same contract. Zero- or sign-extend the factors, add the 64-bit S2, and write the low and high words. - For the unsigned form, write the carry (sum < S2, unsigned) as a lane mask through the existing `write_ballot` path of the carry instructions. - Refuse `v_mad_i64_i32` with any SDST other than `null`, and refuse modifiers. - S2 may be a VGPR pair or an aligned SGPR pair. Other S2 forms are refused here. - Fixture: a source-built dispatch with per-lane factors near 2^32 and S2 near 2^64, so that some lanes carry and some do not, against a CPU reference. The stored carry mask must equal the reference ballot. References that drop the high word, zero-extend the signed factors, or report no carry must differ. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 04:02:11 +00:00
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#3000
No description provided.