[polly] r251208 - ScopInfo: PHI-node uses in the EntryNode with an incoming BB that is not part

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 24 13:55:27 PDT 2015


Author: grosser
Date: Sat Oct 24 15:55:27 2015
New Revision: 251208

URL: http://llvm.org/viewvc/llvm-project?rev=251208&view=rev
Log:
ScopInfo: PHI-node uses in the EntryNode with an incoming BB that is not part
          of the Region are external.

During code generation we split off the parts of the PHI nodes in the entry
block, which have incoming blocks that are not part of the region. As these
split-off PHI nodes then are external uses, we consequently also need to model
these uses in ScopInfo.

Added:
    polly/trunk/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node.ll
Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=251208&r1=251207&r2=251208&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sat Oct 24 15:55:27 2015
@@ -3218,8 +3218,11 @@ bool ScopInfo::buildScalarDependences(In
 
     BasicBlock *UseParent = UI->getParent();
 
-    // Ignore the users in the same BB (statement)
-    if (UseParent == ParentBB)
+    // Ignore basic block local uses. A value that is defined in a scop, but
+    // used in a PHI node in the same basic block does not count as basic block
+    // local, as for such cases a control flow edge is passed between definition
+    // and use.
+    if (UseParent == ParentBB && !isa<PHINode>(UI))
       continue;
 
     // Do not build scalar dependences inside a non-affine subregion.
@@ -3245,6 +3248,27 @@ bool ScopInfo::buildScalarDependences(In
       continue;
     }
 
+    // Uses by PHI nodes in the entry node count as external uses in case the
+    // use is through an incoming block that is itself not contained in the
+    // region.
+    if (R->getEntry() == UseParent) {
+      if (auto *PHI = dyn_cast<PHINode>(UI)) {
+        bool ExternalUse = false;
+        for (unsigned i = 0; i < PHI->getNumIncomingValues(); i++) {
+          if (PHI->getIncomingValue(i) == Inst &&
+              !R->contains(PHI->getIncomingBlock(i))) {
+            ExternalUse = true;
+            break;
+          }
+        }
+
+        if (ExternalUse) {
+          AnyCrossStmtUse = true;
+          continue;
+        }
+      }
+    }
+
     // If the instruction can be synthesized and the user is in the region
     // we do not need to add scalar dependences.
     if (canSynthesizeInst)

Added: polly/trunk/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node.ll?rev=251208&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node.ll (added)
+++ polly/trunk/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node.ll Sat Oct 24 15:55:27 2015
@@ -0,0 +1,35 @@
+; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+
+; CHECK: MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
+; CHECK-NEXT: [p_0] -> { Stmt_bb3[] -> MemRef_tmp5[] };
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @hoge() {
+bb:
+  br label %bb2
+
+bb2:                                              ; preds = %bb
+  %tmp = load i64*, i64** undef
+  br label %bb3
+
+bb3:                                              ; preds = %bb9, %bb2
+  %tmp4 = phi i64* [ %tmp, %bb2 ], [ %tmp5, %bb9 ]
+  %tmp5 = getelementptr inbounds i64, i64* %tmp4, i64 1
+  %tmp6 = load i64, i64* %tmp5
+  %tmp7 = and i64 %tmp6, 4160749568
+  br i1 false, label %bb8, label %bb9
+
+bb8:                                              ; preds = %bb3
+  br label %bb9
+
+bb9:                                              ; preds = %bb8, %bb3
+  %tmp10 = icmp eq i64 %tmp7, 134217728
+  br i1 %tmp10, label %bb11, label %bb3
+
+bb11:                                             ; preds = %bb9
+  br label %bb12
+
+bb12:                                             ; preds = %bb11
+  ret void
+}




More information about the llvm-commits mailing list