diff options
author | Tobias Grosser <tobias@grosser.es> | 2017-07-19 11:09:16 +0000 |
---|---|---|
committer | Tobias Grosser <tobias@grosser.es> | 2017-07-19 11:09:16 +0000 |
commit | 303bd07c6eda128756039f25362fb8ec7d0c0ed4 (patch) | |
tree | e8c6b898a02f49b9c15dc8fb98d7b0506af436f6 /polly | |
parent | f346cf269fd82071574f30716ff490931164cc1b (diff) | |
download | llvm-303bd07c6eda128756039f25362fb8ec7d0c0ed4.zip llvm-303bd07c6eda128756039f25362fb8ec7d0c0ed4.tar.gz llvm-303bd07c6eda128756039f25362fb8ec7d0c0ed4.tar.bz2 |
[ScopInfo] Introduce tryGetValueStored
Summary:
This makes code more readable and allows to reuse this functionality in
the future at other places.
Suggested-by Michael Kruse in post-commit review of r307660.
Reviewers: Meinersbur, bollu, gareevroman, efriedma, huihuiz, sebpop, simbuerg
Reviewed By: Meinersbur
Subscribers: pollydev, llvm-commits
Tags: #polly
Differential Revision: https://reviews.llvm.org/D35585
llvm-svn: 308435
Diffstat (limited to 'polly')
-rw-r--r-- | polly/include/polly/ScopInfo.h | 15 | ||||
-rw-r--r-- | polly/lib/Transform/Simplify.cpp | 8 |
2 files changed, 16 insertions, 7 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 27f79ba..8089c54 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -889,6 +889,21 @@ public: /// Return the access value of this memory access. Value *getAccessValue() const { return AccessValue; } + /// Return llvm::Value that is stored by this access, if available. + /// + /// PHI nodes may not have a unique value available that is stored, as in + /// case of region statements one out of possibly several llvm::Values + /// might be stored. In this case nullptr is returned. + Value *tryGetValueStored() { + assert(isWrite() && "Only write statement store values"); + if (isPHIKind()) { + if (Incoming.size() == 1) + return Incoming[0].second; + return nullptr; + } + return AccessValue; + } + /// Return the access instruction of this memory access. Instruction *getAccessInstruction() const { return AccessInstruction; } diff --git a/polly/lib/Transform/Simplify.cpp b/polly/lib/Transform/Simplify.cpp index 8fbd353..1abffe1 100644 --- a/polly/lib/Transform/Simplify.cpp +++ b/polly/lib/Transform/Simplify.cpp @@ -238,13 +238,7 @@ private: if (!isa<StoreInst>(WA->getAccessInstruction()) && !WA->isPHIKind()) continue; - auto ReadingValue = WA->getAccessValue(); - - if (WA->isPHIKind()) { - PHINode *PHI = cast<PHINode>(WA->getAccessValue()); - BasicBlock *BB = Stmt.getBasicBlock(); - ReadingValue = PHI->getIncomingValueForBlock(BB); - } + llvm::Value *ReadingValue = WA->tryGetValueStored(); if (!ReadingValue) continue; |