shader: lower s_absdiff_i32 #128

Merged
Olima34 merged 1 commit from upstream-pr/128 into main 2026-11-26 18:09:23 +00:00
Olima34 commented 2026-11-26 17:57:40 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T17:57:40Z.


s_absdiff_i32 was decoded but refused ("s_absdiff_i32": 1 unique compute shader in the #123 story-load log, commit 182c14f).

What. It is lowered as the RDNA2 ISA's SOP2 operation: D = S0 - S1 as a wrapping 32-bit difference, negated when it is negative as a signed number, and SCC = D != 0. The arm sits next to s_abs_i32.

Tests.

  • gfx_refusal_tests::absdiff_translates: an FSPX compute program translates. It is refused on main.
  • victory-gpu addr_tests::absdiff_is_the_magnitude_of_the_signed_difference_on_the_gpu runs on Metal. It checks D and SCC for (5, 9), (9, 5), (-3, 4), (7, 7), (MIN, 1), (1, MIN) and (MIN, 0). The wrapping cases are the hardware's magnitudes: 1 - MIN gives i32::MAX, and |MIN - 0| gives 0x8000_0000.

The old refusal text appears nowhere else in crates/. victory-shader and victory-gpu tests (arm64, Metal), Windows clippy and cargo xtask policy pass.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6632402071 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/128). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-26T17:57:40Z. --- `s_absdiff_i32` was decoded but refused ("s_absdiff_i32": 1 unique compute shader in the #123 story-load log, commit 182c14f). **What.** It is lowered as the RDNA2 ISA's SOP2 operation: `D = S0 - S1` as a wrapping 32-bit difference, negated when it is negative as a signed number, and `SCC = D != 0`. The arm sits next to `s_abs_i32`. **Tests.** - `gfx_refusal_tests::absdiff_translates`: an FSPX compute program translates. It is refused on main. - `victory-gpu` `addr_tests::absdiff_is_the_magnitude_of_the_signed_difference_on_the_gpu` runs on Metal. It checks D and SCC for (5, 9), (9, 5), (-3, 4), (7, 7), (MIN, 1), (1, MIN) and (MIN, 0). The wrapping cases are the hardware's magnitudes: `1 - MIN` gives `i32::MAX`, and `|MIN - 0|` gives `0x8000_0000`. The old refusal text appears nowhere else in `crates/`. victory-shader and victory-gpu tests (arm64, Metal), Windows clippy and `cargo xtask policy` pass.
LakshanSivakumar commented 2026-11-26 18:10:01 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T18:10:01Z.


Merged, thanks. s_absdiff_i32 lowers, and the GPU test covers the wrapping cases.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7200129867 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/128#issuecomment-7200129867). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T18:10:01Z. --- Merged, thanks. `s_absdiff_i32` lowers, and the GPU test covers the wrapping cases.
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
LakshanSivakumar/Native-Victory-macOS!128
No description provided.