diff --git a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp index dde7de406c585e47699a02f179cd7ff2d21d1763..a8ff70d9fd64bdd215334a9f952727414e22ad51 100644 --- a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp @@ -105,6 +105,11 @@ static cl::opt cl::desc("Least loop depth to insert prefetch"), cl::Hidden, cl::init(1)); +static cl::opt + EnableCrcHashPrefetch("enable-crc-hash-prefetch", cl::Hidden, + cl::init(false), + cl::desc("Enable crc hash load prefetch")); + STATISTIC(NumPrefetches, "Number of prefetches inserted"); STATISTIC(NumIndPrefetches, "Number of indirect prefetches inserted"); STATISTIC(NumOuterLoopPrefetches, "Number of outer loop prefetches inserted"); @@ -551,7 +556,7 @@ bool LoopDataPrefetch::insertPrefetcherForIndirectLoad( Module *M = TargetIndirectLoad->getModule(); Type *I32Ty = Type::getInt32Ty(TargetIndirectLoad->getParent()->getContext()); - if (RandomAccessPrefetchOnly) { + if (RandomAccessPrefetchOnly || EnableCrcHashPrefetch) { bool isRandomAccess = false; for (auto *I : DependentInsts) { if (isCrcHashDataAccess(I, TargetIndirectLoad)) { @@ -813,7 +818,7 @@ bool LoopDataPrefetch::findCandidateMemoryLoads( break; } case Instruction::Call: { - if (PrefetchInOuterLoop || RandomAccessPrefetchOnly) { + if (PrefetchInOuterLoop || RandomAccessPrefetchOnly || EnableCrcHashPrefetch) { if (OperandInst->mayReadOrWriteMemory()) return false; CallInst *Call = dyn_cast(OperandInst); @@ -1538,7 +1543,7 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) { bool IsInnerMost = true; // Prefetch outer loop if needed. if (!L->isInnermost()) { - if (OuterLoopPrefetch) + if (OuterLoopPrefetch || EnableCrcHashPrefetch) IsInnerMost = false; else return MadeChange; @@ -1666,7 +1671,7 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) { } } } - if (!DupPref && !DisableDirectLoadPrefetch) + if (!DupPref && !(DisableDirectLoadPrefetch || EnableCrcHashPrefetch)) Prefetches.push_back(Prefetch(LSCEVAddRec, MemI)); } } @@ -1727,7 +1732,7 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) { MadeChange = true; } - if (!IndirectLoadPrefetch) + if (!IndirectLoadPrefetch && !EnableCrcHashPrefetch) return MadeChange; // List of valid phi nodes that indirect loads can depend on. @@ -1758,7 +1763,7 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) { return MadeChange; } - if (!RandomAccessPrefetchOnly && !PrefetchInOuterLoop && + if (!EnableCrcHashPrefetch && !RandomAccessPrefetchOnly && !PrefetchInOuterLoop && !canDoIndirectPrefetch(L)) { cleanLoopIterationNumber(NumIterations); return MadeChange;