gfx2hlsl: lower per-lane bit operations (bfe_i32, bcnt, ffbl, ffbh, bfrev) #1436
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1443"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:34:10Z.
Change
tools/startup/gfx2hlsl.pyrefused six per-lane bit operations (Unsupported: v_bfe_i32and the others). This lowersv_bfe_i32,v_bcnt_u32_b32,v_ffbl_b32,v_ffbh_u32,v_ffbh_i32andv_bfrev_b32to single HLSL expressions with the semanticstools/pixel_aot.pyalready uses. Source modifiers,clamp,op_seland a wrong operand count are refused; the operand count is now checked for the whole integer table (a missing operand raisedIndexError). The 64-bit carry forms,v_bfm_b32, 24-bit multiplies andv_alignbit_b32stay out of scope for separate changes.Outside
--preset pr:startup_gfx2hlsl_bit_alu_controls,startup_gfx2hlsl_bit_alu_warp,startup_gfx2hlsl_bit_alu_hardware.Verification
Linux, local (llvm-mc 19; llvm-mc 15 is not installed here, the CI job runs the
binarymode with it):python3 -B tests/startup_gfx2hlsl_bit_alu_check.py: all checks ok (17,459 bfe inputs, 324 bcnt, 81 per scan against an independent reference; six mutations each read a wrong word).origin/main: fails withUnsupported: v_bfe_i32.python3 -B tests/startup_gfx2hlsl_bit_alu_check.py binary llvm-mc-19: fixture words match, including the generated vertex stage for every draw set.startup_gfx2hlsl_sdwa_check.py,startup_translator_check.py,startup_flat_param_check.py,startup_image_*_check.py,rdna2_tools_check.py,docs_links_check.py,bidi_controls_check.py: unchanged and passing.Not run here: the
drawmode (FXC ps_5_1, DXC ps_6_0, WARP and hardware readback throughoffscreen_check --startup-flat-param) needs the Windows toolchain.Evidence and follow-up
Fixtures are assembled from original sources in the test file; the words are checked against llvm-mc. The reference uses bit loops, string reversal and integer arithmetic written from the ISA description, not the lowering's expressions. The draw mode also draws the mutated lowering and requires the mutated words. One assumption: results of 0xffffffff travel through a float render target unchanged, as the existing flat-parameter draw already relies on for NaN payloads.
AI-assisted; commands listed were executed locally.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:39:20Z.
AI-assisted. Fixed in
75908557(test only, lowering unchanged). The v_bcnt_u32_b32 mutation dropped the addend, so the mutated pixel stage no longer read the second flat parameter set and the WARP readback was all zero. It now subtracts the addend (same inputs read as the correct lowering). Expected mutated words now come from a plain integer definition per mutation (MUTATION_REF), cross-checked against the CPU evaluator over the whole grid. Draw mode for the new mutated words is not yet run on WARP: ctest --preset dev -R startup_gfx2hlsl_bit_alu (Debug and /O2).Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:42:21Z.
@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T11:42:45Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
75908557:--preset dev):ctest --preset dev -R '^(startup_gfx2hlsl_bit_alu_controls|startup_gfx2hlsl_bit_alu_warp)$' --no-tests=error --output-on-failure— 2/2 passed (startup_gfx2hlsl_bit_alu_controls0.65s,startup_gfx2hlsl_bit_alu_warp4.63s)/O2(--preset release):ctest --preset release -R '^(startup_gfx2hlsl_bit_alu_controls|startup_gfx2hlsl_bit_alu_warp)$' --no-tests=error --output-on-failure— 2/2 passed (startup_gfx2hlsl_bit_alu_controls0.69s,startup_gfx2hlsl_bit_alu_warp4.79s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T11:46:41Z.
Codex Review: Didn't find any major issues. Bravo.
Reviewed commit:
75908557c8ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T11:38:11Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
7590855ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.