llvm::UnrollLoop

Unroll loop L by the factor and policies in ULO.

Synopsis

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);

Description

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.

Return Value

Whether the loop was unmodified, partially unrolled, or fully unrolled.

Parameters

NameDescription
LLoop to unroll.
ULOUnrolling options including count and runtime behavior.
LILoopInfo to keep consistent with the transformed CFG.
SEOptional ScalarEvolution analysis to preserve and use.
DTDominator tree required for the transformation.
ACOptional assumption cache used by simplifications.
TTIOptional target transform info for cost-aware decisions.
OREOptional remark emitter for optimization diagnostics.
PreserveLCSSAWhether to preserve LCSSA form after unrolling.
RemainderLoopIf non-null, receives the remainder loop when one is created and the loop is not fully unrolled.
AAOptional alias analysis used by post-unroll simplifications.