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.
llvm-svn: 251208
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 4e22fad..90d08fe 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -3218,8 +3218,11 @@
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 @@
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)