From 9244a6e1852628e6dc3e64a44e20ad7ea5494c67 Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Mon, 7 Mar 2016 18:35:42 +0000 Subject: [PATCH] [LoopDataPrefetch] If prefetch distance is not set, skip pass This lets select sub-targets enable this pass. The patch implements the idea from the recent llvm-dev thread: http://thread.gmane.org/gmane.comp.compilers.llvm.devel/94925 The goal is to enable the LoopDataPrefetch pass for the Cyclone sub-target only within Aarch64. Positive and negative tests will be included in an upcoming patch that enables selective prefetching of large-strided accesses on Cyclone. llvm-svn: 262844 --- lib/Transforms/Scalar/LoopDataPrefetch.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Scalar/LoopDataPrefetch.cpp b/lib/Transforms/Scalar/LoopDataPrefetch.cpp index 0edceec8e13..5d0a5906509 100644 --- a/lib/Transforms/Scalar/LoopDataPrefetch.cpp +++ b/lib/Transforms/Scalar/LoopDataPrefetch.cpp @@ -99,9 +99,12 @@ bool LoopDataPrefetch::runOnFunction(Function &F) { AC = &getAnalysis().getAssumptionCache(F); TTI = &getAnalysis().getTTI(F); + // If PrefetchDistance is not set, don't run the pass. This gives an + // opportunity for targets to run this pass for selected subtargets only + // (whose TTI sets PrefetchDistance). + if (TTI->getPrefetchDistance() == 0) + return false; assert(TTI->getCacheLineSize() && "Cache line size is not set for target"); - assert(TTI->getPrefetchDistance() && - "Prefetch distance is not set for target"); bool MadeChange = false;