diff options
author | Michael Kruse <llvm@meinersbur.de> | 2017-05-11 22:56:46 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2017-05-11 22:56:46 +0000 |
commit | 4c27643398e52efb235c52d4ffa640893d6fcec7 (patch) | |
tree | e33e70d2894f20bda2f5f919b286dd54a078e02b | |
parent | bfaa1857b3cb10556d4a2e157688adc918802984 (diff) | |
download | bcm5719-llvm-4c27643398e52efb235c52d4ffa640893d6fcec7.tar.gz bcm5719-llvm-4c27643398e52efb235c52d4ffa640893d6fcec7.zip |
[DeLICM] Lookup input accesses.
Previous to this patch, we used VirtualUse to determine the input
access of an llvm::Value in a statement. The input access is the
READ MemoryAccess that makes a value available in that statement,
which can either be a READ of a MemoryKind::Value or the
MemoryKind::PHI for a PHINode in the statement. DeLICM uses the input
access to heuristically find a candidate to map without searching all
possible values.
This might modify the behaviour in that previously PHI accesses were
not considered input accesses before. This was unintentially lost when
"VirtualUse" was extracted from the "Known Knowledge" patch.
llvm-svn: 302838
-rw-r--r-- | polly/include/polly/ScopInfo.h | 26 | ||||
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 13 | ||||
-rw-r--r-- | polly/lib/Transform/DeLICM.cpp | 9 |
3 files changed, 42 insertions, 6 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index fbaa5a83b59..32b61b70b52 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1422,6 +1422,10 @@ public: return ValueReads.lookup(Inst); } + /// Return the MemoryAccess that loads a PHINode value, or nullptr if not + /// existing, respectively not yet added. + MemoryAccess *lookupPHIReadOf(PHINode *PHI) const; + /// Return the PHI write MemoryAccess for the incoming values from any /// basic block in this ScopStmt, or nullptr if not existing, /// respectively not yet added. @@ -1430,6 +1434,28 @@ public: return PHIWrites.lookup(PHI); } + /// Return the input access of the value, or null if no such MemoryAccess + /// exists. + /// + /// The input access is the MemoryAccess that makes an inter-statement value + /// available in this statement by reading it at the start of this statement. + /// This can be a MemoryKind::Value if defined in another statement or a + /// MemoryKind::PHI if the value is a PHINode in this statement. + MemoryAccess *lookupInputAccessOf(Value *Val) const { + if (isa<PHINode>(Val)) + if (auto InputMA = lookupPHIReadOf(cast<PHINode>(Val))) { + assert(!lookupValueReadOf(Val) && "input accesses must be unique; a " + "statement cannot read a .s2a and " + ".phiops simultaneously"); + return InputMA; + } + + if (auto *InputMA = lookupValueReadOf(Val)) + return InputMA; + + return nullptr; + } + /// Add @p Access to this statement's list of accesses. void addAccess(MemoryAccess *Access); diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index a5406100bf0..462ff6314f8 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1285,6 +1285,19 @@ void ScopStmt::buildAccessRelations() { } } +MemoryAccess *ScopStmt::lookupPHIReadOf(PHINode *PHI) const { + for (auto *MA : *this) { + if (!MA->isRead()) + continue; + if (!MA->isLatestAnyPHIKind()) + continue; + + if (MA->getAccessInstruction() == PHI) + return MA; + } + return nullptr; +} + void ScopStmt::addAccess(MemoryAccess *Access) { Instruction *AccessInst = Access->getAccessInstruction(); diff --git a/polly/lib/Transform/DeLICM.cpp b/polly/lib/Transform/DeLICM.cpp index 72abb088845..7bcb0726632 100644 --- a/polly/lib/Transform/DeLICM.cpp +++ b/polly/lib/Transform/DeLICM.cpp @@ -1949,12 +1949,9 @@ private: } }; - // Add initial scalar. Either the value written by the store, or all inputs - // of its statement. - auto WrittenValUse = VirtualUse::create( - S, TargetStoreMA->getAccessInstruction()->getOperandUse(0), LI, true); - if (WrittenValUse.isInter()) - Worklist.push_back(WrittenValUse.getMemoryAccess()); + auto *WrittenVal = TargetStoreMA->getAccessInstruction()->getOperand(0); + if (auto *WrittenValInputMA = TargetStmt->lookupInputAccessOf(WrittenVal)) + Worklist.push_back(WrittenValInputMA); else ProcessAllIncoming(TargetStmt); |