[PATCH] D23824: [ADCE] Add handling of PHI nodes when removing control flow

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 17:29:40 PDT 2016


1. Mark reaching definitions of a live phi as live
2. Mark the terminators of blocks control dependent on the edge of each phi
edge as live.
(and #2 only has to be done one per block, so if you have multiple phis in
the same block, you can skip #2 for the other phis)

If we want to go from there to something better, let's do it based on
evidence it helps something :)


On Tue, Sep 6, 2016 at 4:27 PM, David Callahan <dcallahan at fb.com> wrote:

> I think your proposed simplification was to always mark the terminators of
> predecessor blocks of a live PHI as live as well as the reaching
> definitions. Is that correct?
>
> From: Daniel Berlin <dberlin at dberlin.org>
> Date: Tuesday, September 6, 2016 at 4:23 PM
> To: "reviews+D23824+public+bfd9f3a940dac1be at reviews.llvm.org" <
> reviews+D23824+public+bfd9f3a940dac1be at reviews.llvm.org>
> Cc: David Callahan <dcallahan at fb.com>, Tim Amini Golling <
> mehdi.amini at apple.com>, "nadav.rotem at me.com" <nadav.rotem at me.com>, David
> Majnemer <david.majnemer at gmail.com>, Taewook Oh <twoh at fb.com>, Kevin Frei
> <freik at fb.com>, llvm-commits <llvm-commits at lists.llvm.org>
> Subject: Re: [PATCH] D23824: [ADCE] Add handling of PHI nodes when
> removing control flow
>
> Interesting.
> I don't see how it legally decides to do that, but okay.
> :)
>
> In any case, i still think you should simplify this code unless we have
> anything that shows the complexity is worth it :)
>
>
> On Tue, Sep 6, 2016 at 3:55 PM, David Callahan <dcallahan at fb.com> wrote:
>
>> david2050 added a comment.
>>
>> This snippet
>>
>>   int foo(int b, int j, int N) {
>>     if (b) {
>>       int i;
>>       for (i = 0; i < N; i++)
>>         ;
>>       j =       0;
>>     }
>>     return j;
>>   }
>>
>> via
>>
>>   clang -c -emit-llvm -O0 ...
>>   opt -sroa -adce -adce-remove-loops -S ...
>>
>> generates
>>
>>   define i32 @foo(i32 %b, i32 %j, i32 %N) #0 {
>>     %1 = icmp ne i32 %b, 0
>>     br i1 %1, label %2, label %3
>>
>>   ; <label>:2:                                      ; preds = %0
>>     br label %3
>>
>>   ; <label>:3:                                      ; preds = %2, %0
>>     %.0 = phi i32 [ %j, %0 ], [ 0, %2 ]
>>     ret i32 %.0
>>   }
>>
>>
>> https://reviews.llvm.org/D23824
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D23824&d=DQMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=lFyiPUrFdOHdaobP7i4hoA&m=2JaRmei7Q_OhLkH0vL2W3_6d3ZborW1k5yIfKnsIK4g&s=T7wb6dqAIu3VNjW8aCi4dLGAwqcdFvlHOr0MXu-H3xU&e=>
>>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160906/0f82b103/attachment.html>


More information about the llvm-commits mailing list