<div dir="ltr">Yes, that is why i said you may need to make the phi non-constant (ie make a new parameter):<div><br></div><div>It is propagating the constant into the phi:</div><div><div><span style="font-size:12.8px">    %j.0 = phi i32 [ 0, %0 ], [ 1, %2 ]</span><br style="font-size:12.8px"></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thus, you never end up marking anything interesting live there.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 6, 2016 at 3:30 PM, David Callahan <span dir="ltr"><<a href="mailto:dcallahan@fb.com" target="_blank">dcallahan@fb.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">david2050 added a comment.<br>
<br>
I ran this test:<br>
<br>
  int foo(int a, int b, int N) {<br>
    int j = 0;<br>
    if (b) {<br>
      int i;<br>
      for (i = 0; i < N; i++)<br>
        ;<br>
      j = 1;<br>
    }<br>
    return j;<br>
  }<br>
<br>
compiled to bc and then processed:  opt -sroa -adce -adce-remove-loops  and it did successfully remove the loop.  I also tried this variant<br>
<br>
  int foo(int b, int N) {<br>
    int j = 0;<br>
    if (b) {<br>
      int i;<br>
      j = 1;<br>
      for (i = 0; i < N; i++)<br>
        ;<br>
    }<br>
    return j;<br>
  }<br>
<br>
The final output for that one looked like:<br>
<br>
  define i32 @foo(i32 %b, i32 %N) #0 {<br>
    %1 = icmp ne i32 %b, 0<br>
    br i1 %1, label %2, label %3<br>
<br>
  ; <label>:2:                                      ; preds = %0<br>
    br label %3<br>
<br>
  ; <label>:3:                                      ; preds = %2, %0<br>
    %j.0 = phi i32 [ 0, %0 ], [ 1, %2 ]<br>
    ret i32 %j.0<br>
  }<br>
<br>
<br>
<a href="https://reviews.llvm.org/D23824" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D23824</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>