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

Closed
opened 2026-11-27 03:59:18 +00:00 by legacy-code-archaeologist · 0 comments
legacy-code-archaeologist commented 2026-11-27 03:59:18 +00:00 (Migrated from github.com)
Contributor

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


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6639670037 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3000). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-27T03:59:18Z. --- 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.
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#3000
No description provided.