diff options
| -rw-r--r-- | polly/include/polly/ScopInfo.h | 8 | ||||
| -rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 23 |
2 files changed, 17 insertions, 14 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 8671de60cb5..1c31396e927 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1253,6 +1253,9 @@ private: /// will be inserted. DenseMap<PHINode *, MemoryAccess *> PHIWrites; + /// Map from PHI nodes to its read access in this statement. + DenseMap<PHINode *, MemoryAccess *> PHIReads; + //@} /// A SCoP statement represents either a basic block (affine/precise case) or @@ -1497,7 +1500,10 @@ public: /// Return the MemoryAccess that loads a PHINode value, or nullptr if not /// existing, respectively not yet added. - MemoryAccess *lookupPHIReadOf(PHINode *PHI) const; + MemoryAccess *lookupPHIReadOf(PHINode *PHI) const { + assert(isBlockStmt() || R->getEntry() == PHI->getParent()); + return PHIReads.lookup(PHI); + } /// Return the PHI write MemoryAccess for the incoming values from any /// basic block in this ScopStmt, or nullptr if not existing, diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index b89ed718855..80286cfcdb8 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1309,19 +1309,6 @@ void ScopStmt::buildAccessRelations() { } } -MemoryAccess *ScopStmt::lookupPHIReadOf(PHINode *PHI) const { - for (auto *MA : *this) { - if (!MA->isRead()) - continue; - if (!MA->isOriginalAnyPHIKind()) - continue; - - if (MA->getAccessInstruction() == PHI) - return MA; - } - return nullptr; -} - void ScopStmt::addAccess(MemoryAccess *Access) { Instruction *AccessInst = Access->getAccessInstruction(); @@ -1344,6 +1331,11 @@ void ScopStmt::addAccess(MemoryAccess *Access) { assert(!PHIWrites.lookup(PHI)); PHIWrites[PHI] = Access; + } else if (Access->isAnyPHIKind() && Access->isRead()) { + PHINode *PHI = cast<PHINode>(Access->getAccessValue()); + assert(!PHIReads.lookup(PHI)); + + PHIReads[PHI] = Access; } MemAccs.push_back(Access); @@ -2017,6 +2009,11 @@ void ScopStmt::removeAccessData(MemoryAccess *MA) { (void)Found; assert(Found && "Expected access data not found"); } + if (MA->isRead() && MA->isOriginalAnyPHIKind()) { + bool Found = PHIReads.erase(cast<PHINode>(MA->getAccessInstruction())); + (void)Found; + assert(Found && "Expected access data not found"); + } } void ScopStmt::removeMemoryAccess(MemoryAccess *MA) { |

