[llvm-dev] Regarding ScalarEvolution's loop backedge computation

Chawla, Pankaj via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 29 15:48:12 PDT 2016


It looks like ScalarEvolution bails out of loop backedge computation if it cannot prove the IV stride as either positive or negative (based on loop control condition). I think this logic can be refined for signed IVs.

Consider this simple loop-

void foo(int *A, int n, int s) {

  int i;

  for(i=0; i<n; i += s) {

The IV of this loop has this SCEV form-

Can someone please clarify why it is not ok to deduce the stride to be positive based on the assumption that the IV cannot have a signed underflow due to the presence of the NSW flag otherwise the program has undefined behavior?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160629/10545176/attachment.html>

More information about the llvm-dev mailing list