Repository navigation
Preserve distinct incoming loop values after dead-code elimination - #1
Open
MichaelSmithAI wants to merge 3 commits into
Conversation
- Replace fixed-point phi-only liveness in Module::write with a single-pass backward worklist seeded from side-effecting roots (stores, atomics, barriers, void/non-pure calls) and branch conditions across reachable reverse-postorder blocks. - Omit dead non-phi instructions, cyclic dead phis, unreachable blocks, and unreferenced dx.op declarations from the emitted DXIL module, fold loop latches left empty by DCE, and reuse one record scratch Vec during FUNCTION_BLOCK serialization. - Prune instruction-driven ShaderFlags (TYPED_UAV_LOADS, WAVE_OPS, INT64, RESOURCE_HEAP, SAMPLER_HEAP) in Shader::finish to those used by surviving instructions so declared flags and SFI0 always match live module usage. - Add unit and dxil.dll validation tests covering dead instruction/declaration elimination, latch folding, side-effecting atomic preservation, and post-DCE ShaderFlags pruning.
wbkepler
force-pushed
the
shader/dxil-dead-code-elimination
branch
from
November 24, 2026 16:17
2eea8e2 to
fa8d084
Compare
wbkepler
pushed a commit
that referenced
this pull request
Nov 25, 2026
Exercise the descriptor cursor regression on the actual heap capacity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A conditional can take two different paths back to the same loop header. After dead-code elimination, both paths can be empty. Folding both into their common predecessor loses the distinction between the values the loop header takes from each path.
This change accounts for an already folded successor when deciding whether to fold the other. The source-built regression starts with incoming values 0, 1 and 2 and verifies that the two backedges remain distinguishable while one empty latch is still folded.
Tested on the branch for Marvisak#697 at
2eea8e2. The graph assertion failed on that commit. With this change the Linux shader library suite passed all 59 tests. Microsoft DXV also accepted a source-built compute shader with the corrected graph. Native rendering and title performance were not measured. AI-assisted.