shader: lower s_flbit_i32_b32 in gfx2hlsl (Part of #1723) #2641
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2641
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2641/head"
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?
@SimSalabimse on GitHub · 2026-11-26 00:09 UTC · original
SimSalabimse:cursor/gfx2hlsl-s-flbit-5a9e→main· +291 −0 · 6 files · 4 commits · merged 2026-11-26 02:02 UTCChange
Part of #1723: port
s_flbit_i32_b32frompixel_aotintotools/startup/gfx2hlsl.py.D = S0 == 0 ? 0xffffffff : 31 - firstbithigh(S0)Claim before coding. Base is
main.AI-assisted.
Verification
Commit under test: this PR head (includes
sopk_accummutant-needle pin so the plain-scalar allow-list line is not required to be unique).All passed on Linux (CPU evaluation of the translated text). Windows WARP/hardware draws were not run here; the fixture is device-free.
Windows verification:
Evidence and follow-up
disasm_rdna2/gfx2hlsl.decode; no retail bytes.31 -offset diverges from the ISA reference.Checklist
@tedin7 on GitHub · 2026-11-26 00:11 UTC · original · reviewed
Review of head 8bd10767 (comment only).
What is fine:
op_s_flbit_i32_b32(tools/startup/gfx2hlsl.py):S0 == 0 ? 0xffffffff : 31 - firstbithigh(S0)matches the ISA, SCC untouched, lane masks and descriptor SGPRs refused, constants folded.s_flbit_i32_b32in gfx2hlsl (#2072 covers only the 64-bit forms and says the 32-bit one is left alone; #2041 is closed).What is missing before merge:
firstbithighon the GPU (zero input, high-bit set input) is the exact thing a string check cannot prove. Please add that case to the existing WARP/hardware suite.Local checks (Linux, worktree on the exact head):
python3 -B tests/startup_gfx2hlsl_s_flbit_check.py: all okpython3 -B tests/docs_links_check.py: okpython3 tests/bidi_controls_check.py: okgit diff --check origin/main...HEAD: clean31u - firstbithigh->30u - firstbithigh: the test fails as it should.No merge from me yet. Please add the WARP readback case, then this can go on.
AI-assisted; commands listed were executed locally.
@SimSalabimse on GitHub · 2026-11-26 00:49 UTC · original
Host Windows retest on this PR head:
Passed:
startup_gfx2hlsl_s_flbit,startup_gfx2hlsl_s_flbit_dispatch_warp,startup_gfx2hlsl_s_flbit_dispatch_hardware(3/3).@tedin7 on GitHub · 2026-11-26 01:36 UTC · original · reviewed
Review of head 3059909f (comment only). The WARP readback requested in the earlier review is now there.
What is fine:
op_s_flbit_i32_b32(tools/startup/gfx2hlsl.py):S0 == 0 ? 0xffffffff : 31 - firstbithigh(S0)matches the ISA, SCC untouched, lane masks and descriptor SGPRs refused, constant sources fold.startup_gfx2hlsl_s_flbit_dispatch_{warp,hardware}ctests (CMakeLists.txt) compile the translated expression into a compute shader and compare the UAV readback for 0, 1, 0x80000000, 0x00010000 with the CPU reference, same pattern as thes_abs/pack_absdiffdispatch tests. Exit 77 is skipped, the operand region is checked unchanged.s_flbit_i32_b32(#2072 only did the 64-bit forms, #2041 is closed).Local checks (Linux, worktree on the exact head):
python3 -B tests/startup_gfx2hlsl_s_flbit_check.py: all okpython3 -B tests/docs_links_check.py: okpython3 tests/bidi_controls_check.py: okgit diff --check origin/main...HEAD: clean31u - firstbithigh->30u - firstbithighin gfx2hlsl.py: the test fails as it should.Not run by this review: the D3D12 dispatch variants (Windows only); a Win2025 run follows separately.
Nit (not blocking): CMakeLists.txt has a stray blank line after the new comment block.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-26 02:01 UTC · original
Win2025 WARP receipt for head
716001d8(2 commits behind main, not updated).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
716001d8d0f0314a4dcfc9a821be4ec6b4f90c6c:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):103.40s(configure5.45s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check -- -j 2):127.98s(configure3.90s)tests/mesh_heap_sampler_check.pyok (1.1s),tests/startup_buffer_address_check.pyok (0.9s),tests/startup_buffer_format_word3_table_check.pyok (0.2s),tests/startup_compute_request_offline_check.pyok (0.9s),tests/startup_compute_store_format_xyzw_check.pyok (0.4s),tests/startup_compute_translate_check.pyok (0.4s),tests/startup_flat_param_check.pyok (0.3s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.3s),tests/startup_gfx2hlsl_bit_alu_check.pyok (1.1s),tests/startup_gfx2hlsl_capture_check.pyok (1.8s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.6s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.8s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.3s),tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyok (0.4s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.5s),tests/startup_gfx2hlsl_f32_lg_check.pyok (2.5s),tests/startup_gfx2hlsl_f32_nan_check.pyok (10.1s),tests/startup_gfx2hlsl_fma_mix_check.pyok (2.6s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.2s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.1s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.3s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.2s),tests/startup_gfx2hlsl_interp_p2_hi_check.pyok (0.3s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.4s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_data_check.pyok (0.1s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.1s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.5s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (4.0s),tests/startup_gfx2hlsl_pack_b32_f16_check.pyok (0.2s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.2s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.3s),tests/startup_gfx2hlsl_refusals_check.pyok (0.9s),tests/startup_gfx2hlsl_root_check.pyok (1.4s),tests/startup_gfx2hlsl_s_abs_check.pyok (0.1s),tests/startup_gfx2hlsl_s_bitset_check.pyok (0.2s),tests/startup_gfx2hlsl_s_flbit_check.pyok (0.1s),tests/startup_gfx2hlsl_sad_check.pyok (0.5s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.1s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.5s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.4s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.3s),tests/startup_gfx2hlsl_shift64_check.pyok (0.3s),tests/startup_gfx2hlsl_sload_const_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.1s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (10.9s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.9s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.3s),tests/startup_gfx2hlsl_swap_check.pyok (0.5s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (7.5s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.2s),tests/startup_gfx2hlsl_watch_check.pyok (3.2s),tests/startup_image_2d_array_check.pyok (0.3s),tests/startup_image_3d_check.pyok (0.3s),tests/startup_image_gather_lz_check.pyok (1.1s),tests/startup_image_load_d16_check.pyok (1.9s),tests/startup_image_sample_a16_check.pyok (0.4s),tests/startup_image_sample_b_check.pyok (0.4s),tests/startup_image_sample_c_check.pyok (0.4s),tests/startup_image_sample_l_check.pyok (0.3s),tests/startup_image_sample_lod_check.pyok (1.0s),tests/startup_inline_sampler_check.pyok (0.3s),tests/startup_mesh57_loop_refusal_check.pyok (0.3s),tests/startup_mesh57_skeleton_check.pyok (1.4s),tests/startup_run_ps1_check.pyok (15.2s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.3s),tests/startup_shader_cache_rekey_check.pyok (7.2s),tests/startup_smem_address_check.pyok (0.3s),tests/startup_stream_fetch_check.pyok (0.4s),tests/startup_stream_interface_check.pyok (0.4s),tests/startup_translator_check.pyok (1.3s)sccache: 8/124 hits; wall355.2sAI-assisted; commands listed were executed locally.