[PATCH] D22377: [SCEV] trip count calculation for loops with unknown stride

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 12:39:22 PDT 2016


sanjoy added a comment.

I think there still is a problem with the unsigned variant of this
patch:

  i8 index  = 127;
  i8 limit  = 128;
  i8 stride = 129;
  
  if (index u< limit) {
    do {
      index = wrapping_add(index, stride);
    } while (index u< limit);
  }

The backedge count of the loop above is 1.  Given that, the post-inc
can be marked `nuw` (since it goes from `127` -> `255` only).
However, the formula `(limit - start + (stride - 1)) /u stride`
computes `(128 - 0 + 128) /u 129` == `0`.


https://reviews.llvm.org/D22377





More information about the llvm-commits mailing list