[polly] r302839 - [DeLICM] Use input access heuristic for mapped PHI WRITEs.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 15:56:59 PDT 2017


Author: meinersbur
Date: Thu May 11 17:56:59 2017
New Revision: 302839

URL: http://llvm.org/viewvc/llvm-project?rev=302839&view=rev
Log:
[DeLICM] Use input access heuristic for mapped PHI WRITEs.

As with the scalar operand of the initial StoreInst, also use input
accesses when searching for new opportunities after mapping a
PHI write.

The same rational applies here: After LICM has been applied, the
promoted value will either be an instruction in the same statement
(in which case we fall back to try every scalar access of the
statement), or in another statement such that there will be such
an input access. In the latter case other scalars cannot have
originated from the same register promotion, at least not by LICM.

This mostly helps to decrease compilation time and makes debugging
easier by not pursuing unpromising routes. In some circumstances,
it may change the compiler's output.

Modified:
    polly/trunk/lib/Transform/DeLICM.cpp

Modified: polly/trunk/lib/Transform/DeLICM.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Transform/DeLICM.cpp?rev=302839&r1=302838&r2=302839&view=diff
==============================================================================
--- polly/trunk/lib/Transform/DeLICM.cpp (original)
+++ polly/trunk/lib/Transform/DeLICM.cpp Thu May 11 17:56:59 2017
@@ -1996,9 +1996,24 @@ private:
       if (SAI->isPHIKind()) {
         if (!tryMapPHI(SAI, EltTarget))
           continue;
-        // Add inputs of all incoming statements to the worklist.
-        for (auto *PHIWrite : DefUse.getPHIIncomings(SAI))
-          ProcessAllIncoming(PHIWrite->getStatement());
+        // Add inputs of all incoming statements to the worklist. Prefer the
+        // input accesses of the incoming blocks.
+        for (auto *PHIWrite : DefUse.getPHIIncomings(SAI)) {
+          auto *PHIWriteStmt = PHIWrite->getStatement();
+          bool FoundAny = false;
+          for (auto Incoming : PHIWrite->getIncoming()) {
+            auto *IncomingInputMA =
+                PHIWriteStmt->lookupInputAccessOf(Incoming.second);
+            if (!IncomingInputMA)
+              continue;
+
+            Worklist.push_back(IncomingInputMA);
+            FoundAny = true;
+          }
+
+          if (!FoundAny)
+            ProcessAllIncoming(PHIWrite->getStatement());
+        }
 
         AnyMapped = true;
         continue;




More information about the llvm-commits mailing list