summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorAndreas Bolka <a@bolka.at>2009-06-28 00:35:22 +0000
committerAndreas Bolka <a@bolka.at>2009-06-28 00:35:22 +0000
commit9d09e20142f6767eadcfb27318f6850c1d371c3e (patch)
tree0026ca9bd8b91b159e4d8a0946d674d644ade589 /llvm/lib/Analysis/LoopDependenceAnalysis.cpp
parent9fee7f86ad77ffc50c0653b84daa17ddd0328061 (diff)
downloadbcm5719-llvm-9d09e20142f6767eadcfb27318f6850c1d371c3e.tar.gz
bcm5719-llvm-9d09e20142f6767eadcfb27318f6850c1d371c3e.zip
Print pairwise dependence results, add testcases.
llvm-svn: 74402
Diffstat (limited to 'llvm/lib/Analysis/LoopDependenceAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopDependenceAnalysis.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp b/llvm/lib/Analysis/LoopDependenceAnalysis.cpp
index b23459e81ac..4912bf27591 100644
--- a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopDependenceAnalysis.cpp
@@ -40,6 +40,16 @@ static inline bool isMemRefInstr(const Value *I) {
return isa<LoadInst>(I) || isa<StoreInst>(I);
}
+static void getMemRefInstrs(
+ const Loop *L, SmallVectorImpl<Instruction*> &memrefs) {
+ for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
+ b != be; ++b)
+ for (BasicBlock::iterator i = (*b)->begin(), ie = (*b)->end();
+ i != ie; ++i)
+ if (isMemRefInstr(i))
+ memrefs.push_back(i);
+}
+
//===----------------------------------------------------------------------===//
// Dependence Testing
//===----------------------------------------------------------------------===//
@@ -71,16 +81,30 @@ void LoopDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
}
static void PrintLoopInfo(
- raw_ostream &OS, const LoopDependenceAnalysis *LDA, const Loop *L) {
+ raw_ostream &OS, LoopDependenceAnalysis *LDA, const Loop *L) {
if (!L->empty()) return; // ignore non-innermost loops
OS << "Loop at depth " << L->getLoopDepth() << ", header block: ";
WriteAsOperand(OS, L->getHeader(), false);
OS << "\n";
+
+ SmallVector<Instruction*, 8> memrefs;
+ getMemRefInstrs(L, memrefs);
+ OS << " Load/store instructions: " << memrefs.size() << "\n";
+ OS << " Pairwise dependence results:\n";
+ for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
+ end = memrefs.end(); x != end; ++x)
+ for (SmallVector<Instruction*, 8>::const_iterator y = x + 1;
+ y != end; ++y)
+ if (LDA->isDependencePair(*x, *y))
+ OS << "\t" << (x - memrefs.begin()) << "," << (y - memrefs.begin())
+ << ": " << (LDA->depends(*x, *y) ? "dependent" : "independent")
+ << "\n";
}
void LoopDependenceAnalysis::print(raw_ostream &OS, const Module*) const {
- PrintLoopInfo(OS, this, this->L);
+ // TODO: doc why const_cast is safe
+ PrintLoopInfo(OS, const_cast<LoopDependenceAnalysis*>(this), this->L);
}
void LoopDependenceAnalysis::print(std::ostream &OS, const Module *M) const {
OpenPOWER on IntegriCloud