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

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 1 13:43:18 PDT 2016


Here's an implementation that just uses nearest useful post dominator:
https://github.com/apple/swift/blob/master/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Note the lack of needing to discover dead regions, etc.

(Rob Shillner's work here is unpublished, sadly)


There is a pseudocode version in
https://yunmingzhang.files.wordpress.com/2013/12/dcereport-2.pdf

Past that, if you can provide a simple example of the problem you are
trying to solve with this code, i'm happy to try to help explain how this
would work.


On Sat, Oct 1, 2016 at 9:22 AM, Daniel Berlin <dberlin at dberlin.org> wrote:

> When I get back to a sane computer I'll send a link to the paper
>
>
> On Sat, Oct 1, 2016, 9:40 AM David Callahan <dcallahan at fb.com> wrote:
>
>> david2050 added inline comments.
>>
>>
>> > dberlin wrote in ADCE.cpp:610
>> > Is the above really necessary?
>> >
>> > The standard way to do this, AFAIK, is to mark the useful block set
>> while doing marking, and then just walking up the PDT to find the nearest
>> block marked useful for each dead branch.
>> > Replace all uses of the bb with that block using RAUW.
>> > This should update phi nodes, since I believe the blocks in phi nodes
>> are still considered uses.
>>
>> I don't understand this approach. Given a live branch  (x,y) where y is
>> dead and  z is the live post-dominator of y, we can't just replace uses of
>> 'y' because the 'y' may not be directly referenced in phi nodes in 'z'
>> which only will old references to its predecessors. Also, 'y' could have
>> multiple branches into it which are dead.
>>
>> https://reviews.llvm.org/D24918
>>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161001/d80d4fb3/attachment.html>


More information about the llvm-commits mailing list