shader: lower scalar multiply-high instructions in pixel_aot #598

Merged
descent81 merged 1 commit from upstream-pr/604 into main 2026-11-22 15:43:56 +00:00
descent81 commented 2026-11-22 15:14:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by descent81 on 2026-11-22T15:14:43Z.


Change

pixel_aot now lowers s_mul_hi_i32 and s_mul_hi_u32. Both return the high 32 bits of a 32×32 product and preserve SCC. The unsigned lowering uses 16-bit partial products. The signed lowering adjusts that high word for each negative operand. Both paths use 32-bit integer arithmetic.

The source-built fixture compares both full result words with independent Python integer references and draws SCC in a separate output channel. It covers zero, signed extrema, mixed signs in both operand orders, mixed halfwords and all-one operands. For 0xFFFFFFFF × 0xFFFFFFFF, the signed high word is 0x00000000 and the unsigned high word is 0xFFFFFFFE. Replacing the signed instruction with the unsigned instruction while keeping that reference must fail.

Verification

Tested 2019dbf on base 997518d.

  • The complete LLVM 15 pixel binary fixture suite passed before and after the change. Against the gfx1013 reference, the measured set grew from 452 to 454. Against the gfx1030 reference it grew from 450 to 452. The only additions were the two SOP2 forms above.
  • Ran the new draw directly on RTX 4060 (32.0.16.1088) and WARP (10.0.26100.9818). Each backend matched all 4,096 pixels in each of six draws, with the debug layer enabled and zero reported errors or warnings. Both backends rejected the signed-to-unsigned substitution with pixel_mismatch.

Run from the repository root:

python -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

The draw is also registered through the Windows pixel_aot_predicate_rounding_* tests:

ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(hardware|warp)$' --output-on-failure

Evidence and follow-up

The fixture uses original assembly and synthetic inputs under the repository's MIT license. The coverage figures describe the local binary suite. AMD RDNA 2 ISA reference

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6544039621 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/604). Originally posted by [descent81](https://github.com/descent81) on 2026-11-22T15:14:43Z. --- ## Change `pixel_aot` now lowers `s_mul_hi_i32` and `s_mul_hi_u32`. Both return the high 32 bits of a 32×32 product and preserve SCC. The unsigned lowering uses 16-bit partial products. The signed lowering adjusts that high word for each negative operand. Both paths use 32-bit integer arithmetic. The source-built fixture compares both full result words with independent Python integer references and draws SCC in a separate output channel. It covers zero, signed extrema, mixed signs in both operand orders, mixed halfwords and all-one operands. For `0xFFFFFFFF × 0xFFFFFFFF`, the signed high word is `0x00000000` and the unsigned high word is `0xFFFFFFFE`. Replacing the signed instruction with the unsigned instruction while keeping that reference must fail. ## Verification Tested `2019dbf` on base `997518d`. - The complete LLVM 15 pixel binary fixture suite passed before and after the change. Against the gfx1013 reference, the measured set grew from 452 to 454. Against the gfx1030 reference it grew from 450 to 452. The only additions were the two SOP2 forms above. - Ran the new draw directly on RTX 4060 (32.0.16.1088) and WARP (10.0.26100.9818). Each backend matched all 4,096 pixels in each of six draws, with the debug layer enabled and zero reported errors or warnings. Both backends rejected the signed-to-unsigned substitution with `pixel_mismatch`. Run from the repository root: ```sh python -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` The draw is also registered through the Windows `pixel_aot_predicate_rounding_*` tests: ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(hardware|warp)$' --output-on-failure ``` ## Evidence and follow-up The fixture uses original assembly and synthetic inputs under the repository's MIT license. The coverage figures describe the local binary suite. [AMD RDNA 2 ISA reference](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture) AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:43:54 +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!598
No description provided.