1 //===- llvm/Transforms/Utils/UnrollLoop.h - Unrolling utilities -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines some loop unrolling utilities. It does not define any
11 // actual pass or policy, but provides a single function to perform loop
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
17 #define LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
19 // Needed because we can't forward-declare the nested struct
20 // TargetTransformInfo::UnrollingPreferences
21 #include "llvm/Analysis/TargetTransformInfo.h"
26 class AssumptionCache;
33 class OptimizationRemarkEmitter;
34 class ScalarEvolution;
36 typedef SmallDenseMap<const Loop *, Loop *, 4> NewLoopsMap;
38 const Loop* addClonedBlockToLoopInfo(BasicBlock *OriginalBB,
39 BasicBlock *ClonedBB, LoopInfo *LI,
40 NewLoopsMap &NewLoops);
42 bool UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool Force,
43 bool AllowRuntime, bool AllowExpensiveTripCount,
44 bool PreserveCondBr, bool PreserveOnlyFirst,
45 unsigned TripMultiple, unsigned PeelCount, LoopInfo *LI,
46 ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC,
47 OptimizationRemarkEmitter *ORE, bool PreserveLCSSA);
49 bool UnrollRuntimeLoopRemainder(Loop *L, unsigned Count,
50 bool AllowExpensiveTripCount,
51 bool UseEpilogRemainder, LoopInfo *LI,
52 ScalarEvolution *SE, DominatorTree *DT,
55 void computePeelCount(Loop *L, unsigned LoopSize,
56 TargetTransformInfo::UnrollingPreferences &UP);
58 bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE,
59 DominatorTree *DT, bool PreserveLCSSA);
61 MDNode *GetUnrollMetadata(MDNode *LoopID, StringRef Name);