Convert a loop into a loop with bottom test.
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);
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.
True if the loop was modified.
| Name | Description |
|---|---|
| L | Loop to rotate. |
| LI | LoopInfo to keep consistent with the transformed CFG. |
| TTI | Target transform info used for header size metrics. |
| AC | Assumption cache used when collecting ephemeral values. |
| DT | Dominator tree to update. |
| SE | ScalarEvolution analysis to invalidate and optionally consult. |
| MSSAU | MemorySSA updater, or nullptr. |
| SQ | Simplify query used during latch simplification. |
| RotationOnly | If true, only rotate; if false, also simplify the latch. |
| Threshold | Maximum allowed size of the loop header; rotation is skipped when the header exceeds this threshold. |
| IsUtilMode | If true, ignore the profitability heuristic. |
| PrepareForLTO | If true, avoid rotating loops with inlining candidates that may be handled during LTO. |
| CheckExitCount | If true, consider ScalarEvolution exit-count info when deciding whether rotating an already-exiting latch is profitable. |