Direct DXIL: fold Countbits of constants (AMD folds Bfrev(Countbits(K)) wrong) #2231
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2231
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2231"
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?
@Diskuss on GitHub · 2026-11-25 10:49 UTC · original
Diskuss:fuzz-1599-rdna4→main· +45 −3 · 3 files · 1 commits · draftOn the RX 9070 XT (RDNA4), the AMD driver (amdxc64) folds
Bfrev(Countbits(K))wrong whenKis a constant. It givesbfrev(n) | n(n = countbits(K)): for K = 2 that is 0x80000001 instead of 0x80000000. This is the cause of fuzz seed 1599 (62 mismatches) and offuzz_validate_and_gpu_3failing on this card.Shader::bit_countnow foldsCountbitsof a constant itself, so the driver never sees that pattern. The reduced HLSL repro and the analysis are in #2115.Part of #2115
What is in it
crates/xcl/src/gpu/dxil/module.rs:Module::int_const, which reads the value of an integer constant.crates/xcl/src/gpu/dxil/ops.rs:Shader::bit_countfoldsCountbitsof a constant, masked to the operand's width.crates/xcl/src/gpu/dxil/ops_tests.rs: new testbfrev_of_countbits_of_a_constant_matches_cpu, which compares the GPU result with the CPU.Tested
cargo test -p xcl --lib -- --test-threads=4:64eef49, onmain2898511): 1284 passed, 1 failed, 26 ignored.main2898511on the same machine: 1282 passed, 2 failed, 26 ignored.fuzz_validate_and_gpu_3now passes, and the new test is counted.mainand is not touched here:fuzz_validate_and_gpu_1, seed 722,res[30] = 0x1, CPU 0x7fffffff. #2192 covers it.bfrev_of_countbits_of_a_constant_matches_cpuandfuzz_validate_and_gpu_3alone (--test-threads=1): both pass.pso_measurement_compiles_an_exact_synthetic_record(Developer Mode is off).f16_programs_on_the_gpu/f32_programs_on_the_gpuper-lane cases (refused ops).Regression run
main:This PR:
The title is The Matrix Awakens. On
main(4d44186) and on this PR it dies the same way, about 1.5 to 3.5 s in: the title'sCreateCommandSignature(DispatchIndirectMesh) fails, then it reads a null pointer (0xc0000005). That is fixed only in #1887. So this run shows no new crash and no device removal, but it never reaches a shader that this change affects.Not tested
2898511(only-p xcl --libwas rerun; the change is in that crate).Countbits(zext((in & 0) | 2)). The translator does not see those as constants.AI use
🤖 Generated with Claude Code
@DavidM1911 on GitHub · 2026-11-25 16:31 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1 real failure, deterministic (also fails--test-threads=1):Same failure as #2229 (likely the same feature branch area). Needs a fix before merge.
— Devin
@CharNoir on GitHub · 2026-11-25 22:32 UTC · original
Test report for
64eef49("Direct DXIL: fold Countbits of constants").Tested
<rustc --version>; debug (testprofile); DXC 1.8.2502.11 (Windows SDK 10.0.26100.0)cargo test -p xcl --lib fuzz_validate_and_gpu, on main and on this PR:_0_1_2_3e1d84b7res[193] = 0x1, CPU0x0)64eef49Bfrev(Countbits(2)), which should be0x80000000; the GPU result on main is consistent with the driver misfoldingBfrev(Countbits(K)). The remaining seed 722 failure (WaveReadLaneFirst before a divergent switch) is unrelated to this PR; #2192 targets it.e1d84b7:cargo test --workspace -- --test-threads=4: 1421 passed, 2 failed (the two fuzz tests above), 46 ignored. SKIPPED GPU tests: 6 f16/f32 per-lane refusals (#1426) and the heap_window test ("no heap windows").Not tested
fuzz_validate_and_gputests were run on it.scripts/smoke.ps1regression run on a real title.AI use
@DavidM1911 on GitHub · 2026-11-26 00:59 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.