Iteratively simplify const conditions #107702
Closed
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.
cc @est31
It turns out that the drop flags are correctly inserted. However, the intermediate MIR transformation
SimplifyConstCondition
does not clean up the unreachable blocks. In addition, MIR validation understandably does not apply const analysis when tracking storage liveness, despite the fact that the "violating" block is apparently unreachable after applying a few rounds of data-flow const analysis.We shall take the example from the description of #104843. After applying
SimplifyConstCondition
once, we have the following control flow graph.Note that Block 10 is only reachable if the drop flag
_5
is set totrue
, except that_5
is alwaysfalse
.There are open questions. Is it desirable to apply
DataflowConstProp
iteratively? Is it the right way to apply this transformation given that we need to perform the patching a few times?Unfortunately, this will not provide answer to #103108.