[PATCH] D12286: [LV] Never widen an induction variable.

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 00:11:10 PDT 2015


anemet accepted this revision.
anemet added a comment.
This revision is now accepted and ready to land.

LGTM with some changes below.

Thanks for your patience!


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2683-2692
@@ -2682,12 +2683,12 @@
   } else {
     LI->addTopLevelLoop(Lp);
   }
   Lp->addBasicBlockToLoop(VecBody, *LI);
 
   // Use this IR builder to create the loop instructions (Phi, Br, Cmp)
   // inside the loop.
   Builder.SetInsertPoint(VecBody->getFirstNonPHI());
 
   // Generate the induction variable.
   setDebugLocFromInst(Builder, getDebugLocFromInstOrOperands(OldInduction));
   Induction = Builder.CreatePHI(IdxTy, 2, "index");
----------------
Great!

Also just to note what I missed about getNoopOrZeroExtend: it returns the original type (e.g. pointer type) if IdxTy and the original types have the same size.  The function comment is misleading in SCEV.  I'll fix this later.

================
Comment at: test/Transforms/LoopVectorize/ptr-induction.ll:1-3
@@ +1,4 @@
+; RUN: opt < %s -loop-vectorize -S | FileCheck %s
+
+; This testcase causes SCEV to return a pointer-typed exit value.
+
----------------
Doesn't this test need a datalayout to ensure that pointers are 64-bit?

================
Comment at: test/Transforms/LoopVectorize/ptr-induction.ll:3-6
@@ +2,6 @@
+
+; This testcase causes SCEV to return a pointer-typed exit value.
+
+; CHECK: @f
+; CHECK: %index.next = add i64 %index, 4
+define i8 @f(i8* readonly %a, i8* readnone %b) #0 {
----------------
So I guess you're checking here that we have converted this into an integer induction variable?   Perhaps a comment would be good.

================
Comment at: test/Transforms/LoopVectorize/ptr-induction.ll:17
@@ +16,3 @@
+  %a.pn = phi i8* [ %incdec.ptr8, %while.body ], [ %a, %while.body.preheader ]
+  %acc.07 = phi i32 [ %add, %while.body ], [ 0, %while.body.preheader ]
+  %incdec.ptr8 = getelementptr inbounds i8, i8* %a.pn, i64 1
----------------
When I tried this with my not completely up-to-date sources, vectorization failed with:

LV: Found an unidentified PHI.  %acc.07 = phi i32 [ %add, %while.body ], [ 0, %while.body.preheader ]

I think we should just remove this and its uses further down.


Repository:
  rL LLVM

http://reviews.llvm.org/D12286





More information about the llvm-commits mailing list