[PATCH] [LoopVectorize] Factor out a global emitLoopAnalysis

Adam Nemet anemet at apple.com
Thu Jan 29 16:52:38 PST 2015


Hi hfinkel, aschwaighofer,

The logic in emitAnalysis is duplicated across multiple functions.  This
splits it into a global function.  Another use will be added by the patchset.

NFC.  This is part of the patchset that splits out the memory dependence logic
from LoopVectorizationLegality into a new class LoopAccessAnalysis.
LoopAccessAnalysis will be used by the new Loop Distribution pass.

http://reviews.llvm.org/D7280

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp

Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -552,6 +552,17 @@
   }
 }
 
+/// \brief Emit an analysis note with the debug location from the instruction in
+/// \p Message or \p TheLoop's.
+static void emitLoopAnalysis(Report &Message, const Function *TheFunction,
+                             const Loop *TheLoop) {
+  DebugLoc DL = TheLoop->getStartLoc();
+  if (Instruction *I = Message.getInstr())
+    DL = I->getDebugLoc();
+  emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE,
+                                 *TheFunction, DL, Message.str());
+}
+
 /// \brief Propagate known metadata from one instruction to a vector of others.
 static void propagateMetadata(SmallVectorImpl<Value *> &To, const Instruction *From) {
   for (Value *V : To)
@@ -835,11 +846,7 @@
   /// Report an analysis message to assist the user in diagnosing loops that are
   /// not vectorized.
   void emitAnalysis(Report &Message) {
-    DebugLoc DL = TheLoop->getStartLoc();
-    if (Instruction *I = Message.getInstr())
-      DL = I->getDebugLoc();
-    emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE,
-                                   *TheFunction, DL, Message.str());
+    emitLoopAnalysis(Message, TheFunction, TheLoop);
   }
 
   /// The loop that we evaluate.
@@ -975,11 +982,7 @@
   /// Report an analysis message to assist the user in diagnosing loops that are
   /// not vectorized.
   void emitAnalysis(Report &Message) {
-    DebugLoc DL = TheLoop->getStartLoc();
-    if (Instruction *I = Message.getInstr())
-      DL = I->getDebugLoc();
-    emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE,
-                                   *TheFunction, DL, Message.str());
+    emitLoopAnalysis(Message, TheFunction, TheLoop);
   }
 
   /// Values used only by @llvm.assume calls.

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7280.19009.patch
Type: text/x-patch
Size: 2001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150130/63d8f8be/attachment.bin>


More information about the llvm-commits mailing list