Unroll loop L by the factor and policies in ULO.
Declared in <llvm/Transforms/Utils/UnrollLoop.h>
LoopUnrollResult
UnrollLoop(
Loop* L,
UnrollLoopOptions ULO,
LoopInfo* LI,
ScalarEvolution* SE,
DominatorTree* DT,
AssumptionCache* AC,
llvm::TargetTransformInfo const* TTI,
OptimizationRemarkEmitter* ORE,
bool PreserveLCSSA,
Loop** RemainderLoop = nullptr,
AAResults* AA = nullptr);
The loop must be in LCSSA form. Unrolling can only fail when the loop's latch block is not terminated by a conditional branch instruction. However, if the trip count (and multiple) are not known, loop unrolling will mostly produce more code that is no faster.
If ULO.Runtime is true then UnrollLoop will try to insert a prologue or epilogue that ensures the latch has a trip multiple of ULO.Count. UnrollLoop will not runtime-unroll the loop if computing the run-time trip count will be expensive and ULO.AllowExpensiveTripCount is false.
The LoopInfo Analysis that is passed will be kept consistent. This utility preserves LoopInfo. It will also preserve ScalarEvolution and DominatorTree if they are non-null.
Whether the loop was unmodified, partially unrolled, or fully unrolled.
| Name | Description |
|---|---|
| L | Loop to unroll. |
| ULO | Unrolling options including count and runtime behavior. |
| LI | LoopInfo to keep consistent with the transformed CFG. |
| SE | Optional ScalarEvolution analysis to preserve and use. |
| DT | Dominator tree required for the transformation. |
| AC | Optional assumption cache used by simplifications. |
| TTI | Optional target transform info for cost-aware decisions. |
| ORE | Optional remark emitter for optimization diagnostics. |
| PreserveLCSSA | Whether to preserve LCSSA form after unrolling. |
| RemainderLoop | If non-null, receives the remainder loop when one is created and the loop is not fully unrolled. |
| AA | Optional alias analysis used by post-unroll simplifications. |