[LoopDataPrefetch] Add stats and debug output

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262998 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Adam Nemet 2016-03-09 05:33:21 +00:00
parent db96e9895d
commit 713ac2f65a

View File

@ -43,6 +43,8 @@ static cl::opt<bool>
PrefetchWrites("loop-prefetch-writes", cl::Hidden, cl::init(false),
cl::desc("Prefetch write addresses"));
STATISTIC(NumPrefetches, "Number of prefetches inserted");
namespace llvm {
void initializeLoopDataPrefetchPass(PassRegistry&);
}
@ -149,6 +151,10 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) {
if (!ItersAhead)
ItersAhead = 1;
DEBUG(dbgs() << "Prefetching " << ItersAhead
<< " iterations ahead (loop size: " << LoopSize << ") in "
<< L->getHeader()->getParent()->getName() << ": " << *L);
SmallVector<std::pair<Instruction *, const SCEVAddRecExpr *>, 16> PrefLoads;
for (Loop::block_iterator I = L->block_begin(), IE = L->block_end();
I != IE; ++I) {
@ -219,6 +225,9 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) {
{PrefPtrValue,
ConstantInt::get(I32, MemI->mayReadFromMemory() ? 0 : 1),
ConstantInt::get(I32, 3), ConstantInt::get(I32, 1)});
++NumPrefetches;
DEBUG(dbgs() << " Access: " << *PtrValue << ", SCEV: " << *LSCEV
<< "\n");
MadeChange = true;
}