[PATCH] D24918: [ADCE] Add code to remove dead branches

David Callahan via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 14:32:03 PST 2016


david2050 added inline comments.


================
Comment at: lib/Transforms/Scalar/ADCE.cpp:665
+      // This is a live block but the terminator is not live so all
+      // control reaches the LivePdom, so we make the terminator
+      // an unconditional branch to that destination (B29 in the example
----------------
mehdi_amini wrote:
> david2050 wrote:
> > mehdi_amini wrote:
> > > To make sure I understand correctly: if the terminator was a conditional branch with each target BB in different dead region, then this terminator shouldn't be marked as dead?
> > This is a live block which has whose terminator is dead the implication is that all paths from this branch must reach LivePDOM (directly or through blocks with dead branches). We replace this branch with an unconditional branch.
> My question was about another invariant at this stage:
> 
> ```
> A
> | \
> B C
> | |
> D E
> ```
> 
> If B and C are dead, but A, D and E are live. 
> A's terminator branch to either B or C, which are both dead. However B and C aren't part of the same dead region.
> You're operating here under the assumption that A's terminator has be marked as live somehow, right?
Yes, if "D" is live then, as expressed, "A" is a control-dependence source for "D" (and for all non-A nodes listed) and as such will be marked live. "A" will be in the iterated dominance frontier of the "D" in the reverse control flow graph. If the terminator is not live then "D" and "E" must be the same (and in the code labeled LivePDOM).


https://reviews.llvm.org/D24918





More information about the llvm-commits mailing list