compute: accept EXEC as the destination of s_bitreplicate_b64_b32 #3179
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3179"
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-27T20:30:54Z.
Fixes #3170. Part of #2935. Target branch
main. This is the direct C++ path; #3030 (merged) coveredgfx2hlsl.py.Change (
src/gfx1013_direct_compute.inl):s_bitreplicate_b64_b32now accepts EXEC (s126/s127) as its destination pair in compute.active()reads s126 only. In split wave64, the upper half uses s127.Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on
main454fc0edplus this commit.native_bitreplicate_exec_hardware(new) sets EXEC from four sources: the literals0xff00ff00,0x0000ffffand0xf0f0f0f0, and the inline constant 5. It also checks that SCC is unchanged. It stores lane values under that EXEC, restores EXEC and stores the saved EXEC words, all against a CPU reference.native_bitreplicate_exec_controlskeeps an odd destination refused.native_direct_containerand thenative_salu*tests pass.native_bitreplicate_exec_hardware.Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsonmain6057071b. Since then only #3147 (3a550d0a, f16 frexp inline sources) touchesgfx1013_direct_compute.inl, outside this path.s_bitreplicate_b64_b32 exec, <literal>.v_permlanex16_b32(#3021, PR #3022) and 3 at "direct scalar move destination" (s_mov_b32 exec_hi).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T21:23:15Z.
Review of src/gfx1013_direct_compute.inl and src/gfx1013_compute_native.cpp changes:
s_cmp_lg_u64 is implemented as inequality, not signed less-than (BUG)
Lines 2258-2264:
For
s_cmp_eq_u64this produces(a_lo==b_lo) AND (a_hi==b_hi)— correct for 64-bit equality.For
s_cmp_lg_u64this produces(a_lo!=b_lo) OR (a_hi!=b_hi)— which is inequality, not signed less-than. In the RDNA2 ISA,s_cmp_lg_u64sets SCC if S0 <signed S1. The current code treats it as a simple "not equal" check on 64 bits.Fix: implement proper signed 64-bit comparison:
s_bitcmp0_b64 / s_bitcmp1_b64 — looks correct ✓
The word selection via bit 5 of the index and single-bit extraction is right.
s_cmov_b32/b64/k_i32 — looks correct ✓
Properly reads SCC from register 128, validates destination/source ranges per ISA spec, handles pair registers for b64 variant.
v_cvt_f16_u16/i16/u16/i16 — looks correct ✓
Uses the existing
legacyF16ToF32intrinsic for f16→int conversions with proper clamping/bounds logic. The inline half constant handling (registers 240-248) is consistent with how v_add_f16 already handles them.s_bitreplicate_b64_b32 — looks correct ✓
The EXEC destination change (removing the
i.dst != 126guard) is appropriate since EXEC is a valid scalar pair register in compute mode, equivalent to VCC for this instruction. The bit-replication algorithm (interleaving zeros then duplicating) is standard and matches the ISA description.transfer() clobber list — looks correct ✓
Adding
s_cmovk_i32to the set of instructions that clobber their destination symbol is right since it always writes D regardless of SCC state.Summary: Blocker on s_cmp_lg_u64. The signed less-than comparison for 64-bit values needs a proper fix as shown above before this can merge.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T21:57:19Z.
Thanks for reading through it.
s_cmp_lg_u64is "less or greater", that is, not equal: SCC = (S0 != S1), as intools/disasm_rdna2.py(SOPC 0x13, "not-equal unsigned 64-bit") andtools/startup/gfx2hlsl.py. So the OR of the per-half inequalities is the intended 64-bit test. That code also came from #3081, which is onmain; this PR does not change it. This PR only accepts EXEC as the destination ofs_bitreplicate_b64_b32.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:01:51Z.
Review: APPROVED
I reviewed
f37a6dd3merged overmaind474a393. The merge is clean (tree3b43fff4) andgit diff --cached --checkis clean.What I traced.
s126) is now accepted next to VCC in compute, and odd pairs, other special registers and graphics stay refused.write(i.dst)andwrite(i.dst + 1)go through the same scalar storage as any other EXEC pair write.active()readss126on every vector write in wave32, ands127for the upper half in split wave64, so the lane mask applies from the next instruction.transferalready clears both words fors_bitreplicate_b64_b32, which leaves EXEC unknown. SCC is not written.What I ran. I built
compile_dxil native_store_replayindevandrelease(plusnative_compute_ir_dumpinreleasefor the_irtests), then ran/O2, with no skips.native_bitreplicate_exec_hardwarecovers all four sources and checks the lane stores under the replicated EXEC, both saved EXEC words, the unchanged SCC and the guards.main6cc46a3c, the PR'snative_bitreplicate_exec_check.py controlspasses, because the odd-pair refusal predates this PR.hardwarefails, because the replay compile refuses+0x24: bitreplicate requires an aligned general scalar pair or compute VCC.Mutants in
src/gfx1013_direct_compute.inl. For each, I rebuilt indevand ran both new tests:0x0000ffff, word 136:0xffffffffvs0x00000000)0xff00ff00, word 136:0x00000000vs0xffff0000)Restored and rebuilt afterwards;
git diff --quietis clean.Non-blocking. SCC is checked only from 0, so a lowering that cleared SCC would pass. A case that sets SCC to 1 before the bitreplicate would pin that too. Wave64 isn't exercised, which matches the PR's scope.
Verdict: approve on
f37a6dd3.Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off.
CI:
Build and test on Windowspasses onf37a6dd3.This reply was AI-assisted.