aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Bolka <a@bolka.at>2009-07-28 19:49:25 +0000
committerAndreas Bolka <a@bolka.at>2009-07-28 19:49:25 +0000
commite00b49406f90b8daf506fd506591f9d2dcbd1121 (patch)
treec1809f441cf6b3e5afc10e8f7c6a694002b02573 /lib
parentf109601f445629e11a2583c5c44d9464a76a3f05 (diff)
downloadexternal_llvm-e00b49406f90b8daf506fd506591f9d2dcbd1121.zip
external_llvm-e00b49406f90b8daf506fd506591f9d2dcbd1121.tar.gz
external_llvm-e00b49406f90b8daf506fd506591f9d2dcbd1121.tar.bz2
Minor factoring, naming and formatting cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/LoopDependenceAnalysis.cpp53
1 files changed, 29 insertions, 24 deletions
diff --git a/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp
index 421e4e1..97c8514 100644
--- a/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/lib/Analysis/LoopDependenceAnalysis.cpp
@@ -50,9 +50,9 @@ static inline bool IsMemRefInstr(const Value *V) {
static void GetMemRefInstrs(const Loop *L,
SmallVectorImpl<Instruction*> &Memrefs) {
for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
- b != be; ++b)
+ b != be; ++b)
for (BasicBlock::iterator i = (*b)->begin(), ie = (*b)->end();
- i != ie; ++i)
+ i != ie; ++i)
if (IsMemRefInstr(i))
Memrefs.push_back(i);
}
@@ -71,6 +71,15 @@ static Value *GetPointerOperand(Value *I) {
return 0;
}
+static AliasAnalysis::AliasResult UnderlyingObjectsAlias(AliasAnalysis *AA,
+ const Value *A,
+ const Value *B) {
+ const Value *aObj = A->getUnderlyingObject();
+ const Value *bObj = B->getUnderlyingObject();
+ return AA->alias(aObj, AA->getTypeStoreSize(aObj->getType()),
+ bObj, AA->getTypeStoreSize(bObj->getType()));
+}
+
//===----------------------------------------------------------------------===//
// Dependence Testing
//===----------------------------------------------------------------------===//
@@ -83,19 +92,19 @@ bool LoopDependenceAnalysis::isDependencePair(const Value *A,
cast<const Instruction>(B)->mayWriteToMemory());
}
-bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *X,
- Value *Y,
+bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *A,
+ Value *B,
DependencePair *&P) {
void *insertPos = 0;
FoldingSetNodeID id;
- id.AddPointer(X);
- id.AddPointer(Y);
+ id.AddPointer(A);
+ id.AddPointer(B);
P = Pairs.FindNodeOrInsertPos(id, insertPos);
if (P) return true;
P = PairAllocator.Allocate<DependencePair>();
- new (P) DependencePair(id, X, Y);
+ new (P) DependencePair(id, A, B);
Pairs.InsertNode(P, insertPos);
return false;
}
@@ -114,28 +123,24 @@ void LoopDependenceAnalysis::analysePair(DependencePair *P) const {
return;
}
- Value *aptr = GetPointerOperand(P->A);
- Value *bptr = GetPointerOperand(P->B);
- const Value *aobj = aptr->getUnderlyingObject();
- const Value *bobj = bptr->getUnderlyingObject();
- AliasAnalysis::AliasResult alias = AA->alias(
- aobj, AA->getTypeStoreSize(aobj->getType()),
- bobj, AA->getTypeStoreSize(bobj->getType()));
+ Value *aPtr = GetPointerOperand(P->A);
+ Value *bPtr = GetPointerOperand(P->B);
- // We can not analyse objects if we do not know about their aliasing.
- if (alias == AliasAnalysis::MayAlias) {
+ switch (UnderlyingObjectsAlias(AA, aPtr, bPtr)) {
+ case AliasAnalysis::MayAlias:
+ // We can not analyse objects if we do not know about their aliasing.
DEBUG(errs() << "---> [?] may alias\n");
return;
- }
- // If the objects noalias, they are distinct, accesses are independent.
- if (alias == AliasAnalysis::NoAlias) {
+ case AliasAnalysis::NoAlias:
+ // If the objects noalias, they are distinct, accesses are independent.
DEBUG(errs() << "---> [I] no alias\n");
P->Result = Independent;
return;
- }
- // TODO: the underlying objects MustAlias, test for dependence
+ case AliasAnalysis::MustAlias:
+ break; // The underlying objects alias, test accesses for dependence.
+ }
DEBUG(errs() << "---> [?] cannot analyse\n");
return;
@@ -187,14 +192,14 @@ static void PrintLoopInfo(raw_ostream &OS,
OS << " Load/store instructions: " << memrefs.size() << "\n";
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
- end = memrefs.end(); x != end; ++x)
+ end = memrefs.end(); x != end; ++x)
OS << "\t" << (x - memrefs.begin()) << ": " << **x << "\n";
OS << " Pairwise dependence results:\n";
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
- end = memrefs.end(); x != end; ++x)
+ end = memrefs.end(); x != end; ++x)
for (SmallVector<Instruction*, 8>::const_iterator y = x + 1;
- y != end; ++y)
+ y != end; ++y)
if (LDA->isDependencePair(*x, *y))
OS << "\t" << (x - memrefs.begin()) << "," << (y - memrefs.begin())
<< ": " << (LDA->depends(*x, *y) ? "dependent" : "independent")