[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 16:23:38 PDT 2016


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
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160906/46027d4d/attachment.html>


More information about the llvm-commits mailing list