pixel_aot: lower the 64-bit integer compares v_cmp_*_{i64,u64} #788

Closed
opened 2026-11-23 04:43:39 +00:00 by JB2WIN · 3 comments
JB2WIN commented 2026-11-23 04:43:39 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T04:43:39Z.


pixel_aot lowers the 16- and 32-bit integer compares, but not the 64-bit ones: v_cmp_{f,lt,eq,le,gt,ne,ge,t}_{i64,u64}, which are 16 VOPC forms plus their 16 _e64 spellings in docs/coverage/gfx1013.tsv. tests/form_coverage_check.py currently lists v_cmp_lt_i64/v_cmp_lt_u64 as uncovered neighbours.

I'd like to take these. They need one thing the translator does not have yet, VGPR pair sources (v[a:a+1]), so I'm asking about the shape first.

Proposed first slice:

  • Sources:

    • a VGPR pair v[a:a+1] whose two registers hold tracked numeric values (low word in va, high word in va+1);
    • an SGPR pair through the existing scalar_u64;
    • an integer inline constant from -16 to 64, sign-extended to 64 bits.

    32-bit literals stay refused until their extension rule is pinned with an LLVM 15 round trip.

  • Compare: the result is the same per-lane condition the 32-bit compares produce, so v_cndmask_b32 and the existing lane-mask consumers read it unchanged.

    • Unsigned: compare the high words, and on equality the low words.
    • Signed: the same, with the high words compared as signed.
    • f/t are constants.
  • Refused: v_cmpx_* (exec-writing), source modifiers, misaligned or out-of-range pairs, and pending scalar loads or outstanding samples.

  • Tests: an integer-export draw that selects distinct words with v_cndmask_b32 per predicate. The word pairs make a 32-bit compare of either half disagree with the 64-bit result: equal high words with different low words, sign-bit-only, -1 against 0, and 0x7fffffff_ffffffff against 0x80000000_00000000. Mutations: signed as unsigned, high/low swapped, and only the low words compared. Plus form coverage, the LLVM 15 binary round trip and scanner support.

Does this fit, or would you rather VGPR pairs arrive first as their own small change? AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6552439895 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/794). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T04:43:39Z. --- `pixel_aot` lowers the 16- and 32-bit integer compares, but not the 64-bit ones: `v_cmp_{f,lt,eq,le,gt,ne,ge,t}_{i64,u64}`, which are 16 VOPC forms plus their 16 `_e64` spellings in `docs/coverage/gfx1013.tsv`. `tests/form_coverage_check.py` currently lists `v_cmp_lt_i64`/`v_cmp_lt_u64` as uncovered neighbours. I'd like to take these. They need one thing the translator does not have yet, **VGPR pair sources** (`v[a:a+1]`), so I'm asking about the shape first. Proposed first slice: - **Sources:** - a VGPR pair `v[a:a+1]` whose two registers hold tracked numeric values (low word in `va`, high word in `va+1`); - an SGPR pair through the existing `scalar_u64`; - an integer inline constant from -16 to 64, sign-extended to 64 bits. 32-bit literals stay refused until their extension rule is pinned with an LLVM 15 round trip. - **Compare:** the result is the same per-lane condition the 32-bit compares produce, so `v_cndmask_b32` and the existing lane-mask consumers read it unchanged. - Unsigned: compare the high words, and on equality the low words. - Signed: the same, with the high words compared as signed. - `f`/`t` are constants. - **Refused:** `v_cmpx_*` (exec-writing), source modifiers, misaligned or out-of-range pairs, and pending scalar loads or outstanding samples. - **Tests:** an integer-export draw that selects distinct words with `v_cndmask_b32` per predicate. The word pairs make a 32-bit compare of either half disagree with the 64-bit result: equal high words with different low words, sign-bit-only, -1 against 0, and `0x7fffffff_ffffffff` against `0x80000000_00000000`. Mutations: signed as unsigned, high/low swapped, and only the low words compared. Plus form coverage, the LLVM 15 binary round trip and scanner support. Does this fit, or would you rather VGPR pairs arrive first as their own small change? AI-assisted (Claude Code).
JB2WIN commented 2026-11-24 06:49:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T04:44:26Z.


A correction to my proposal, from LLVM 15.0.7 on gfx1013:

  • Unaligned VGPR pairs are valid. v_cmp_lt_u64 vcc_lo, v[3:4], v[4:5] assembles to [0x03,0x09,0xc2,0x7d], so the first slice would accept them, not refuse them.
  • Spelling. The e32 form prints with the explicit _e32 suffix.
  • Wave32 destination. The e64 destination must be a single SGPR or vcc_lo; s[10:11] is rejected.
  • Literals. A 32-bit literal source (0x12345678) assembles. I still plan to refuse it until its 64-bit extension rule is sourced.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7091827434 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/794#issuecomment-7091827434). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T04:44:26Z. --- A correction to my proposal, from LLVM 15.0.7 on `gfx1013`: - **Unaligned VGPR pairs are valid.** `v_cmp_lt_u64 vcc_lo, v[3:4], v[4:5]` assembles to `[0x03,0x09,0xc2,0x7d]`, so the first slice would accept them, not refuse them. - **Spelling.** The e32 form prints with the explicit `_e32` suffix. - **Wave32 destination.** The e64 destination must be a single SGPR or `vcc_lo`; `s[10:11]` is rejected. - **Literals.** A 32-bit literal source (`0x12345678`) assembles. I still plan to refuse it until its 64-bit extension rule is sourced.
R0Y00 commented 2026-11-24 06:49:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T04:53:07Z.


Proceed with the bounded register-pair slice. Accept the unaligned VGPR pairs demonstrated by LLVM 15 and keep the 32-bit literal extension outside the first change until independently established. Add cases with identical high words and distinct low words, high words that differ only in sign for signed versus unsigned ordering, and a source pair overlapping the other source. Preserve each operand’s original bit pattern in the comparison. Keep wave32/e32 and e64 destination rules explicit, and include an invalid pair or destination control.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7091943289 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/794#issuecomment-7091943289). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T04:53:07Z. --- Proceed with the bounded register-pair slice. Accept the unaligned VGPR pairs demonstrated by LLVM 15 and keep the 32-bit literal extension outside the first change until independently established. Add cases with identical high words and distinct low words, high words that differ only in sign for signed versus unsigned ordering, and a source pair overlapping the other source. Preserve each operand’s original bit pattern in the comparison. Keep wave32/e32 and e64 destination rules explicit, and include an invalid pair or destination control.
R0Y00 commented 2026-11-24 06:49:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T08:09:06Z.


The bounded 64-bit comparison slice landed in #803 (06c8bf8). The LLVM 15 round trip and WARP comparisons cover the high-word, low-word, signedness and overlapping-register cases. Explicit e32 destination checks remain in place. The 32-bit literal extension stays outside this slice.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7095101719 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/794#issuecomment-7095101719). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T08:09:06Z. --- The bounded 64-bit comparison slice landed in #803 (06c8bf8). The LLVM 15 round trip and WARP comparisons cover the high-word, low-word, signedness and overlapping-register cases. Explicit e32 destination checks remain in place. The 32-bit literal extension stays outside this slice.
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#788
No description provided.