[PATCH] D25095: [Polly] Ignore removed memory access. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 08:10:22 PDT 2016


Meinersbur created this revision.
Meinersbur added reviewers: grosser, jdoerfert, etherzhhb.
Meinersbur added subscribers: pollydev, llvm-commits.
Meinersbur added a project: Polly.

The DeLICM (and Known) pass will remove redundant explicit memory accesses. This patch prepares the code generator to ignore such removed access. The code currently has no effect because there is no pass except Invariant Load Hoisting yet that removes accesses. The hoisted loads are skipped because their value is already found in `GlobalMap`.

Opening for review since Tobias mentioned concerns about generateArrayLoad returning `Undef`.


https://reviews.llvm.org/D25095

Files:
  lib/CodeGen/BlockGenerators.cpp


Index: lib/CodeGen/BlockGenerators.cpp
===================================================================
--- lib/CodeGen/BlockGenerators.cpp
+++ lib/CodeGen/BlockGenerators.cpp
@@ -235,6 +235,16 @@
   if (Value *PreloadLoad = GlobalMap.lookup(Load))
     return PreloadLoad;
 
+  // Optimization passes (Invariant Load Hoisting, DeLICM) can remove loads when
+  // replaced by a load at another location. The invariant load case is caught
+  // by the lookup in GlobalMap which contains the value. In other cases the
+  // optimization pass is responsible to ensure that the load's value is not
+  // used, either by replacing all uses or it wasn't used in the first place. We
+  // need to return some value because VectorBlockGenerator might multiplex it
+  // into a vector register, even though the vector component is not used.
+  if (!Stmt.getArrayAccessOrNULLFor(Load))
+    return UndefValue::get(Load->getType());
+
   Value *NewPointer =
       generateLocationAccessed(Stmt, Load, BBMap, LTS, NewAccesses);
   Value *ScalarLoad = Builder.CreateAlignedLoad(
@@ -250,6 +260,12 @@
 void BlockGenerator::generateArrayStore(ScopStmt &Stmt, StoreInst *Store,
                                         ValueMapT &BBMap, LoopToScevMapT &LTS,
                                         isl_id_to_ast_expr *NewAccesses) {
+  // Optimization passes (DeLICM) can remove stores when deemed unnecessary or
+  // replaced by a store at another location. In this case do not generate a
+  // StoreInst.
+  if (!Stmt.getArrayAccessOrNULLFor(Store))
+    return;
+
   Value *NewPointer =
       generateLocationAccessed(Stmt, Store, BBMap, LTS, NewAccesses);
   Value *ValueOperand = getNewValue(Stmt, Store->getValueOperand(), BBMap, LTS,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25095.73054.patch
Type: text/x-patch
Size: 1732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/3bdfd83d/attachment.bin>


More information about the llvm-commits mailing list