Repository navigation
shader: lower s_cmp_eq_u64, s_cmp_lg_u64, s_bitcmp0_b64 and s_bitcmp1_b64 in the direct compute path - #3081
Conversation
tedin7
left a comment
There was a problem hiding this comment.
Review of bc6dc3b (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. controls asserts only that icmp eq i32, icmp ne i32 and lshr i32 appear in the DXIL dump, which other instructions in the same program could also produce, and native_salu_cmp64_hardware skipped 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 (like native_f16_alu_check.py ir with native_compute_ir_dump), or a hardware run 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.
Lower s_cmp_eq_u64, s_cmp_lg_u64, s_bitcmp0_b64 and s_bitcmp1_b64 in DirectCompute::scalar() using pure 32-bit DXIL ops writing SCC only, with IR-level evaluation (native_salu_cmp64_ir) via native_compute_ir_dump and compile controls (native_salu_cmp64_controls). Fixes R0Y00#3078 (part of R0Y00#2935). AI-assisted.
bc6dc3b to
cc7a8fb
Compare
|
@tedin7 Thanks for catching that gap! Added the IR-level check in rebased commit
AI-assisted. |
pigalot
left a comment
There was a problem hiding this comment.
I reviewed cc7a8fbe merged into main 671d2f46 (tree 4971b9a6, clean merge; main now 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].- Sources:
nullreads as 0.pair_high()refuses unaligned pairs and wave64 specials, and sign-extends negative inline constants. The new code also refusesvccandexec. - Only SCC is written.
What I ran. I built compile_dxil native_store_replay native_compute_ir_dump in dev and release, then ran:
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_salu_(cmp64|cmov)_'
- 6/6 passed in each preset. I included
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):
| mutant | _ir |
_hardware |
|---|---|---|
bit test always reads the low word (word = a_lo) |
fails at ('bitcmp1 bit 32 set', (512, 0, 0), 1) |
fails at ('bitcmp1 bit 32 set', (0, 1), 1) |
s_cmp_eq_u64 joins the halves with or |
fails at ('eq hi differs', (512, 1, 0), 0) |
fails |
Restored, all pass, and git diff --check is 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 Windows passes on cc7a8fbe.
This reply was AI-assisted.
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.