[PATCH] D35585: [ScopInfo] Introduce tryGetValueStored
Tobias Grosser via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 04:10:00 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308435: [ScopInfo] Introduce tryGetValueStored (authored by grosser).
Repository:
rL LLVM
https://reviews.llvm.org/D35585
Files:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Transform/Simplify.cpp
Index: polly/trunk/include/polly/ScopInfo.h
===================================================================
--- polly/trunk/include/polly/ScopInfo.h
+++ polly/trunk/include/polly/ScopInfo.h
@@ -889,6 +889,21 @@
/// 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; }
Index: polly/trunk/lib/Transform/Simplify.cpp
===================================================================
--- polly/trunk/lib/Transform/Simplify.cpp
+++ polly/trunk/lib/Transform/Simplify.cpp
@@ -238,13 +238,7 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35585.107279.patch
Type: text/x-patch
Size: 1707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170719/c104052c/attachment.bin>
More information about the llvm-commits
mailing list