llvm::UnrollRuntimeLoopRemainder

Insert a runtime prolog or epilog so L can be unrolled by Count.

Synopsis

Declared in <llvm/Transforms/Utils/UnrollLoop.h>

bool
UnrollRuntimeLoopRemainder(
    Loop* L,
    unsigned int Count,
    bool AllowExpensiveTripCount,
    bool UseEpilogRemainder,
    bool UnrollRemainder,
    bool ForgetAllSCEV,
    LoopInfo* LI,
    ScalarEvolution* SE,
    DominatorTree* DT,
    AssumptionCache* AC,
    TargetTransformInfo const* TTI,
    bool PreserveLCSSA,
    unsigned int SCEVExpansionBudget,
    bool RuntimeUnrollMultiExit,
    Loop** ResultLoop = nullptr,
    std::optional<unsigned int> OriginalTripCount = std::nullopt,
    BranchProbability OriginalLoopProb = BranchProbability::getUnknown());

Description

Ensures the latch trip count is a multiple of Count when the trip count is not known statically. May create and optionally unroll a remainder loop.

Return Value

True if the remainder transformation succeeded.

Parameters

NameDescription
LLoop to prepare for runtime unrolling.
CountUnroll factor that the remainder logic must satisfy.
AllowExpensiveTripCountAllow costly run-time trip-count computation.
UseEpilogRemainderPrefer an epilog remainder over a prolog.
UnrollRemainderUnroll the generated remainder loop when profitable.
ForgetAllSCEVForget all SCEV expressions for the loop after rewrite.
LILoopInfo to keep consistent.
SEScalarEvolution used to compute the trip count.
DTDominator tree to update.
ACAssumption cache used by subsequent simplifications.
TTITarget transform info for cost checks.
PreserveLCSSAWhether to preserve LCSSA form.
SCEVExpansionBudgetBudget for expanding the trip-count SCEV.
RuntimeUnrollMultiExitAllow runtime unrolling with multiple exits.
ResultLoopIf non-null, receives the remainder loop when created.
OriginalTripCountOptional original trip count used for probabilities.
OriginalLoopProbOptional original loop-latch branch probability.