[PATCH] [LoopVectorize] Induction variables: support arbitrary constant step

Arnold Schwaighofer aschwaighofer at apple.com
Tue Jan 27 08:03:06 PST 2015

Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:722
@@ +721,3 @@
+    /// For pointer induction, returns StartValue[Index * StepValue].
+    Value *transform(IRBuilder<> &B, Value *Index) const {
+      switch (IK) {
hfinkel wrote:
> Given that we don't vectorize loops with wrap-around index spaces, as far as I know, we should be able to add nsw (or nuw or both) flags on these operations. Please do so when possible.
Hal, I don't think this is safe. Consider the following example. The canonical induction variable does not wrap but the derived one does.

int test(int *a) {
  int r = 0;
  uint64_t idx2=0;
  for (uint64_t i = 0 ; i < UINT64_MAX; ++i) {
    idx2 += 2;
  return r;



More information about the llvm-commits mailing list