<div dir="ltr">I just subscribed this group.  This is my first time to post a question (not sure if this is a right place for discussion) after I have a brief look at LLVM OPT (dev trunk).   I would expect loop simplification and induction variable canonicalization pass (IndVarSimplify pass) should be able to convert the following loops into a simple canonical form, i.e., there is a canonical induction variable which starts at zero and steps by one,  getCanonicalInductionVariable() returns  the first PHI node in the loop header block.   <br><br>int test1 (int x[], int k, int s) {<br>  int sum = 0;<br>  for (int i = 0; i < k; i+=s) {<br>    sum += x[i];<br>  }<br>  return sum;<br>}<br><br>int test2(int x[], int k, int s) {<br>  int sum = 0;<br>  for (int i = k; i > 0; i--) {<br>    sum += x[i];<br>  }<br>  return sum;<br>}<br><br>Anyone can help explain why the current LLVM cannot canonicalize induction variables for the above loops (by design or a limitation to be fixed in the future)?  Thanks.<br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Best regards,<br><br>Yaoqing Gao</div>
</div>