[PATCH] D17153: [LV] Identify more induction PHIs by coercing expressions to AddRecExprs

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 16:28:47 PDT 2016


anemet requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:4594-4627
@@ -4584,36 +4593,36 @@
         InductionDescriptor ID;
-        if (InductionDescriptor::isInductionPHI(Phi, PSE.getSE(), ID)) {
+        auto ValidateInductionPhi = [&]() {
           Inductions[Phi] = ID;
           // Get the widest type.
           if (!WidestIndTy)
             WidestIndTy = convertPointerToIntegerType(DL, PhiTy);
           else
             WidestIndTy = getWiderType(DL, PhiTy, WidestIndTy);
 
           // Int inductions are special because we only allow one IV.
           if (ID.getKind() == InductionDescriptor::IK_IntInduction &&
               ID.getStepValue()->isOne() &&
               isa<Constant>(ID.getStartValue()) &&
                 cast<Constant>(ID.getStartValue())->isNullValue()) {
             // Use the phi node with the widest type as induction. Use the last
             // one if there are multiple (no good reason for doing this other
             // than it is expedient). We've checked that it begins at zero and
             // steps by one, so this is a canonical induction variable.
             if (!Induction || PhiTy == WidestIndTy)
               Induction = Phi;
           }
 
           DEBUG(dbgs() << "LV: Found an induction variable.\n");
 
           // Until we explicitly handle the case of an induction variable with
           // an outside loop user we have to give up vectorizing this loop.
           if (hasOutsideLoopUser(TheLoop, &*it, AllowedExit)) {
             emitAnalysis(VectorizationReport(&*it) <<
                          "use of induction value outside of the "
                          "loop is not handled by vectorizer");
             return false;
           }
 
-          continue;
-        }
+          return true;
+        };
 
----------------
Why did you choose a lambda rather than a helper for this?  This is a pretty big function and the lambda is not small either.  Unless there is  a strong reason I would prefer factoring this part out into a helper.

================
Comment at: test/Transforms/LoopVectorize/induction.ll:171
@@ +170,3 @@
+; The SCEV expression of %sphi is (zext i8 {%t,+,1}<%loop> to i32)
+; In order to recognize it as an induction PHI and vectorize this loop,
+; we need to convert the SCEV expression into an AddRecExpr.
----------------
Please comment which induction PHI you mean here?  Same on the other testcase.


http://reviews.llvm.org/D17153





More information about the llvm-commits mailing list