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

hfinkel at anl.gov hfinkel at anl.gov
Tue Jan 27 06:38:58 PST 2015


Thanks for continuing to work on this. I think this is a nice over-all code simplification (that also gives us some forward-looking added capabilities).


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:712
@@ +711,3 @@
+
+    int isConsecutive() const {
+      if (StepValue && (StepValue->isOne() || StepValue->isMinusOne()))
----------------
I prefer that is* function return a boolean, but this returns a (-1, 0, 1) value. Maybe getConsecutiveDirection() would be better?


================
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) {
----------------
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.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:1663
@@ -1615,1 +1662,3 @@
+  Step = Builder.CreateMul(Cv, Step);
+  return Builder.CreateAdd(Val, Step, "induction");
 }
----------------
I know it was like this before, but nsw/nuw?

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:3192
@@ -3198,1 +3191,3 @@
+      Value *NormalizedIdx =
+          Builder.CreateSub(Induction, ExtendedIdx, "normalized.idx");
       // This is the vector of results. Notice that we don't generate
----------------
nsw/nuw? (same with the others in the code below)

================
Comment at: test/Transforms/LoopVectorize/arbitrary-induction-step.ll:7
@@ +6,3 @@
+
+; CHECK: LV: Checking a loop in "ind_plus2"
+; CHECK: LV: Did not find one integer induction var.
----------------
If you're checking debug output, you'll need to add:

  ; REQUIRES: asserts

to the entire test. Please break this out into a separate test file, if you'd like to do this, to limit the reduction in test coverage for non-asserts builds.

http://reviews.llvm.org/D7193

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list