[polly] r308435 - [ScopInfo] Introduce tryGetValueStored
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 04:09:16 PDT 2017
Author: grosser
Date: Wed Jul 19 04:09:16 2017
New Revision: 308435
URL: http://llvm.org/viewvc/llvm-project?rev=308435&view=rev
Log:
[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
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Transform/Simplify.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=308435&r1=308434&r2=308435&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed Jul 19 04:09:16 2017
@@ -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; }
Modified: polly/trunk/lib/Transform/Simplify.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Transform/Simplify.cpp?rev=308435&r1=308434&r2=308435&view=diff
==============================================================================
--- polly/trunk/lib/Transform/Simplify.cpp (original)
+++ polly/trunk/lib/Transform/Simplify.cpp Wed Jul 19 04:09:16 2017
@@ -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;
More information about the llvm-commits
mailing list