<div class="gmail_quote">On 27 October 2010 14:20, Tobias Grosser <span dir="ltr"><<a href="mailto:grosser@fim.uni-passau.de">grosser@fim.uni-passau.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi,<br>
<br>
I am just found a scalar evolution function that does not seem canonical to me.<br>
<br>
The C code I used to produce it is:<br>
<br>
long foo (long n, long m) {<br>
  long i, j;<br>
  long A[n][m];<br>
<br>
  for (i = 0; i < n; ++i)<br>
    for (j = 0; j < m; ++j)<br>
      A[i][j] = 1;<br>
<br>
  return A[42][42];<br>
}<br>
<br>
This produces after applying -mem2reg the attached LLVM-IR.<br>
<br>
For the store to the array A in the loop I get this scalar evolution function:<br>
<br>
{((8 * ({0,+,(8 * %m)}<%for.cond> /u 8)) + %vla),+,8}<%for.cond5><br>
<br>
For me it seems the devision by "8" is not canonical. Is there any reason this can not be simplified to:<br>
<br>
{((1 * ({0,+,(1 * %m)}<%for.cond>)) + %vla),+,8}<%for.cond5><br></blockquote><div><br></div><div>Because we have to assume 2's complement arithmetic. Unless we know (or can prove) that the "8 *" won't overflow, we can't safely fold it away against "/u 8".</div>

<div><br></div><div>Nick</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
which is actually this:<br>
<br>
{(({0,+,%m}<%for.cond>) + %vla),+,8}<%for.cond5><br>
<br>
Any ideas<br>
Tobi<br>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br>