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

Manually merged
github merged 1 commit from gh-pr/604/head into gh-pr/604/base 2026-11-26 22:05:11 +00:00
Owner

@⁠descent81 on GitHub · 2026-11-22 15:14 UTC · original
descent81:shader/scalar-mul-high → main · +54 −1 · 2 files · 1 commits · merged 2026-11-22 15:43 UTC

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.

**@⁠descent81** on GitHub · 2026-11-22 15:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/604) `descent81:shader/scalar-mul-high` → `main` · +54 −1 · 2 files · 1 commits · merged 2026-11-22 15:43 UTC ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:05:09 +00:00
github manually merged commit 2019dbf502 into gh-pr/604/base 2026-11-26 22:05:11 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.