LLVM  6.0.0svn
UnrollLoop.h
Go to the documentation of this file.
1 //===- llvm/Transforms/Utils/UnrollLoop.h - Unrolling utilities -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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
12 // unrolling.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
17 #define LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
18 
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/StringRef.h"
22 
23 namespace llvm {
24 
25 class AssumptionCache;
26 class BasicBlock;
27 class DominatorTree;
28 class Loop;
29 class LoopInfo;
30 class MDNode;
31 class OptimizationRemarkEmitter;
32 class ScalarEvolution;
33 
35 
36 const Loop* addClonedBlockToLoopInfo(BasicBlock *OriginalBB,
37  BasicBlock *ClonedBB, LoopInfo *LI,
38  NewLoopsMap &NewLoops);
39 
40 /// Represents the result of a \c UnrollLoop invocation.
41 enum class LoopUnrollResult {
42  /// The loop was not modified.
43  Unmodified,
44 
45  /// The loop was partially unrolled -- we still have a loop, but with a
46  /// smaller trip count. We may also have emitted epilogue loop if the loop
47  /// had a non-constant trip count.
49 
50  /// The loop was fully unrolled into straight-line code. We no longer have
51  /// any back-edges.
53 };
54 
55 LoopUnrollResult UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
56  bool Force, bool AllowRuntime,
57  bool AllowExpensiveTripCount, bool PreserveCondBr,
58  bool PreserveOnlyFirst, unsigned TripMultiple,
59  unsigned PeelCount, bool UnrollRemainder,
60  LoopInfo *LI, ScalarEvolution *SE,
62  OptimizationRemarkEmitter *ORE, bool PreserveLCSSA);
63 
64 bool UnrollRuntimeLoopRemainder(Loop *L, unsigned Count,
65  bool AllowExpensiveTripCount,
66  bool UseEpilogRemainder, bool UnrollRemainder,
67  LoopInfo *LI,
69  AssumptionCache *AC,
70  bool PreserveLCSSA);
71 
72 void computePeelCount(Loop *L, unsigned LoopSize,
74  unsigned &TripCount);
75 
76 bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE,
77  DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA);
78 
80 
81 } // end namespace llvm
82 
83 #endif // LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
The main scalar evolution driver.
A cache of .assume calls within a function.
Metadata node.
Definition: Metadata.h:862
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:140
The loop was fully unrolled into straight-line code.
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA)
Peel off the first PeelCount iterations of loop L.
void computePeelCount(Loop *L, unsigned LoopSize, TargetTransformInfo::UnrollingPreferences &UP, unsigned &TripCount)
The loop was partially unrolled – we still have a loop, but with a smaller trip count.
bool UnrollRuntimeLoopRemainder(Loop *L, unsigned Count, bool AllowExpensiveTripCount, bool UseEpilogRemainder, bool UnrollRemainder, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA)
Insert code in the prolog/epilog code when unrolling a loop with a run-time trip-count.
const Loop * addClonedBlockToLoopInfo(BasicBlock *OriginalBB, BasicBlock *ClonedBB, LoopInfo *LI, NewLoopsMap &NewLoops)
Adds ClonedBB to LoopInfo, creates a new loop for ClonedBB if necessary and adds a mapping from the o...
Definition: LoopUnroll.cpp:203
MDNode * GetUnrollMetadata(MDNode *LoopID, StringRef Name)
Given an llvm.loop loop id metadata node, returns the loop hint metadata node with the given name (fo...
Definition: LoopUnroll.cpp:894
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:439
Parameters that control the generic loop unrolling transformation.
The loop was not modified.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
This pass exposes codegen information to IR-level passes.
LoopUnrollResult UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool Force, bool AllowRuntime, bool AllowExpensiveTripCount, bool PreserveCondBr, bool PreserveOnlyFirst, unsigned TripMultiple, unsigned PeelCount, bool UnrollRemainder, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, OptimizationRemarkEmitter *ORE, bool PreserveLCSSA)
Unroll the given loop by Count.
Definition: LoopUnroll.cpp:307
The optimization diagnostic interface.
LoopUnrollResult
Represents the result of a UnrollLoop invocation.
Definition: UnrollLoop.h:41