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

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 1 14:05:36 PDT 2016


dberlin added inline comments.


> david2050 wrote in ADCE.cpp:217
> This seems super simple and conservative in the sense it will catch all loops. The variant of this code before this review cycle started used po_iterator but there no measurable benefit but quite a bit more code.

So, here are two of identical code, laid out in the IR differently,  where we will do different things, and should not.

A
jump C
B
jump D
C
jump B

A
jump C
C
jump B
B
jump D

In the first, the visitation order will be A, B, C.
You will mark A as seen. 
No successors seen, nothing marked.
You will now mark B as visited
No successors seen, nothing marked
You will now mark C as visited
You will see that you have marked B as visited
You will incorrectly think this is a back edge.

In the second, the visitation order, will be A, C, B.
You will mark A as seen.
No successors seen, nothing marked.
You will mark C as seen
No successors seen, nothing marked.
You will mark B as seen
No successors seen, nothing marked

> david2050 wrote in ADCE.cpp:228
> Still can only mark the terminator of that block live once.

yes, i read it wrong, sorry!

> david2050 wrote in ADCE.cpp:248
> I don't think so: marking the terminator of the source block not the successor block.

yes, i read it wrong, sorry!

https://reviews.llvm.org/D24918





More information about the llvm-commits mailing list