compute: accept v_cmp_ne_i32 as a vcc_lo lane guard #2103

Merged
Leyukaka merged 2 commits from upstream-pr/2110 into main 2026-11-25 00:46:53 +00:00
Leyukaka commented 2026-11-25 00:34:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T00:34:47Z.


Part of #2022 (item G, v_cmp_ne_i32).

The lane guard in tools/compute_store_aot.py accepted only v_cmp_{gt,lt,ge,le}_u32_e32 vcc_lo, src0, vN before s_and_saveexec_b32. This adds integer inequality.

  • v_cmp_ne_i32_e32 vcc_lo, src0, vN: source 0 is an integer immediate, or a resolved SGPR or VGPR; source 1 is a VGPR.
  • v_cmp_ne_i32_e64 vcc_lo, src0, src1: source 1 may also be a resolved SGPR or an integer immediate.
  • The guard emits != on the two 32-bit words. Inequality is the same for signed and unsigned words, so the existing unsigned guard path serves both.
  • The unsigned ordered compares now go through the same operand parser (ALU_SOURCE / alu_word). The verified-word rule is unchanged: a word read from a source buffer or computed by ALU in the program is still refused as a guard operand.
  • Still refused: v_cmpx, destinations other than vcc_lo, source modifiers, and VGPRs beyond v255. v_cmp_ne_u32 is not added here, although its lowering would be identical.

Tests

python -B tests/compute_alu_cmp_ne_check.py   # passes

The check covers:

  • both encodings, with SGPR, immediate (-1, 0x80000000, 0) and VGPR operands;
  • refusals: VGPR/SGPR order in _e32, vcc_hi, an SGPR destination, a negated source, v_cmpx, an unset SGPR, an SGPR holding a descriptor word, v256 in source 1, an out-of-range literal, and a word computed in the program (s_add_u32) in _e64 source 1;
  • a mutation that maps ne to ==, which must change the emitted guard.

Registered as compute_alu_cmp_ne_controls and added to the pure-Python lists. The existing controls in compute_store_check.py and compute_lane_mask_check.py, which exercise the unsigned guard, still pass with the shared parser.

Negative control: against the previous tools/compute_store_aot.py, the check fails with Unsupported compute instruction: v_cmp_ne_i32_e32 vcc_lo, s3, v0.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594368621 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2110). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-25T00:34:47Z. --- Part of #2022 (item G, `v_cmp_ne_i32`). The lane guard in `tools/compute_store_aot.py` accepted only `v_cmp_{gt,lt,ge,le}_u32_e32 vcc_lo, src0, vN` before `s_and_saveexec_b32`. This adds integer inequality. - `v_cmp_ne_i32_e32 vcc_lo, src0, vN`: source 0 is an integer immediate, or a resolved SGPR or VGPR; source 1 is a VGPR. - `v_cmp_ne_i32_e64 vcc_lo, src0, src1`: source 1 may also be a resolved SGPR or an integer immediate. - The guard emits `!=` on the two 32-bit words. Inequality is the same for signed and unsigned words, so the existing unsigned guard path serves both. - The unsigned ordered compares now go through the same operand parser (`ALU_SOURCE` / `alu_word`). The verified-word rule is unchanged: a word read from a source buffer or computed by ALU in the program is still refused as a guard operand. - Still refused: `v_cmpx`, destinations other than `vcc_lo`, source modifiers, and VGPRs beyond `v255`. `v_cmp_ne_u32` is not added here, although its lowering would be identical. ## Tests ``` python -B tests/compute_alu_cmp_ne_check.py # passes ``` The check covers: - both encodings, with SGPR, immediate (`-1`, `0x80000000`, `0`) and VGPR operands; - refusals: VGPR/SGPR order in `_e32`, `vcc_hi`, an SGPR destination, a negated source, `v_cmpx`, an unset SGPR, an SGPR holding a descriptor word, `v256` in source 1, an out-of-range literal, and a word computed in the program (`s_add_u32`) in `_e64` source 1; - a mutation that maps `ne` to `==`, which must change the emitted guard. Registered as `compute_alu_cmp_ne_controls` and added to the pure-Python lists. The existing controls in `compute_store_check.py` and `compute_lane_mask_check.py`, which exercise the unsigned guard, still pass with the shared parser. Negative control: against the previous `tools/compute_store_aot.py`, the check fails with `Unsupported compute instruction: v_cmp_ne_i32_e32 vcc_lo, s3, v0`. AI-assisted.
upstream-sync closed this pull request 2026-11-25 01:01:44 +00:00
Sign in to join this conversation.
No reviewers
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!2103
No description provided.