shader: lower s_absdiff_i32 in the direct compute path #3054

Closed
opened 2026-11-27 12:30:45 +00:00 by github-bot · 0 comments
Owner

@⁠pigalot on GitHub · 2026-11-27 12:27 UTC · original

Part of the instruction-coverage item of #2935. Target branch main.

Gap. The direct C++ compute path refuses s_absdiff_i32 with direct DXIL lowering for s_absdiff_i32. gfx2hlsl.py, tools/pixel_aot.py and the HLSL path in src/gfx1013_compute_native.cpp already lower it, with the same rules:

  • D = |S0 - S1|, where the difference wraps to 32 bits first, so a difference of 0x80000000 stays 0x80000000;
  • SCC = D != 0.

Measured. I ran compile_dxil --refusals (counts only) at main 1ec2c938 on a local start-up capture of 2,689 compute requests. 7 of them stop first at s_absdiff_i32. With the change below, 1 of them compiles and the other 6 stop at later refusals (3 descriptor outside the bound table, 2 image modifiers, 1 unbound numeric SGPR).

Proposed.

  • Lower it in the direct path as a sub, then a select of the negation for a negative difference. SCC comes from the shared scalar tail.
  • Add a controls/hardware fixture covering both wrap cases, the equal pair (with SCC 1 beforehand), and literal and inline-constant operands, with mutant references.

I am taking it, and the PR follows. This issue was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 12:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/3054) Part of the instruction-coverage item of #2935. Target branch `main`. **Gap.** The direct C++ compute path refuses `s_absdiff_i32` with `direct DXIL lowering for s_absdiff_i32`. `gfx2hlsl.py`, `tools/pixel_aot.py` and the HLSL path in `src/gfx1013_compute_native.cpp` already lower it, with the same rules: - D = |S0 - S1|, where the difference wraps to 32 bits first, so a difference of 0x80000000 stays 0x80000000; - SCC = D != 0. **Measured.** I ran `compile_dxil --refusals` (counts only) at `main` `1ec2c938` on a local start-up capture of 2,689 compute requests. 7 of them stop first at `s_absdiff_i32`. With the change below, 1 of them compiles and the other 6 stop at later refusals (3 descriptor outside the bound table, 2 image modifiers, 1 unbound numeric SGPR). **Proposed.** - Lower it in the direct path as a `sub`, then a select of the negation for a negative difference. SCC comes from the shared scalar tail. - Add a controls/hardware fixture covering both wrap cases, the equal pair (with SCC 1 beforehand), and literal and inline-constant operands, with mutant references. I am taking it, and the PR follows. This issue was AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:30:45 +00:00
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#3054
No description provided.