[PATCH] [LoopAccesses] Make blockNeedsPredication static

Adam Nemet anemet at apple.com
Mon Feb 16 14:19:53 PST 2015


Hi hfinkel, aschwaighofer, nadav,

blockNeedsPredication is in LoopAccess in order to share it with the
vectorizer.  It's a utility needed by LoopAccess not strictly provided
by it but it's a good place to share it.  This makes the function static
so that it no longer required to create an LoopAccessInfo instance in
order to access it from LV.

This was actually causing problems because it would have required
creating LAI much earlier that LV::canVectorizeMemory().

This is part of the patchset that converts LoopAccessAnalysis into an
actual analysis pass.

http://reviews.llvm.org/D7683

Files:
  include/llvm/Analysis/LoopAccessAnalysis.h
  lib/Analysis/LoopAccessAnalysis.cpp
  lib/Transforms/Vectorize/LoopVectorize.cpp

Index: include/llvm/Analysis/LoopAccessAnalysis.h
===================================================================
--- include/llvm/Analysis/LoopAccessAnalysis.h
+++ include/llvm/Analysis/LoopAccessAnalysis.h
@@ -131,6 +131,8 @@
 
   /// Return true if the block BB needs to be predicated in order for the loop
   /// to be vectorized.
+  static bool blockNeedsPredication(BasicBlock *BB, Loop *TheLoop,
+                                    DominatorTree *DT);
   bool blockNeedsPredication(BasicBlock *BB);
 
   /// Returns true if the value V is uniform within the loop.
Index: lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- lib/Analysis/LoopAccessAnalysis.cpp
+++ lib/Analysis/LoopAccessAnalysis.cpp
@@ -1075,14 +1075,19 @@
         " need a runtime memory check.\n");
 }
 
-bool LoopAccessInfo::blockNeedsPredication(BasicBlock *BB)  {
+bool LoopAccessInfo::blockNeedsPredication(BasicBlock *BB, Loop *TheLoop,
+                                           DominatorTree *DT)  {
   assert(TheLoop->contains(BB) && "Unknown block used");
 
   // Blocks that do not dominate the latch need predication.
   BasicBlock* Latch = TheLoop->getLoopLatch();
   return !DT->dominates(BB, Latch);
 }
 
+bool LoopAccessInfo::blockNeedsPredication(BasicBlock *BB)  {
+  return blockNeedsPredication(BB, TheLoop, DT);
+}
+
 void LoopAccessInfo::emitAnalysis(VectorizationReport &Message) {
   assert(!Report && "Multiple report generated");
   Report = Message;
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -554,7 +554,7 @@
                             AliasAnalysis *AA, Function *F,
                             const TargetTransformInfo *TTI)
       : NumPredStores(0), TheLoop(L), SE(SE), DL(DL),
-        TLI(TLI), TheFunction(F), TTI(TTI), Induction(nullptr),
+        TLI(TLI), TheFunction(F), TTI(TTI), DT(DT), Induction(nullptr),
         WidestIndTy(nullptr),
         LAI(L, SE, DL, TLI, AA, DT),
         HasFunNoNaNAttr(false) {}
@@ -855,6 +855,8 @@
   Function *TheFunction;
   /// Target Transform Info
   const TargetTransformInfo *TTI;
+  /// Dominator Tree.
+  DominatorTree *DT;
 
   //  ---  vectorization state --- //
 
@@ -4174,7 +4176,7 @@
 }
 
 bool LoopVectorizationLegality::blockNeedsPredication(BasicBlock *BB)  {
-  return LAI.blockNeedsPredication(BB);
+  return LoopAccessInfo::blockNeedsPredication(BB, TheLoop, DT);
 }
 
 bool LoopVectorizationLegality::blockCanBePredicated(BasicBlock *BB,

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7683.20052.patch
Type: text/x-patch
Size: 2646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150216/806d64d0/attachment.bin>


More information about the llvm-commits mailing list