Repository navigation
Conversation
…k merging xcl-dev#3503 made the optimizer's DCE keep one reachable dx.op.rawBufferLoad when every raw load is dead: RawAndStructuredBuffers is set while the module is built, and a module that sets it without a raw load no longer matches its flags. The second DCE, which runs when simplify_cfg merged blocks, had no such guard and dropped the very load the first DCE kept. Both DCEs now go through one Module::eliminate_dead, which applies the guard. XCL_DXIL_MERGE_DCE_RAW_GUARD=0 leaves it out of the second DCE (the behaviour before this change). Like XCL_DXIL_NO_OPT, the switch bypasses the translated shader caches and is part of the warm pipeline settings key, so a cached shader never stands in for the other setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review (head cc6b6d1, diff read, not a merge-check; checks red):
Fine: by reading, AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: AI-written and posted by Foniass without a human check of each point. |
|
test report (not a merge-check; requested AMD test of #3664) base: df0cfef |
bmjask
left a comment
There was a problem hiding this comment.
Review of cc6b6d1a: 1 finding(s) (1 medium), most severe first.
- Medium
crates/xcl/src/gpu/dxil/module/opt.rs:1392: see below.
On lines outside the diff:
- Medium
crates/xcl/src/gpu/dxil/module/opt.rs:1392: The raw-load guard only sees blocks that are still reachable wheneliminate_deadruns, but constant branch folding (and the unreachable-block sweep at line 1153) empties blocks withself.blocks[b].clear()before any DCE, so raw loads that existed only in a folded-away branch are dropped with no guard. Take a shader whose only raw-buffer access is arawBufferLoadinsideif (CONST_FALSE): the CondBr folds to Br, the block becomes unreachable and is cleared,eliminate_deadfinds no reachable rawBufferLoad, and the emitted DXIL still declares RawAndStructuredBuffers with no raw load left, the mismatch this PR is meant to prevent. Working out the flag from the final optimized code (on the writer side) instead of protecting loads in each DCE would cover every path.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Requested by Prime
#3503 made the optimizer's dead-code elimination keep one raw buffer load when every raw load in a shader is dead. The RawAndStructuredBuffers shader flag is set while the module is built, so a shader that loses all its raw loads no longer matches its flags. But
Module::optimizeruns a second DCE aftersimplify_cfgmerges blocks, and that one had no such guard: it dropped the very load the first DCE had kept. Both DCEs now go through oneModule::eliminate_dead, which applies the guard, so the load survives block merging too.Related: #3503 added the guard to the first DCE; this adds it to the second. #3646 (open) also changes
Module::optimizeinopt.rsfor speed; the two may conflict in text, not in behaviour.What is in it
crates/xcl/src/gpu/dxil/module/opt.rs: the two DCE loops inModule::optimizebecome oneModule::eliminate_dead, with the raw-load guard in both; a switch for the second one; a unit test that a dead raw load survives the DCE after block merging.crates/xcl/src/gpu/recomp/pso.rs,crates/xcl/src/shaders.rs: the new switch bypasses the translated shader caches and is part of the warm pipeline settings key, likeXCL_DXIL_NO_OPT.Tested
cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnupasses. The test suite was not run on this exact branch.Regression run
Not tested
scripts/smoke.ps1on this branch; AMD.a_dead_raw_buffer_load_survives_the_dce_after_block_mergingwas not run on this branch.Switches
XCL_DXIL_MERGE_DCE_RAW_GUARD(default on):=0leaves the guard out of the DCE after block merging, as before this change. While it is set (to any value), the shader caches are bypassed, as withXCL_DXIL_NO_OPT.AI use
🤖 Generated with Claude Code