cpp-migration: lower s_bfm_b64, s_cselect_b64 and s_not_b64 in the direct C++ compute path #2957
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#2957
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Leyukaka on GitHub · 2026-11-26 23:25 UTC · original
Target branch
cpp-migration. Part of #2935 (instruction coverage). I am taking this; please say if you already have it locally and I will drop it.Gap: the direct compute path lowers the bitwise 64-bit SALU ops (
and,or,xor,andn2,orn2,nand,nor,xnorand theirsaveexecforms) and refuses the other_b64ones. Three of the refused ones are plain 64-bit arithmetic:s_bfm_b64ands_cselect_b64get "unsupported wave64 scalar mask operation";s_not_b64gets "unsupported wave64 scalar operation".Measured on a local capture of 2,689 compute requests (counts and instruction shape only), with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsbuilt fromcpp-migration49e0e36d. Requests stop first at:s_bfm_b64, e.g.s[28:29], 32, 32s_cselect_b64, e.g.s[40:41], -1, 0andvcc, -1, 0s_not_b64The runtime uses the Python translator, so I matched request keys against a 600 s start-up run, on a build with the same compiler content as
49e0e36d. Thes_bfm_b64ands_cselect_b64first stops among the dispatched pipelines account for about 13,500 dispatches.Plan: ISA semantics on real 64-bit values.
tools/startup/gfx2hlsl.pyhas the sames_bfm_b64rule (op_s_bfm_b64). Itss_cselect_b64ands_not_b64use its one-bit-per-lane mask model, which does not apply here.s_bfm_b64 D, S0, S1:D = ((1 << (S0 & 63)) - 1) << (S1 & 63), with both destination words written and SCC unchanged. S0 and S1 are single 32-bit operands: an SGPR or a constant.s_cselect_b64 D, S0, S1:D = SCC ? S0 : S1per word, with SCC unchanged.pair_highalready does: inline negatives are sign-extended, and inline non-negatives and literals get a zero high word.vcc, with the existing wave32/wave64 VCC layout.execas a destination is left out for now.s_not_b64 D, S0:D = ~S0per word, and SCC = (D != 0) over both words.s_cselect_b64ands_not_b64take even SGPR pairs or constants as sources.s_bcnt1_i32_b64ands_ff1_i32_b64onexec(13 and 11 first stops), whose results depend on the wave model.Tests: a hardware readback against a CPU reference.
s_bfm_b64with widths and offsets 0, 1, 31, 32, 33 and 63, plus the measured32, 32.s_cselect_b64under both SCC values, with an SGPR pair,-1and a literal.s_not_b64with its SCC result, read throughs_cselect_b32.Mutants: a 32-bit
s_bfm_b64, zero-extending the inline constant ins_cselect_b64, and an SCC taken from the low word only ins_not_b64.AI-assisted.
@MasterDomino on GitHub · 2026-11-26 23:47 UTC · original
Closed by #2959, merged into
cpp-migrationasf934df52.native_salu64_hardwarepasses on an RTX 5080 (author) and on an RX 9070 XT, and taking thes_not_b64SCC from the low word only fails it. AI-assisted.