shader: lower s_bfm_b64, s_cselect_b64 and s_not_b64 in the direct C++ compute path #2959
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2959"
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 Leyukaka on 2026-11-26T23:35:53Z.
Fixes #2957 (it needs closing by hand, since the base is not the default branch). Part of #2935. Target branch
cpp-migration.Change (
src/gfx1013_direct_compute.inl,src/gfx1013_compute_native.cpp): three_b64SALU ops are lowered as real 64-bit values in direct compute, ahead of the generic bitwise_b64block.s_bfm_b64 D, S0, S1:D = ((1 << (S0 & 63)) - 1) << (S1 & 63), both words written, SCC unchanged;s[104:105];s_cselect_b64 D, S0, S1: both words are selected by SCC, and SCC is unchanged.s_cselect_b32/_b64are now named as SCC readers. This changes no behaviour: they were already treated as possible readers.s_bfm_b64is marked SCC-preserving.s_not_b64 D, S0: both words are inverted, and SCC = (D != 0) over the 64-bit result.s_cselect_b64ands_not_b64:pair_highalready does: inline negatives are sign-extended, and inline non-negatives and literals get a zero high word;vcc/execsources are refused;vcc, with the existing VCC layout;execis refused.tools/startup/gfx2hlsl.pyhas the sames_bfm_b64rule (op_s_bfm_b64). Itss_cselect_b64ands_not_b64follow its one-bit-per-lane mask model, which does not apply to this path.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
cpp-migratione3670100plus this commit.native_salu64_hardwarepassed, 15 cases in two 32-lane groups with guards:s_bfm_b64with (width, offset) in (0,0), (1,0), (31,1), (32,32) from SGPRs, (33,0), (63,1) and (64,0). Each case sets SCC beforehand and checks that it is unchanged.s_cselect_b64under both SCC values, choosing between an SGPR pair and-1, and between the literal0x80000001and an SGPR pair, written tovcc.s_not_b64of four pairs, including all ones, whose SCC is 0.native_salu64_controlspassed:s_cselect_b64 exec, -1, 0ands_not_b64 s[24:25], vccare refused. Thes_bfm_b64destination refusal has no control.native_shift64_hardware,native_lane_access_hardware,native_dpp_quad_hardwareandnative_compute_clearstill pass.Mutation checks, run by hand; each fails the hardware test on its own case:
s_bfm_b64with a zero high word:bfm 32,32;-1ins_cselect_b64:cselect pair,-1 SCC=0;s_not_b64SCC from the low word only:not (0xffffffff, 0).Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests.e3670100and 297 with this commit; none that compiled before stops compiling.e3670100, 177 requests stop first at one of the two "unsupported wave64 scalar ... operation" refusals; 44 still do.s_bcnt1_i32_b64ands_ff1_i32_b64onexec, left out as in #2957.s_not_b64readsvccorexec, which this change refuses.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T23:47:05Z.
Review: APPROVED
Review of head
895decff, tested merged ontocpp-migratione3670100. It merges cleanly, and CI on the head is green. Approving and merging.Code read against RDNA 2:
s_bfm_b64is((1 << S0[5:0]) - 1) << S1[5:0]as a 64-bit value, so a raw width of 64 gives an empty mask. It sets the Int64 shader flag, and the constant fold intransfer()agrees.s_cselect_b64selects both words by SCC and leaves SCC unchanged. It is now named as an SCC reader in liveness.s_not_b64inverts both words and sets SCC from the whole 64-bit result.Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release.
ctest --preset release --no-tests=error -R '^native_'gives 45 tests, 44 passed and 1 skipped (77,native_comparison_pso_warp), includingnative_salu64_hardwareandnative_salu64_controls.Mutation here: taking the
s_not_b64SCC from the low word only failsnative_salu64_hardwareat('not (4294967295, 0)', (0, 4294967295), 1). With it restored, it passes.The
s_bfm_b64destination refusal has no control, as you note. That is minor. I will close #2957 by hand.AI-assisted; the commands above were run locally.