Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
LoopDataPrefetch.cpp
Go to the documentation of this file.
1//===-------- LoopDataPrefetch.cpp - Loop Data Prefetching Pass -----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements a Loop Data Prefetching Pass.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/Transforms/Scalar/LoopDataPrefetch.h"
14#include "llvm/InitializePasses.h"
15
16#include "llvm/ADT/DepthFirstIterator.h"
17#include "llvm/ADT/Statistic.h"
18#include "llvm/Analysis/AssumptionCache.h"
19#include "llvm/Analysis/CodeMetrics.h"
20#include "llvm/Analysis/LoopInfo.h"
21#include "llvm/Analysis/OptimizationRemarkEmitter.h"
22#include "llvm/Analysis/ScalarEvolution.h"
23#include "llvm/Analysis/ScalarEvolutionExpressions.h"
24#include "llvm/Analysis/TargetTransformInfo.h"
25#include "llvm/IR/Dominators.h"
26#include "llvm/IR/Function.h"
27#include "llvm/Support/CommandLine.h"
28#include "llvm/Support/Debug.h"
29#include "llvm/Transforms/Scalar.h"
30#include "llvm/Transforms/Utils.h"
31#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
32
33#define DEBUG_TYPE "loop-data-prefetch"
34
35using namespacellvm;
36
37// By default, we limit this to creating 16 PHIs (which is a little over half
38// of the allocatable register set).
39staticcl::opt<bool>
40PrefetchWrites("loop-prefetch-writes",cl::Hidden,cl::init(false),
41cl::desc("Prefetch write addresses"));
42
43staticcl::opt<unsigned>
44PrefetchDistance("prefetch-distance",
45cl::desc("Number of instructions to prefetch ahead"),
46cl::Hidden);
47
48staticcl::opt<unsigned>
49MinPrefetchStride("min-prefetch-stride",
50cl::desc("Min stride to add prefetches"),cl::Hidden);
51
52staticcl::opt<unsigned>MaxPrefetchIterationsAhead(
53"max-prefetch-iters-ahead",
54cl::desc("Max number of iterations to prefetch ahead"),cl::Hidden);
55
56STATISTIC(NumPrefetches,"Number of prefetches inserted");
57
58namespace{
59
60/// Loop prefetch implementation class.
61classLoopDataPrefetch {
62public:
63 LoopDataPrefetch(AssumptionCache *AC,DominatorTree *DT,LoopInfo *LI,
64ScalarEvolution *SE,constTargetTransformInfo *TTI,
65OptimizationRemarkEmitter *ORE)
66 : AC(AC), DT(DT), LI(LI), SE(SE),TTI(TTI), ORE(ORE) {}
67
68boolrun();
69
70private:
71bool runOnLoop(Loop *L);
72
73 /// Check if the stride of the accesses is large enough to
74 /// warrant a prefetch.
75bool isStrideLargeEnough(constSCEVAddRecExpr *AR,unsigned TargetMinStride);
76
77unsigned getMinPrefetchStride(unsigned NumMemAccesses,
78unsigned NumStridedMemAccesses,
79unsigned NumPrefetches,
80bool HasCall) {
81if (MinPrefetchStride.getNumOccurrences() > 0)
82returnMinPrefetchStride;
83returnTTI->getMinPrefetchStride(NumMemAccesses, NumStridedMemAccesses,
84 NumPrefetches, HasCall);
85 }
86
87unsigned getPrefetchDistance() {
88if (PrefetchDistance.getNumOccurrences() > 0)
89returnPrefetchDistance;
90returnTTI->getPrefetchDistance();
91 }
92
93unsigned getMaxPrefetchIterationsAhead() {
94if (MaxPrefetchIterationsAhead.getNumOccurrences() > 0)
95returnMaxPrefetchIterationsAhead;
96returnTTI->getMaxPrefetchIterationsAhead();
97 }
98
99bool doPrefetchWrites() {
100if (PrefetchWrites.getNumOccurrences() > 0)
101returnPrefetchWrites;
102returnTTI->enableWritePrefetching();
103 }
104
105AssumptionCache *AC;
106DominatorTree *DT;
107LoopInfo *LI;
108ScalarEvolution *SE;
109constTargetTransformInfo *TTI;
110OptimizationRemarkEmitter *ORE;
111};
112
113/// Legacy class for inserting loop data prefetches.
114classLoopDataPrefetchLegacyPass :publicFunctionPass {
115public:
116staticcharID;// Pass ID, replacement for typeid
117 LoopDataPrefetchLegacyPass() :FunctionPass(ID) {
118initializeLoopDataPrefetchLegacyPassPass(*PassRegistry::getPassRegistry());
119 }
120
121voidgetAnalysisUsage(AnalysisUsage &AU) const override{
122 AU.addRequired<AssumptionCacheTracker>();
123 AU.addRequired<DominatorTreeWrapperPass>();
124 AU.addPreserved<DominatorTreeWrapperPass>();
125 AU.addRequired<LoopInfoWrapperPass>();
126 AU.addPreserved<LoopInfoWrapperPass>();
127 AU.addRequiredID(LoopSimplifyID);
128 AU.addPreservedID(LoopSimplifyID);
129 AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
130 AU.addRequired<ScalarEvolutionWrapperPass>();
131 AU.addPreserved<ScalarEvolutionWrapperPass>();
132 AU.addRequired<TargetTransformInfoWrapperPass>();
133 }
134
135boolrunOnFunction(Function &F)override;
136 };
137}
138
139char LoopDataPrefetchLegacyPass::ID = 0;
140INITIALIZE_PASS_BEGIN(LoopDataPrefetchLegacyPass,"loop-data-prefetch",
141"Loop Data Prefetch",false,false)
142INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
143INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
144INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
145INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
146INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)
147INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
148INITIALIZE_PASS_END(LoopDataPrefetchLegacyPass, "loop-data-prefetch",
149 "Loop DataPrefetch",false,false)
150
151FunctionPass *llvm::createLoopDataPrefetchPass() {
152returnnew LoopDataPrefetchLegacyPass();
153}
154
155bool LoopDataPrefetch::isStrideLargeEnough(constSCEVAddRecExpr *AR,
156unsigned TargetMinStride) {
157// No need to check if any stride goes.
158if (TargetMinStride <= 1)
159returntrue;
160
161constauto *ConstStride = dyn_cast<SCEVConstant>(AR->getStepRecurrence(*SE));
162// If MinStride is set, don't prefetch unless we can ensure that stride is
163// larger.
164if (!ConstStride)
165returnfalse;
166
167unsigned AbsStride = std::abs(ConstStride->getAPInt().getSExtValue());
168return TargetMinStride <= AbsStride;
169}
170
171PreservedAnalysesLoopDataPrefetchPass::run(Function &F,
172FunctionAnalysisManager &AM) {
173DominatorTree *DT = &AM.getResult<DominatorTreeAnalysis>(F);
174LoopInfo *LI = &AM.getResult<LoopAnalysis>(F);
175ScalarEvolution *SE = &AM.getResult<ScalarEvolutionAnalysis>(F);
176AssumptionCache *AC = &AM.getResult<AssumptionAnalysis>(F);
177OptimizationRemarkEmitter *ORE =
178 &AM.getResult<OptimizationRemarkEmitterAnalysis>(F);
179constTargetTransformInfo *TTI = &AM.getResult<TargetIRAnalysis>(F);
180
181 LoopDataPrefetch LDP(AC, DT, LI, SE,TTI, ORE);
182bool Changed = LDP.run();
183
184if (Changed) {
185PreservedAnalyses PA;
186 PA.preserve<DominatorTreeAnalysis>();
187 PA.preserve<LoopAnalysis>();
188return PA;
189 }
190
191returnPreservedAnalyses::all();
192}
193
194bool LoopDataPrefetchLegacyPass::runOnFunction(Function &F) {
195if (skipFunction(F))
196returnfalse;
197
198DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
199LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
200ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
201AssumptionCache *AC =
202 &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
203OptimizationRemarkEmitter *ORE =
204 &getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
205constTargetTransformInfo *TTI =
206 &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
207
208 LoopDataPrefetch LDP(AC, DT, LI, SE,TTI, ORE);
209return LDP.run();
210}
211
212bool LoopDataPrefetch::run() {
213// If PrefetchDistance is not set, don't run the pass. This gives an
214// opportunity for targets to run this pass for selected subtargets only
215// (whose TTI sets PrefetchDistance and CacheLineSize).
216if (getPrefetchDistance() == 0 ||TTI->getCacheLineSize() == 0) {
217LLVM_DEBUG(dbgs() <<"Please set both PrefetchDistance and CacheLineSize "
218"for loop data prefetch.\n");
219returnfalse;
220 }
221
222bool MadeChange =false;
223
224for (Loop *I : *LI)
225for (Loop *L :depth_first(I))
226 MadeChange |= runOnLoop(L);
227
228return MadeChange;
229}
230
231/// A record for a potential prefetch made during the initial scan of the
232/// loop. This is used to let a single prefetch target multiple memory accesses.
233structPrefetch {
234 /// The address formula for this prefetch as returned by ScalarEvolution.
235constSCEVAddRecExpr *LSCEVAddRec;
236 /// The point of insertion for the prefetch instruction.
237Instruction *InsertPt =nullptr;
238 /// True if targeting a write memory access.
239boolWrites =false;
240 /// The (first seen) prefetched instruction.
241Instruction *MemI =nullptr;
242
243 /// Constructor to create a new Prefetch for \p I.
244Prefetch(constSCEVAddRecExpr *L,Instruction *I) : LSCEVAddRec(L) {
245 addInstruction(I);
246 };
247
248 /// Add the instruction \param I to this prefetch. If it's not the first
249 /// one, 'InsertPt' and 'Writes' will be updated as required.
250 /// \param PtrDiff the known constant address difference to the first added
251 /// instruction.
252voidaddInstruction(Instruction *I,DominatorTree *DT =nullptr,
253 int64_t PtrDiff = 0) {
254if (!InsertPt) {
255 MemI =I;
256 InsertPt =I;
257Writes = isa<StoreInst>(I);
258 }else {
259BasicBlock *PrefBB = InsertPt->getParent();
260BasicBlock *InsBB =I->getParent();
261if (PrefBB != InsBB) {
262BasicBlock *DomBB = DT->findNearestCommonDominator(PrefBB, InsBB);
263if (DomBB != PrefBB)
264 InsertPt = DomBB->getTerminator();
265 }
266
267if (isa<StoreInst>(I) && PtrDiff == 0)
268Writes =true;
269 }
270 }
271};
272
273bool LoopDataPrefetch::runOnLoop(Loop *L) {
274bool MadeChange =false;
275
276// Only prefetch in the inner-most loop
277if (!L->isInnermost())
278return MadeChange;
279
280SmallPtrSet<const Value *, 32> EphValues;
281CodeMetrics::collectEphemeralValues(L, AC, EphValues);
282
283// Calculate the number of iterations ahead to prefetch
284CodeMetricsMetrics;
285bool HasCall =false;
286for (constauto BB :L->blocks()) {
287// If the loop already has prefetches, then assume that the user knows
288// what they are doing and don't add any more.
289for (auto &I : *BB) {
290if (isa<CallInst>(&I) || isa<InvokeInst>(&I)) {
291if (constFunction *F = cast<CallBase>(I).getCalledFunction()) {
292if (F->getIntrinsicID() == Intrinsic::prefetch)
293return MadeChange;
294if (TTI->isLoweredToCall(F))
295 HasCall =true;
296 }else {// indirect call.
297 HasCall =true;
298 }
299 }
300 }
301Metrics.analyzeBasicBlock(BB, *TTI, EphValues);
302 }
303
304if (!Metrics.NumInsts.isValid())
305return MadeChange;
306
307unsigned LoopSize = *Metrics.NumInsts.getValue();
308if (!LoopSize)
309 LoopSize = 1;
310
311unsigned ItersAhead = getPrefetchDistance() / LoopSize;
312if (!ItersAhead)
313 ItersAhead = 1;
314
315if (ItersAhead > getMaxPrefetchIterationsAhead())
316return MadeChange;
317
318unsigned ConstantMaxTripCount = SE->getSmallConstantMaxTripCount(L);
319if (ConstantMaxTripCount && ConstantMaxTripCount < ItersAhead + 1)
320return MadeChange;
321
322unsigned NumMemAccesses = 0;
323unsigned NumStridedMemAccesses = 0;
324SmallVector<Prefetch, 16> Prefetches;
325for (constauto BB :L->blocks())
326for (auto &I : *BB) {
327Value *PtrValue;
328Instruction *MemI;
329
330if (LoadInst *LMemI = dyn_cast<LoadInst>(&I)) {
331 MemI = LMemI;
332 PtrValue = LMemI->getPointerOperand();
333 }elseif (StoreInst *SMemI = dyn_cast<StoreInst>(&I)) {
334if (!doPrefetchWrites())continue;
335 MemI = SMemI;
336 PtrValue = SMemI->getPointerOperand();
337 }elsecontinue;
338
339unsigned PtrAddrSpace = PtrValue->getType()->getPointerAddressSpace();
340if (!TTI->shouldPrefetchAddressSpace(PtrAddrSpace))
341continue;
342 NumMemAccesses++;
343if (L->isLoopInvariant(PtrValue))
344continue;
345
346constSCEV *LSCEV = SE->getSCEV(PtrValue);
347constSCEVAddRecExpr *LSCEVAddRec = dyn_cast<SCEVAddRecExpr>(LSCEV);
348if (!LSCEVAddRec)
349continue;
350 NumStridedMemAccesses++;
351
352// We don't want to double prefetch individual cache lines. If this
353// access is known to be within one cache line of some other one that
354// has already been prefetched, then don't prefetch this one as well.
355bool DupPref =false;
356for (auto &Pref : Prefetches) {
357constSCEV *PtrDiff = SE->getMinusSCEV(LSCEVAddRec, Pref.LSCEVAddRec);
358if (constSCEVConstant *ConstPtrDiff =
359 dyn_cast<SCEVConstant>(PtrDiff)) {
360 int64_tPD = std::abs(ConstPtrDiff->getValue()->getSExtValue());
361if (PD < (int64_t)TTI->getCacheLineSize()) {
362 Pref.addInstruction(MemI, DT, PD);
363 DupPref =true;
364break;
365 }
366 }
367 }
368if (!DupPref)
369 Prefetches.push_back(Prefetch(LSCEVAddRec, MemI));
370 }
371
372unsigned TargetMinStride =
373 getMinPrefetchStride(NumMemAccesses, NumStridedMemAccesses,
374 Prefetches.size(), HasCall);
375
376LLVM_DEBUG(dbgs() <<"Prefetching " << ItersAhead
377 <<" iterations ahead (loop size: " << LoopSize <<") in "
378 <<L->getHeader()->getParent()->getName() <<": " << *L);
379LLVM_DEBUG(dbgs() <<"Loop has: "
380 << NumMemAccesses <<" memory accesses, "
381 << NumStridedMemAccesses <<" strided memory accesses, "
382 << Prefetches.size() <<" potential prefetch(es), "
383 <<"a minimum stride of " << TargetMinStride <<", "
384 << (HasCall ?"calls" :"no calls") <<".\n");
385
386for (auto &P : Prefetches) {
387// Check if the stride of the accesses is large enough to warrant a
388// prefetch.
389if (!isStrideLargeEnough(P.LSCEVAddRec, TargetMinStride))
390continue;
391
392BasicBlock *BB =P.InsertPt->getParent();
393SCEVExpander SCEVE(*SE, BB->getDataLayout(),"prefaddr");
394constSCEV *NextLSCEV = SE->getAddExpr(P.LSCEVAddRec, SE->getMulExpr(
395 SE->getConstant(P.LSCEVAddRec->getType(), ItersAhead),
396P.LSCEVAddRec->getStepRecurrence(*SE)));
397if (!SCEVE.isSafeToExpand(NextLSCEV))
398continue;
399
400unsigned PtrAddrSpace = NextLSCEV->getType()->getPointerAddressSpace();
401Type *I8Ptr =PointerType::get(BB->getContext(), PtrAddrSpace);
402Value *PrefPtrValue = SCEVE.expandCodeFor(NextLSCEV, I8Ptr,P.InsertPt);
403
404IRBuilder<> Builder(P.InsertPt);
405Type *I32 =Type::getInt32Ty(BB->getContext());
406 Builder.CreateIntrinsic(Intrinsic::prefetch, PrefPtrValue->getType(),
407 {PrefPtrValue, ConstantInt::get(I32, P.Writes),
408 ConstantInt::get(I32, 3),
409 ConstantInt::get(I32, 1)});
410 ++NumPrefetches;
411LLVM_DEBUG(dbgs() <<" Access: "
412 << *P.MemI->getOperand(isa<LoadInst>(P.MemI) ? 0 : 1)
413 <<", SCEV: " << *P.LSCEVAddRec <<"\n");
414 ORE->emit([&]() {
415returnOptimizationRemark(DEBUG_TYPE,"Prefetched",P.MemI)
416 <<"prefetched memory access";
417 });
418
419 MadeChange =true;
420 }
421
422return MadeChange;
423}
AssumptionCache.h
CodeMetrics.h
CommandLine.h
Debug.h
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
DepthFirstIterator.h
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
Dominators.h
Writes
SmallVector< uint32_t, 0 > Writes
Definition:ELF_riscv.cpp:497
DEBUG_TYPE
#define DEBUG_TYPE
Definition:GenericCycleImpl.h:31
Function.h
InitializePasses.h
PrefetchWrites
static cl::opt< bool > PrefetchWrites("loop-prefetch-writes", cl::Hidden, cl::init(false), cl::desc("Prefetch write addresses"))
MinPrefetchStride
static cl::opt< unsigned > MinPrefetchStride("min-prefetch-stride", cl::desc("Min stride to add prefetches"), cl::Hidden)
PrefetchDistance
static cl::opt< unsigned > PrefetchDistance("prefetch-distance", cl::desc("Number of instructions to prefetch ahead"), cl::Hidden)
MaxPrefetchIterationsAhead
static cl::opt< unsigned > MaxPrefetchIterationsAhead("max-prefetch-iters-ahead", cl::desc("Max number of iterations to prefetch ahead"), cl::Hidden)
prefetch
loop data prefetch
Definition:LoopDataPrefetch.cpp:148
LoopDataPrefetch.h
This file provides the interface for LLVM's Loop Data Prefetching Pass.
LoopInfo.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
Metrics
Machine Trace Metrics
Definition:MachineTraceMetrics.cpp:63
getCalledFunction
static const Function * getCalledFunction(const Value *V)
Definition:MemoryBuiltins.cpp:159
OptimizationRemarkEmitter.h
P
#define P(N)
INITIALIZE_PASS_DEPENDENCY
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition:PassSupport.h:55
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:52
ScalarEvolutionExpander.h
ScalarEvolutionExpressions.h
ScalarEvolution.h
Scalar.h
data
static Split data
Definition:StaticDataSplitter.cpp:176
Statistic.h
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
STATISTIC
#define STATISTIC(VARNAME, DESC)
Definition:Statistic.h:166
TargetTransformInfo.h
This pass exposes codegen information to IR-level passes.
Utils.h
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition:PassManager.h:410
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::AnalysisUsage::addRequiredID
AnalysisUsage & addRequiredID(const void *ID)
Definition:Pass.cpp:270
llvm::AnalysisUsage::addPreservedID
AnalysisUsage & addPreservedID(const void *ID)
Definition:PassAnalysisSupport.h:88
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition:PassAnalysisSupport.h:75
llvm::AnalysisUsage::addPreserved
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Definition:PassAnalysisSupport.h:98
llvm::AssumptionAnalysis
A function analysis which provides an AssumptionCache.
Definition:AssumptionCache.h:173
llvm::AssumptionCacheTracker
An immutable pass that tracks lazily created AssumptionCache objects.
Definition:AssumptionCache.h:204
llvm::AssumptionCache
A cache of @llvm.assume calls within a function.
Definition:AssumptionCache.h:42
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BasicBlock::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
Definition:BasicBlock.cpp:296
llvm::BasicBlock::getContext
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition:BasicBlock.cpp:168
llvm::BasicBlock::getTerminator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition:BasicBlock.h:240
llvm::DominatorTreeAnalysis
Analysis pass which computes a DominatorTree.
Definition:Dominators.h:279
llvm::DominatorTreeWrapperPass
Legacy analysis pass which computes a DominatorTree.
Definition:Dominators.h:317
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition:Dominators.h:162
llvm::DominatorTree::findNearestCommonDominator
Instruction * findNearestCommonDominator(Instruction *I1, Instruction *I2) const
Find the nearest instruction I that dominates both I1 and I2, in the sense that a result produced bef...
Definition:Dominators.cpp:344
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition:Pass.h:310
llvm::FunctionPass::runOnFunction
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
llvm::Function
Definition:Function.h:63
llvm::IRBuilder
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition:IRBuilder.h:2705
llvm::Instruction
Definition:Instruction.h:68
llvm::LoadInst
An instruction for reading from memory.
Definition:Instructions.h:176
llvm::LoopAnalysis
Analysis pass that exposes the LoopInfo for a function.
Definition:LoopInfo.h:566
llvm::LoopDataPrefetchPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Definition:LoopDataPrefetch.cpp:171
llvm::LoopInfoWrapperPass
The legacy pass manager's analysis pass to compute loop information.
Definition:LoopInfo.h:593
llvm::LoopInfo
Definition:LoopInfo.h:407
llvm::Loop
Represents a single loop in the control flow graph.
Definition:LoopInfo.h:39
llvm::OptimizationRemarkEmitterAnalysis
Definition:OptimizationRemarkEmitter.h:164
llvm::OptimizationRemarkEmitterWrapperPass
OptimizationRemarkEmitter legacy analysis pass.
Definition:OptimizationRemarkEmitter.h:145
llvm::OptimizationRemarkEmitter
The optimization diagnostic interface.
Definition:OptimizationRemarkEmitter.h:32
llvm::OptimizationRemarkEmitter::emit
void emit(DiagnosticInfoOptimizationBase &OptDiag)
Output the remark via the diagnostic handler and to the optimization record file.
Definition:OptimizationRemarkEmitter.cpp:79
llvm::OptimizationRemark
Diagnostic information for applied optimization remarks.
Definition:DiagnosticInfo.h:762
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:PassRegistry.cpp:24
llvm::Pass::getAnalysisUsage
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition:Pass.cpp:98
llvm::PointerType::get
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition:Analysis.h:117
llvm::PreservedAnalyses::preserve
void preserve()
Mark an analysis as preserved.
Definition:Analysis.h:131
llvm::SCEVAddRecExpr
This node represents a polynomial recurrence on the trip count of the specified loop.
Definition:ScalarEvolutionExpressions.h:347
llvm::SCEVAddRecExpr::getStepRecurrence
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
Definition:ScalarEvolutionExpressions.h:365
llvm::SCEVConstant
This class represents a constant integer value.
Definition:ScalarEvolutionExpressions.h:60
llvm::SCEVExpander
This class uses information about analyze scalars to rewrite expressions in canonical form.
Definition:ScalarEvolutionExpander.h:63
llvm::SCEV
This class represents an analyzed expression in the program.
Definition:ScalarEvolution.h:71
llvm::SCEV::getType
Type * getType() const
Return the LLVM type of this SCEV expression.
Definition:ScalarEvolution.cpp:386
llvm::ScalarEvolutionAnalysis
Analysis pass that exposes the ScalarEvolution for a function.
Definition:ScalarEvolution.h:2320
llvm::ScalarEvolutionWrapperPass
Definition:ScalarEvolution.h:2352
llvm::ScalarEvolution
The main scalar evolution driver.
Definition:ScalarEvolution.h:447
llvm::ScalarEvolution::getConstant
const SCEV * getConstant(ConstantInt *V)
Definition:ScalarEvolution.cpp:473
llvm::ScalarEvolution::getSCEV
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
Definition:ScalarEvolution.cpp:4547
llvm::ScalarEvolution::getSmallConstantMaxTripCount
unsigned getSmallConstantMaxTripCount(const Loop *L, SmallVectorImpl< const SCEVPredicate * > *Predicates=nullptr)
Returns the upper bound of the loop trip count as a normal unsigned value.
Definition:ScalarEvolution.cpp:8253
llvm::ScalarEvolution::getMinusSCEV
const SCEV * getMinusSCEV(const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Return LHS-RHS.
Definition:ScalarEvolution.cpp:4655
llvm::ScalarEvolution::getMulExpr
const SCEV * getMulExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical multiply expression, or something simpler if possible.
Definition:ScalarEvolution.cpp:3106
llvm::ScalarEvolution::getAddExpr
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
Definition:ScalarEvolution.cpp:2526
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition:SmallPtrSet.h:519
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StoreInst
An instruction for storing to memory.
Definition:Instructions.h:292
llvm::TargetIRAnalysis
Analysis pass providing the TargetTransformInfo.
Definition:TargetTransformInfo.h:3194
llvm::TargetTransformInfoWrapperPass
Wrapper pass for TargetTransformInfo.
Definition:TargetTransformInfo.h:3250
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition:TargetTransformInfo.h:212
llvm::TargetTransformInfo::getPrefetchDistance
unsigned getPrefetchDistance() const
Definition:TargetTransformInfo.cpp:843
llvm::TargetTransformInfo::enableWritePrefetching
bool enableWritePrefetching() const
Definition:TargetTransformInfo.cpp:858
llvm::TargetTransformInfo::getMaxPrefetchIterationsAhead
unsigned getMaxPrefetchIterationsAhead() const
Definition:TargetTransformInfo.cpp:854
llvm::TargetTransformInfo::getMinPrefetchStride
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const
Some HW prefetchers can handle accesses up to a certain constant stride.
Definition:TargetTransformInfo.cpp:847
llvm::TargetTransformInfo::shouldPrefetchAddressSpace
bool shouldPrefetchAddressSpace(unsigned AS) const
Definition:TargetTransformInfo.cpp:862
llvm::TargetTransformInfo::getCacheLineSize
unsigned getCacheLineSize() const
Definition:TargetTransformInfo.cpp:823
llvm::TargetTransformInfo::isLoweredToCall
bool isLoweredToCall(const Function *F) const
Test whether calls to a function lower to actual program function calls.
Definition:TargetTransformInfo.cpp:352
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition:Value.h:255
llvm::cl::Option::getNumOccurrences
int getNumOccurrences() const
Definition:CommandLine.h:399
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::ilist_detail::node_parent_access::getParent
const ParentTy * getParent() const
Definition:ilist_node.h:32
unsigned
false
Definition:StackSlotColoring.cpp:193
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition:CallingConv.h:24
llvm::M68k::MemAddrModeKind::L
@ L
llvm::X86II::PD
@ PD
PD - Prefix code for packed double precision vector floating point operations performed in the SSE re...
Definition:X86BaseInfo.h:721
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm::dxil::PointerTypeAnalysis::run
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
Definition:PointerTypeAnalysis.cpp:191
llvm::wasm::ValType::I32
@ I32
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::LoopSimplifyID
char & LoopSimplifyID
Definition:LoopSimplify.cpp:784
llvm::initializeLoopDataPrefetchLegacyPassPass
void initializeLoopDataPrefetchLegacyPassPass(PassRegistry &)
llvm::createLoopDataPrefetchPass
FunctionPass * createLoopDataPrefetchPass()
Definition:LoopDataPrefetch.cpp:151
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::depth_first
iterator_range< df_iterator< T > > depth_first(const T &G)
Definition:DepthFirstIterator.h:233
Prefetch
A record for a potential prefetch made during the initial scan of the loop.
Definition:LoopDataPrefetch.cpp:233
Prefetch::addInstruction
void addInstruction(Instruction *I, DominatorTree *DT=nullptr, int64_t PtrDiff=0)
Add the instruction.
Definition:LoopDataPrefetch.cpp:252
Prefetch::LSCEVAddRec
const SCEVAddRecExpr * LSCEVAddRec
The address formula for this prefetch as returned by ScalarEvolution.
Definition:LoopDataPrefetch.cpp:235
Prefetch::Prefetch
Prefetch(const SCEVAddRecExpr *L, Instruction *I)
Constructor to create a new Prefetch for I.
Definition:LoopDataPrefetch.cpp:244
llvm::CodeMetrics
Utility to calculate the size and a few similar metrics for a set of basic blocks.
Definition:CodeMetrics.h:33
llvm::CodeMetrics::collectEphemeralValues
static void collectEphemeralValues(const Loop *L, AssumptionCache *AC, SmallPtrSetImpl< const Value * > &EphValues)
Collect a loop's ephemeral values (those used only by an assume or similar intrinsics in the loop).
Definition:CodeMetrics.cpp:71
llvm::cl::desc
Definition:CommandLine.h:409

Generated on Fri Jul 18 2025 15:56:59 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp