[PATCH] D28181: [MemDep] NFC walk invariant.group graph only down
Piotr Padlewski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 30 11:39:32 PST 2016
Prazek created this revision.
Prazek added a reviewer: reames.
Prazek added a subscriber: llvm-commits.
By using stripPointerCasts we can get to the root
value and then walk down the bitcast graph
https://reviews.llvm.org/D28181
Files:
lib/Analysis/MemoryDependenceAnalysis.cpp
Index: lib/Analysis/MemoryDependenceAnalysis.cpp
===================================================================
--- lib/Analysis/MemoryDependenceAnalysis.cpp
+++ lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -358,24 +358,13 @@
LoadOperandsQueue.push_back(V);
};
- TryInsertToQueue(LoadOperand);
+ // Insert the ptr after all casts and geps 0. This way we can search
+ // cast graph down only
+ TryInsertToQueue(LoadOperand->stripPointerCasts());
while (!LoadOperandsQueue.empty()) {
const Value *Ptr = LoadOperandsQueue.pop_back_val();
assert(Ptr);
- if (isa<GlobalValue>(Ptr))
- continue;
-
- // Value comes from bitcast: Ptr = bitcast x. Insert x.
- if (auto *BCI = dyn_cast<BitCastInst>(Ptr))
- TryInsertToQueue(BCI->getOperand(0));
- // Gep with zeros is equivalent to bitcast.
- // FIXME: we are not sure if some bitcast should be canonicalized to gep 0
- // or gep 0 to bitcast because of SROA, so there are 2 forms. When typeless
- // pointers will be upstream then both cases will be gone (and this BFS
- // also won't be needed).
- if (auto *GEP = dyn_cast<GetElementPtrInst>(Ptr))
- if (GEP->hasAllZeroIndices())
- TryInsertToQueue(GEP->getOperand(0));
+ assert(!isa<GlobalValue>(Ptr));
for (const Use &Us : Ptr->uses()) {
auto *U = dyn_cast<Instruction>(Us.getUser());
@@ -388,7 +377,11 @@
TryInsertToQueue(U);
continue;
}
- // U = getelementptr Ptr, 0, 0...
+ // Gep with zeros is equivalent to bitcast.
+ // FIXME: we are not sure if some bitcast should be canonicalized to gep 0
+ // or gep 0 to bitcast because of SROA, so there are 2 forms. When typeless
+ // pointers will be ready then both cases will be gone (and this BFS
+ // also won't be needed).
if (auto *GEP = dyn_cast<GetElementPtrInst>(U))
if (GEP->hasAllZeroIndices()) {
TryInsertToQueue(U);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28181.82738.patch
Type: text/x-patch
Size: 1952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161230/00f44608/attachment-0001.bin>
More information about the llvm-commits
mailing list