[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 15:41:44 PDT 2016
Yes, that is why i said you may need to make the phi non-constant (ie make
a new parameter):
It is propagating the constant into the phi:
%j.0 = phi i32 [ 0, %0 ], [ 1, %2 ]
Thus, you never end up marking anything interesting live there.
On Tue, Sep 6, 2016 at 3:30 PM, David Callahan <dcallahan at fb.com> wrote:
> david2050 added a comment.
>
> I ran this test:
>
> int foo(int a, int b, int N) {
> int j = 0;
> if (b) {
> int i;
> for (i = 0; i < N; i++)
> ;
> j = 1;
> }
> return j;
> }
>
> compiled to bc and then processed: opt -sroa -adce -adce-remove-loops
> and it did successfully remove the loop. I also tried this variant
>
> int foo(int b, int N) {
> int j = 0;
> if (b) {
> int i;
> j = 1;
> for (i = 0; i < N; i++)
> ;
> }
> return j;
> }
>
> The final output for that one looked like:
>
> define i32 @foo(i32 %b, 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
> %j.0 = phi i32 [ 0, %0 ], [ 1, %2 ]
> ret i32 %j.0
> }
>
>
> https://reviews.llvm.org/D23824
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160906/11f27918/attachment.html>
More information about the llvm-commits
mailing list