[polly] r362258 - [ScopBuilder] Move verifyInvariantLoads function from ScopInfo. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 12:40:20 PDT 2019


Author: meinersbur
Date: Fri May 31 12:40:20 2019
New Revision: 362258

URL: http://llvm.org/viewvc/llvm-project?rev=362258&view=rev
Log:
[ScopBuilder] Move verifyInvariantLoads function from ScopInfo. NFC.

Refactor Scop and ScopBuilder class. Move verifyInvariantLoads from Scop
class to ScopBuilder class.

Patch by: Dominik Adamski <adamski.dominik at gmail.com>

Differential Revision: https://reviews.llvm.org/D62628

Modified:
    polly/trunk/include/polly/ScopBuilder.h
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopBuilder.cpp
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/include/polly/ScopBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopBuilder.h?rev=362258&r1=362257&r2=362258&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopBuilder.h (original)
+++ polly/trunk/include/polly/ScopBuilder.h Fri May 31 12:40:20 2019
@@ -360,6 +360,21 @@ class ScopBuilder {
   /// potential reduction.
   void checkForReductions(ScopStmt &Stmt);
 
+  /// Verify that all required invariant loads have been hoisted.
+  ///
+  /// Invariant load hoisting is not guaranteed to hoist all loads that were
+  /// assumed to be scop invariant during scop detection. This function checks
+  /// for cases where the hoisting failed, but where it would have been
+  /// necessary for our scop modeling to be correct. In case of insufficient
+  /// hoisting the scop is marked as invalid.
+  ///
+  /// In the example below Bound[1] is required to be invariant:
+  ///
+  /// for (int i = 1; i < Bound[0]; i++)
+  ///   for (int j = 1; j < Bound[1]; j++)
+  ///     ...
+  void verifyInvariantLoads();
+
   /// Collect loads which might form a reduction chain with @p StoreMA.
   ///
   /// Check if the stored value for @p StoreMA is a binary operator with one or

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=362258&r1=362257&r2=362258&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Fri May 31 12:40:20 2019
@@ -2040,21 +2040,6 @@ private:
   ///         nullptr if it cannot be hoisted at all.
   isl::set getNonHoistableCtx(MemoryAccess *Access, isl::union_map Writes);
 
-  /// Verify that all required invariant loads have been hoisted.
-  ///
-  /// Invariant load hoisting is not guaranteed to hoist all loads that were
-  /// assumed to be scop invariant during scop detection. This function checks
-  /// for cases where the hoisting failed, but where it would have been
-  /// necessary for our scop modeling to be correct. In case of insufficient
-  /// hoisting the scop is marked as invalid.
-  ///
-  /// In the example below Bound[1] is required to be invariant:
-  ///
-  /// for (int i = 1; i < Bound[0]; i++)
-  ///   for (int j = 1; j < Bound[1]; j++)
-  ///     ...
-  void verifyInvariantLoads();
-
   /// Hoist invariant memory loads and check for required ones.
   ///
   /// We first identify "common" invariant loads, thus loads that are invariant

Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=362258&r1=362257&r2=362258&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Fri May 31 12:40:20 2019
@@ -1306,6 +1306,20 @@ void ScopBuilder::checkForReductions(Sco
   }
 }
 
+void ScopBuilder::verifyInvariantLoads() {
+  auto &RIL = scop->getRequiredInvariantLoads();
+  for (LoadInst *LI : RIL) {
+    assert(LI && scop->contains(LI));
+    // If there exists a statement in the scop which has a memory access for
+    // @p LI, then mark this scop as infeasible for optimization.
+    for (ScopStmt &Stmt : *scop)
+      if (Stmt.getArrayAccessOrNULLFor(LI)) {
+        scop->invalidate(INVARIANTLOAD, LI->getDebugLoc(), LI->getParent());
+        return;
+      }
+  }
+}
+
 void ScopBuilder::collectCandidateReductionLoads(
     MemoryAccess *StoreMA, SmallVectorImpl<MemoryAccess *> &Loads) {
   ScopStmt *Stmt = StoreMA->getStatement();
@@ -1588,7 +1602,7 @@ void ScopBuilder::buildScop(Region &R, A
 
   scop->hoistInvariantLoads();
   scop->canonicalizeDynamicBasePtrs();
-  scop->verifyInvariantLoads();
+  verifyInvariantLoads();
   scop->simplifySCoP(true);
 
   // Check late for a feasible runtime context because profitability did not

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=362258&r1=362257&r2=362258&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri May 31 12:40:20 2019
@@ -3778,20 +3778,6 @@ isl::set Scop::getNonHoistableCtx(Memory
   return WrittenCtx;
 }
 
-void Scop::verifyInvariantLoads() {
-  auto &RIL = getRequiredInvariantLoads();
-  for (LoadInst *LI : RIL) {
-    assert(LI && contains(LI));
-    // If there exists a statement in the scop which has a memory access for
-    // @p LI, then mark this scop as infeasible for optimization.
-    for (ScopStmt &Stmt : Stmts)
-      if (Stmt.getArrayAccessOrNULLFor(LI)) {
-        invalidate(INVARIANTLOAD, LI->getDebugLoc(), LI->getParent());
-        return;
-      }
-  }
-}
-
 void Scop::hoistInvariantLoads() {
   if (!PollyInvariantLoadHoisting)
     return;




More information about the llvm-commits mailing list