On Sat, Nov 3, 2012 at 10:13 AM, Andrew Clinton <span dir="ltr"><<a href="mailto:ajclinto@gmail.com" target="_blank">ajclinto@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It's not clear to me how LICM would provide any benefit in hoisting<br>
redundancies out of conditional control flow - isn't the point of LICM<br>
to extract expressions from a loop so they can be executed once<br>
outside the loop?  If the contents of the loop are already expressed<br>
with conditionals, there wouldn't be any benefit to this optimization.<br>
<br>
If there was an invariant in the original loop that could be extracted<br>
by LICM, I can't see that splitting into an outer/inner loop would<br>
make this any easier to find.<br>
<br>
Do you have a test case that I could use to verify?<br></blockquote><div><br></div><div>This is artificial, but it demonstrates my idea, and we are talking about canonicalizing:</div><div><br></div><div><div>long test(long *z)</div>
<div>{</div><div>  long val = 0;</div><div>  long foo = 0;</div><div>  long i = 0;</div><div><br></div><div>  while (z[i++])</div><div>  {</div><div>    foo += val * 19;</div><div><br></div><div>    if (z[i++])</div><div>
    {</div><div>      val += z[i++];</div><div>    }</div><div>  }</div><div>  return val ^ foo;</div><div>}</div></div><div><br></div><div>TOT currently creates two loops and hoists the "val*19" out of the inner loop. With your patch, there's one loop, and the "val*19" is executed redundantly each time the if body is not executed.</div>
<div><br></div><div>Dan</div><div><br></div></div>