llvm::LoopRotation

Convert a loop into a loop with bottom test.

Synopsis

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

bool
LoopRotation(
    Loop* L,
    LoopInfo* LI,
    TargetTransformInfo const* TTI,
    AssumptionCache* AC,
    DominatorTree* DT,
    ScalarEvolution* SE,
    MemorySSAUpdater* MSSAU,
    SimplifyQuery const& SQ,
    bool RotationOnly,
    unsigned int Threshold,
    bool IsUtilMode,
    bool PrepareForLTO = false,
    bool CheckExitCount = false);

Description

It may perform loop latch simplification as well if the flag RotationOnly is false. The flag Threshold represents the size threshold of the loop header. If the loop header's size exceeds the threshold, the loop rotation will give up. The flag IsUtilMode controls the heuristic used in the LoopRotation. If it is true, the profitability heuristic will be ignored.

Return Value

True if the loop was modified.

Parameters

NameDescription
LLoop to rotate.
LILoopInfo to keep consistent with the transformed CFG.
TTITarget transform info used for header size metrics.
ACAssumption cache used when collecting ephemeral values.
DTDominator tree to update.
SEScalarEvolution analysis to invalidate and optionally consult.
MSSAUMemorySSA updater, or nullptr.
SQSimplify query used during latch simplification.
RotationOnlyIf true, only rotate; if false, also simplify the latch.
ThresholdMaximum allowed size of the loop header; rotation is skipped when the header exceeds this threshold.
IsUtilModeIf true, ignore the profitability heuristic.
PrepareForLTOIf true, avoid rotating loops with inlining candidates that may be handled during LTO.
CheckExitCountIf true, consider ScalarEvolution exit-count info when deciding whether rotating an already-exiting latch is profitable.