shader: lower scalar leading-bit scans in pixel_aot #622

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

@⁠descent81 on GitHub · 2026-11-22 16:16 UTC · original
descent81:shader/scalar-leading-bit → main · +60 −0 · 2 files · 1 commits · merged 2026-11-22 17:01 UTC

Change

Add four distinct gfx1013 SOP1 encodings: s_flbit_i32_b32 and s_flbit_i32_b64 count leading zeros, while s_flbit_i32 and s_flbit_i32_i64 count leading bits equal to the sign bit. The result is 0xffffffff if the search finds no differing bit, and SCC is preserved. The 64-bit paths operate on two 32-bit words. The signed path normalizes both words using bit 63 before searching either word. The 32-bit paths reuse the existing high-bit helpers.

Verification

Tested 4724e26 on base efecacf. The fixture compares the full result word to a Python reference that searches a width-limited bit string, and reads SCC before the equality comparison. It covers zero, all ones, a set high bit, crossings at counts 31/32, and positive and negative inputs that reach count 63. As a negative control, substituting the unsigned 64-bit scan for the signed one changes the result for 0xffffffff_fffffffe from 63 to 0. Both GPU backends caught that substitution.

  • Binary and controls: The complete LLVM 15 pixel binary suite and translator controls passed on both revisions. The local binary-fixture set increased from 465 to 469 against gfx1013 and 461 to 465 against gfx1030. Each delta was exactly the four SOP1 forms, with no removals.
  • Windows: RTX 4060 (32.0.16.1088) and WARP (10.0.26100.9818) each matched all 4,096 pixels across 14 positive draws. Both predicate/rounding CTest entries passed (33.92 s hardware, 6.79 s WARP) with no skips.
python -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(hardware|warp)$' --output-on-failure

Evidence and follow-up

The fixture uses source-written assembly and synthetic input words under the repository's MIT license. This covers the scalar MSB scan family independently of the scalar LSB scans in #618. AMD RDNA 2 ISA reference

AI-assisted.

**@⁠descent81** on GitHub · 2026-11-22 16:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/622) `descent81:shader/scalar-leading-bit` → `main` · +60 −0 · 2 files · 1 commits · merged 2026-11-22 17:01 UTC ## Change Add four distinct gfx1013 SOP1 encodings: `s_flbit_i32_b32` and `s_flbit_i32_b64` count leading zeros, while `s_flbit_i32` and `s_flbit_i32_i64` count leading bits equal to the sign bit. The result is `0xffffffff` if the search finds no differing bit, and SCC is preserved. The 64-bit paths operate on two 32-bit words. The signed path normalizes both words using bit 63 before searching either word. The 32-bit paths reuse the existing high-bit helpers. ## Verification Tested `4724e26` on base `efecacf`. The fixture compares the full result word to a Python reference that searches a width-limited bit string, and reads SCC before the equality comparison. It covers zero, all ones, a set high bit, crossings at counts 31/32, and positive and negative inputs that reach count 63. As a negative control, substituting the unsigned 64-bit scan for the signed one changes the result for `0xffffffff_fffffffe` from 63 to 0. Both GPU backends caught that substitution. - **Binary and controls:** The complete LLVM 15 pixel binary suite and translator controls passed on both revisions. The local binary-fixture set increased from **465 to 469** against gfx1013 and **461 to 465** against gfx1030. Each delta was exactly the four SOP1 forms, with no removals. - **Windows:** RTX 4060 (32.0.16.1088) and WARP (10.0.26100.9818) each matched all 4,096 pixels across 14 positive draws. Both predicate/rounding CTest entries passed (33.92 s hardware, 6.79 s WARP) with no skips. ```sh python -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(hardware|warp)$' --output-on-failure ``` ## Evidence and follow-up The fixture uses source-written assembly and synthetic input words under the repository's MIT license. This covers the scalar MSB scan family independently of the scalar LSB scans in #618. [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:06:32 +00:00
github manually merged commit 4724e26fa8 into gh-pr/622/base 2026-11-26 22:06:34 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.