[PATCH] Add optimization remarks to the loop unroller and vectorizer.

Diego Novillo dnovillo at google.com
Tue Apr 29 08:14:22 PDT 2014


On Tue, Apr 29, 2014 at 11:01 AM, hfinkel at anl.gov <hfinkel at anl.gov> wrote:

> Good point, vectorized with VF == 1 is confusing. We should report the VF
> == 1 cases as just, 'unrolled with interleaving factor N'.
>
> (We should also also say "interleave factor" or "unrolling interleave
> factor" in the regular case; we've decided to use the "interleave"
> terminology for the associated pragma).
>
>
Sure. How about this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140429/8c4fef4a/attachment.html>
-------------- next part --------------
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index 586c220..8ae1853 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1209,6 +1209,10 @@ struct LoopVectorize : public FunctionPass {
       if (UF == 1)
         return false;
       DEBUG(dbgs() << "LV: Trying to at least unroll the loops.\n");
+      F->getContext().emitOptimizationRemark(
+          DEBUG_TYPE, *F, L->getStartLoc(),
+          Twine("unrolled with interleaving factor " + Twine(UF) +
+                " (vectorization not beneficial)"));
       // We decided not to vectorize, but we may want to unroll.
       InnerLoopUnroller Unroller(L, SE, LI, DT, DL, TLI, UF);
       Unroller.vectorize(&LVL);
@@ -1217,17 +1221,17 @@ struct LoopVectorize : public FunctionPass {
       InnerLoopVectorizer LB(L, SE, LI, DT, DL, TLI, VF.Width, UF);
       LB.vectorize(&LVL);
       ++LoopsVectorized;
+
+      // Report the vectorization decision.
+      F->getContext().emitOptimizationRemark(
+          DEBUG_TYPE, *F, L->getStartLoc(),
+          Twine("vectorized loop (vectorization factor: ") + Twine(VF.Width) +
+              ", unrolling interleave factor: " + Twine(UF) + ")");
     }
 
     // Mark the loop as already vectorized to avoid vectorizing again.
     Hints.setAlreadyVectorized(L);
 
-    // Report the vectorization decision.
-    F->getContext().emitOptimizationRemark(
-        DEBUG_TYPE, *F, L->getStartLoc(),
-        Twine("vectorized loop (vectorization factor: ") + Twine(VF.Width) +
-            ", unroll factor: " + Twine(UF) + ")");
-
     DEBUG(verifyFunction(*L->getHeader()->getParent()));
     return true;
   }


More information about the llvm-commits mailing list