shader: lower s_cmp_eq_u64, s_cmp_lg_u64, s_bitcmp0_b64 and s_bitcmp1_b64 in the direct compute path #3081
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3081"
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 legacy-code-archaeologist on 2026-11-27T14:35:23Z.
Lowers
s_cmp_eq_u64,s_cmp_lg_u64,s_bitcmp0_b64, ands_bitcmp1_b64in the direct C++ compute path (src/gfx1013_direct_compute.inl) to pure 32-bit DXIL writes ofSCC.Verification
Measured on Windows
10.0.26100(devpreset) onupstream/main88cddb09+cc7a8fbe:ctest --preset dev --no-tests=error -R '^native_salu_cmp64_' -V:native_salu_cmp64_ir(passed): dumps DXIL IR vianative_compute_ir_dumpfor all 22 cases (aligned pairs,null, negative inline-1, 32-bit literal0x80000001, bits0/31/32/63, wrapped SGPR indices65/96), asserts pure 32-bit IR (noi64ops), evaluates lane 0 to verifys[22:23]is untouched and exactSCCis stored, verifies 7 operand refusals, and catches 6 oracle mutants.native_salu_cmp64_controls(passed): compiles all 22 cases together viacompile_dxilto pure 32-bit DXIL, verifies the 7 operand refusals and 6 oracle mutants.native_salu_cmp64_hardware(skipped, exit77): NVIDIA Quadro M1000M does not support shader model 6.6 with wave32, so GPU readback is not measured locally.ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 47/47 passed (51.67s).python -B tests/docs_links_check.py: passed (102 Markdown files, 589 links).low_word_only_cmp,high_word_only_cmp,swap_and_or,ignore_bit5,invert_bitcmp) each failednative_salu_cmp64_ir(exit1).Fixes #3078
Refs #2935
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T18:09:37Z.
Review: COMMENTED
Review of
bc6dc3b5(comment only).The lowering reads correctly to me: 64-bit equality as two 32-bit compares joined with and/or, and the bit test picking the high word for index bit 5 with the shift masked to the word.
What holds me back from merging: the semantics are not checked by anything that runs.
controlsasserts only thaticmp eq i32,icmp ne i32andlshr i32appear in the DXIL dump, which other instructions in the same program could also produce, andnative_salu_cmp64_hardwareskipped on your machine and skips on WARP. Could you add either an IR-level control that pins the compare operands and the high-word selection (likenative_f16_alu_check.py irwithnative_compute_ir_dump), or ahardwarerun on an SM 6.6 wave32 GPU, reported with adapter, driver and commit? The same gap was pointed out on #3071.Command:
git diff origin/main...pull/3081/head -- src/ tests/(read).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T19:17:21Z.
@tedin7 Thanks for catching that gap! Added the IR-level check in rebased commit
cc7a8fbeonupstream/main(88cddb09):native_salu_cmp64_ir(tests/cmake/native_salu_cmp64.cmake, tests/native_salu_cmp64_check.py): Dumps DXIL IR vianative_compute_ir_dumpfor all 22 cases acrosss_cmp_eq_u64,s_cmp_lg_u64,s_bitcmp0_b64, ands_bitcmp1_b64, asserts no 64-bit integer IR ops appear, and evaluates lane 0 (interpret_pair_stores) to verify both the preserved SGPR pair (s[22:23]) and the exact storedSCCresult (pinning the low/high word compares, sign/zero-extension of inline-1/ literal0x80000001, and bit-5 high-wordselectins_bitcmp*), plus all 7 operand refusals.low_word_only_cmp,high_word_only_cmp,swap_and_or,ignore_bit5,invert_bitcmp) each failnative_salu_cmp64_ir(exit1).10.0.26100,devpreset):native_salu_cmp64_irandnative_salu_cmp64_controlspass;native_salu_cmp64_hardwareskips with77on NVIDIA Quadro M1000M (SM 6.1, no SM 6.6 wave32);^native_.*_(controls|ir)$passes47/47;python -B tests/docs_links_check.pypasses (102 files, 589 links). Also updated docs/experiments/native-direct-salu-cmp64.md.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T20:35:04Z.
Review: APPROVED
I reviewed
cc7a8fbemerged intomain671d2f46(tree4971b9a6, clean merge;mainnow includes #3071). This includes the hardware run tedin7 asked for.What I traced.
s_cmp_eq_u64/s_cmp_lg_u64: two 32-bit compares, joined withand/or.s_bitcmp0_b64/s_bitcmp1_b64: the word is chosen by index bit 5.shift()masks the amount to 5 bits, so this is exactly bitS1[5:0].nullreads as 0.pair_high()refuses unaligned pairs and wave64 specials, and sign-extends negative inline constants. The new code also refusesvccandexec.What I ran. I built
compile_dxil native_store_replay native_compute_ir_dumpindevandrelease, then ran:ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_salu_(cmp64|cmov)_'cmovbecause the two PRs shareuses_scc_after()and the SOPC/SOP1 dispatch.native_salu_cmp64_hardwareran and passed all 22 cases, each reportingpreserved pair, SCC and guards matched. These includeeq hi differs/eq lo differs, bits 0/31/32/63,null,-1and the0x80000001literal.Mutants (in
src/gfx1013_direct_compute.inl, rebuilt each time):_ir_hardwareword = a_lo)('bitcmp1 bit 32 set', (512, 0, 0), 1)('bitcmp1 bit 32 set', (0, 1), 1)s_cmp_eq_u64joins the halves withor('eq hi differs', (512, 1, 0), 0)Restored, all pass, and
git diff --checkis clean.Still unmeasured (the same caveat as #3071): whether gfx1013 zero-extends the 32-bit literal in a 64-bit compare. The hardware run shows only that the lowering matches the PR's
pair_high()reference.Verdict: approve on
cc7a8fbe.Environment: NVIDIA GeForce RTX 5090 (wave 32..32, SM 6.8), driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10.
CI:
Build and test on Windowspasses oncc7a8fbe.This reply was AI-assisted.