[polly] r270438 - [ScopInfo] Change removeMemoryAccesses to remove only one access. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 07:46:05 PDT 2016


Author: meinersbur
Date: Mon May 23 09:45:58 2016
New Revision: 270438

URL: http://llvm.org/viewvc/llvm-project?rev=270438&view=rev
Log:
[ScopInfo] Change removeMemoryAccesses to remove only one access. NFC.

This exposes the more basic operation for use by code not related to
invariant code hoisting.

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

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=270438&r1=270437&r2=270438&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Mon May 23 09:45:58 2016
@@ -1231,11 +1231,11 @@ public:
   /// @brief Add @p Access to this statement's list of accesses.
   void addAccess(MemoryAccess *Access);
 
-  /// @brief Remove the memory access in @p InvMAs.
+  /// @brief Remove a MemoryAccess from this statement.
   ///
-  /// Note that scalar accesses that are caused by any access in @p InvMAs will
+  /// Note that scalar accesses that are caused by MA will
   /// be eliminated too.
-  void removeMemoryAccesses(InvariantAccessesTy &InvMAs);
+  void removeMemoryAccess(MemoryAccess *MA);
 
   typedef MemoryAccessVec::iterator iterator;
   typedef MemoryAccessVec::const_iterator const_iterator;

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=270438&r1=270437&r2=270438&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon May 23 09:45:58 2016
@@ -1706,22 +1706,19 @@ void ScopStmt::print(raw_ostream &OS) co
 
 void ScopStmt::dump() const { print(dbgs()); }
 
-void ScopStmt::removeMemoryAccesses(InvariantAccessesTy &InvMAs) {
-  // Remove all memory accesses in @p InvMAs from this statement
-  // together with all scalar accesses that were caused by them.
+void ScopStmt::removeMemoryAccess(MemoryAccess *MA) {
+  // Remove the memory accesses from this statement
+  // together with all scalar accesses that were caused by it.
   // MK_Value READs have no access instruction, hence would not be removed by
   // this function. However, it is only used for invariant LoadInst accesses,
   // its arguments are always affine, hence synthesizable, and therefore there
   // are no MK_Value READ accesses to be removed.
-  for (const auto &InvMA : InvMAs) {
-    auto *MA = InvMA.MA;
-    auto Predicate = [&](MemoryAccess *Acc) {
-      return Acc->getAccessInstruction() == MA->getAccessInstruction();
-    };
-    MemAccs.erase(std::remove_if(MemAccs.begin(), MemAccs.end(), Predicate),
-                  MemAccs.end());
-    InstructionToAccess.erase(MA->getAccessInstruction());
-  }
+  auto Predicate = [&](MemoryAccess *Acc) {
+    return Acc->getAccessInstruction() == MA->getAccessInstruction();
+  };
+  MemAccs.erase(std::remove_if(MemAccs.begin(), MemAccs.end(), Predicate),
+                MemAccs.end());
+  InstructionToAccess.erase(MA->getAccessInstruction());
 }
 
 //===----------------------------------------------------------------------===//
@@ -3526,7 +3523,8 @@ void Scop::hoistInvariantLoads() {
         InvariantAccesses.push_back({Access, NHCtx});
 
     // Transfer the memory access from the statement to the SCoP.
-    Stmt.removeMemoryAccesses(InvariantAccesses);
+    for (auto InvMA : InvariantAccesses)
+      Stmt.removeMemoryAccess(InvMA.MA);
     addInvariantLoads(Stmt, InvariantAccesses);
   }
   isl_union_map_free(Writes);




More information about the llvm-commits mailing list