cpp-migration: accept inline, literal and SGPR-pair values in direct C++ 64-bit shifts #2951

Closed
opened 2026-11-26 22:59:09 +00:00 by Leyukaka · 1 comment
Leyukaka commented 2026-11-26 22:59:09 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T22:59:09Z.


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: in the direct compute path, v_lshrrev_b64 and v_lshlrev_b64 accept only a VGPR pair or the inline 0 as the shifted value (gfx1013_direct_compute.inl, "direct 64-bit shift operand"). Three forms are refused:

  • an inline integer, as in v_lshrrev_b64 v[2:3], 0, -1, which writes an all-ones pair;
  • a 32-bit literal;
  • an SGPR pair.

Measured on a local capture (counts and instruction shape only). Occurrences are static counts up to each program's s_endpgm.

  • In 2,689 compute requests, the shifted value is:
    • a nonzero inline integer in 108 requests (450 occurrences, 429 of them -1);
    • an SGPR pair in 104 requests;
    • a hex operand in the disassembly (a literal or an inline float) in 299 requests.
  • With compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests built from cpp-migration plus #2950, 21 request keys stop first at this refusal, all on an inline -1.
  • The runtime uses the Python translator, so I matched those keys against a 600 s start-up run: they were dispatched 13,814 times.

Plan: follow the rules gfx2hlsl.py already applies to these shifts (shift64 with i64_words):

  • A nonzero inline integer (-16..64) is sign-extended to 64 bits, the rule gfx2hlsl.py (i64_words) and pixel_aot.py (int64_operand) already apply.
  • A 32-bit literal is zero-extended for these logical shifts, as i64_words does.
  • An even SGPR pair (s[2k:2k+1], k <= 52) is read as a 64-bit value.
  • Keep refused:
    • inline floats, as in gfx2hlsl.py;
    • v_ashrrev_i64, which is not lowered here and appears in 2 requests.

Tests: a hardware readback against a CPU reference.

  • Cases: -1, -16, 64 and 1 shifted by 0, 1, 31, 32, 33 and 63, in both directions; a literal with its top bit set (0x80000001); and an SGPR pair whose two words differ.
  • Control: an inline float stays refused.
  • Mutants: zero-extending the inline value, sign-extending the literal, and swapping the SGPR pair's words.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6636462154 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2951). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-26T22:59:09Z. --- 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:** in the direct compute path, `v_lshrrev_b64` and `v_lshlrev_b64` accept only a VGPR pair or the inline `0` as the shifted value (`gfx1013_direct_compute.inl`, "direct 64-bit shift operand"). Three forms are refused: - an inline integer, as in `v_lshrrev_b64 v[2:3], 0, -1`, which writes an all-ones pair; - a 32-bit literal; - an SGPR pair. **Measured** on a local capture (counts and instruction shape only). Occurrences are static counts up to each program's `s_endpgm`. - In 2,689 compute requests, the shifted value is: - a nonzero inline integer in 108 requests (450 occurrences, 429 of them `-1`); - an SGPR pair in 104 requests; - a hex operand in the disassembly (a literal or an inline float) in 299 requests. - With `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` built from `cpp-migration` plus #2950, 21 request keys stop first at this refusal, all on an inline `-1`. - The runtime uses the Python translator, so I matched those keys against a 600 s start-up run: they were dispatched 13,814 times. **Plan:** follow the rules `gfx2hlsl.py` already applies to these shifts (`shift64` with `i64_words`): - A nonzero inline integer (-16..64) is sign-extended to 64 bits, the rule `gfx2hlsl.py` (`i64_words`) and `pixel_aot.py` (`int64_operand`) already apply. - A 32-bit literal is zero-extended for these logical shifts, as `i64_words` does. - An even SGPR pair (`s[2k:2k+1]`, `k <= 52`) is read as a 64-bit value. - Keep refused: - inline floats, as in `gfx2hlsl.py`; - `v_ashrrev_i64`, which is not lowered here and appears in 2 requests. **Tests:** a hardware readback against a CPU reference. - Cases: `-1`, `-16`, `64` and `1` shifted by 0, 1, 31, 32, 33 and 63, in both directions; a literal with its top bit set (`0x80000001`); and an SGPR pair whose two words differ. - Control: an inline float stays refused. - Mutants: zero-extending the inline value, sign-extending the literal, and swapping the SGPR pair's words. AI-assisted.
MasterDomino commented 2026-11-26 23:18:52 +00:00 (Migrated from github.com)
Author
Contributor

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


Closed by #2952, merged into cpp-migration as 49e0e36d. native_shift64_hardware passes on an RTX 5080 (author) and on an RX 9070 XT, and dropping the sign extension of negative inlines fails it. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7205436681 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2951#issuecomment-7205436681). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T23:18:52Z. --- Closed by #2952, merged into `cpp-migration` as `49e0e36d`. `native_shift64_hardware` passes on an RTX 5080 (author) and on an RX 9070 XT, and dropping the sign extension of negative inlines 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#2951
No description provided.