aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-20 21:00:18 +0000
committerChris Lattner <sabre@nondot.org>2009-09-20 21:00:18 +0000
commit386251341fb6d7e08b9cd8e87e90dee5512ea9bf (patch)
treedce761c2c5e4c5f5adc460a9ecbd2a2035e95de6 /lib/Analysis/MemoryDependenceAnalysis.cpp
parent771a5422e167200f8a750449f688215f9abe925a (diff)
improve memdep to eliminate bitcasts (and aliases, and noop geps)
early for the stated reasons: this allows it to find more equivalences and depend less on code layout. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82404 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index 97b791caf9..d5db2ed651 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -521,6 +521,13 @@ getNonLocalPointerDependency(Value *Pointer, bool isLoad, BasicBlock *FromBB,
const Type *EltTy = cast<PointerType>(Pointer->getType())->getElementType();
uint64_t PointeeSize = AA->getTypeStoreSize(EltTy);
+ // If Pointer is a bitcast instruction, chomp through to the pointee since
+ // they are must alias. This increases the effectiveness of caching by
+ // finding more equivalences, avoids having to phi translate the bitcast, and
+ // avoids conflicts where we are looking for two "different" values in the
+ // same block when they are really just must aliases.
+ Pointer = Pointer->stripPointerCasts();
+
// This is the set of blocks we've inspected, and the pointer we consider in
// each block. Because of critical edges, we currently bail out if querying
// a block with multiple different pointers. This can happen during PHI
@@ -660,7 +667,6 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
SmallVectorImpl<NonLocalDepEntry> &Result,
DenseMap<BasicBlock*, Value*> &Visited,
bool SkipFirstBlock) {
-
// Look up the cached info for Pointer.
ValueIsLoadPair CacheKey(Pointer, isLoad);
@@ -793,6 +799,13 @@ getNonLocalPointerDepFromBB(Value *Pointer, uint64_t PointeeSize,
BasicBlock *Pred = *PI;
Value *PredPtr = PtrPHI->getIncomingValueForBlock(Pred);
+ // If Pointer is a bitcast instruction, chomp through to the pointee since
+ // they are must alias. This increases the effectiveness of caching by
+ // finding more equivalences, avoids having to phi translate the bitcast, and
+ // avoids conflicts where we are looking for two "different" values in the
+ // same block when they are really just must aliases.
+ PredPtr = PredPtr->stripPointerCasts();
+
// Check to see if we have already visited this pred block with another
// pointer. If so, we can't do this lookup. This failure can occur
// with PHI translation when a critical edge exists and the PHI node in