LLVM 20.0.0git
Namespaces | Macros | Typedefs | Functions | Variables
LICM.cpp File Reference
#include "llvm/Transforms/Scalar/LICM.h"
#include "llvm/ADT/PriorityWorklist.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/GuardUtils.h"
#include "llvm/Analysis/LazyBlockFrequencyInfo.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Analysis/LoopNestAnalysis.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/MustExecute.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/PredIteratorCache.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/AssumeBundleBuilder.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"
#include <algorithm>
#include <utility>

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Macros

#define DEBUG_TYPE   "licm"
 

Typedefs

using PointersAndHasReadsOutsideSet = std::pair< SmallSetVector< Value *, 8 >, bool >
 

Functions

 STATISTIC (NumCreatedBlocks, "Number of blocks created")
 
 STATISTIC (NumClonedBranches, "Number of branches cloned")
 
 STATISTIC (NumSunk, "Number of instructions sunk out of loop")
 
 STATISTIC (NumHoisted, "Number of instructions hoisted out of loop")
 
 STATISTIC (NumMovedLoads, "Number of load insts hoisted or sunk")
 
 STATISTIC (NumMovedCalls, "Number of call insts hoisted or sunk")
 
 STATISTIC (NumPromotionCandidates, "Number of promotion candidates")
 
 STATISTIC (NumLoadPromoted, "Number of load-only promotions")
 
 STATISTIC (NumLoadStorePromoted, "Number of load and store promotions")
 
 STATISTIC (NumMinMaxHoisted, "Number of min/max expressions hoisted out of the loop")
 
 STATISTIC (NumGEPsHoisted, "Number of geps reassociated and hoisted out of the loop")
 
 STATISTIC (NumAddSubHoisted, "Number of add/subtract expressions reassociated " "and hoisted out of the loop")
 
 STATISTIC (NumFPAssociationsHoisted, "Number of invariant FP expressions " "reassociated and hoisted out of the loop")
 
 STATISTIC (NumIntAssociationsHoisted, "Number of invariant int expressions " "reassociated and hoisted out of the loop")
 
 STATISTIC (NumBOAssociationsHoisted, "Number of invariant BinaryOp expressions " "reassociated and hoisted out of the loop")
 
static bool inSubLoop (BasicBlock *BB, Loop *CurLoop, LoopInfo *LI)
 Little predicate that returns true if the specified basic block is in a subloop of the current one, not the current one itself.
 
static bool isNotUsedOrFoldableInLoop (const Instruction &I, const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo, TargetTransformInfo *TTI, bool &FoldableInLoop, bool LoopNestMode)
 Return true if the only users of this instruction are outside of the loop.
 
static void hoist (Instruction &I, const DominatorTree *DT, const Loop *CurLoop, BasicBlock *Dest, ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU, ScalarEvolution *SE, OptimizationRemarkEmitter *ORE)
 When an instruction is found to only use loop invariant operands that is safe to hoist, this instruction is called to do the dirty work.
 
static bool sink (Instruction &I, LoopInfo *LI, DominatorTree *DT, const Loop *CurLoop, ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU, OptimizationRemarkEmitter *ORE)
 When an instruction is found to only be used outside of the loop, this function moves it to the exit blocks and patches up SSA form as needed.
 
static bool isSafeToExecuteUnconditionally (Instruction &Inst, const DominatorTree *DT, const TargetLibraryInfo *TLI, const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo, OptimizationRemarkEmitter *ORE, const Instruction *CtxI, AssumptionCache *AC, bool AllowSpeculation)
 Only sink or hoist an instruction if it is not a trapping instruction, or if the instruction is known not to trap when moved to the preheader.
 
static bool pointerInvalidatedByLoop (MemorySSA *MSSA, MemoryUse *MU, Loop *CurLoop, Instruction &I, SinkAndHoistLICMFlags &Flags, bool InvariantGroup)
 
static bool pointerInvalidatedByBlock (BasicBlock &BB, MemorySSA &MSSA, MemoryUse &MU)
 
static bool hoistArithmetics (Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
 Aggregates various functions for hoisting computations out of loop.
 
static InstructioncloneInstructionInExitBlock (Instruction &I, BasicBlock &ExitBlock, PHINode &PN, const LoopInfo *LI, const LoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU)
 
static void eraseInstruction (Instruction &I, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU)
 
static void moveInstructionBefore (Instruction &I, BasicBlock::iterator Dest, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, ScalarEvolution *SE)
 
static void foreachMemoryAccess (MemorySSA *MSSA, Loop *L, function_ref< void(Instruction *)> Fn)
 
static SmallVector< PointersAndHasReadsOutsideSet, 0 > collectPromotionCandidates (MemorySSA *MSSA, AliasAnalysis *AA, Loop *L)
 
 INITIALIZE_PASS_BEGIN (LegacyLICMPass, "licm", "Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(LegacyLICMPass
 
static bool isLoadInvariantInLoop (LoadInst *LI, DominatorTree *DT, Loop *CurLoop)
 
static MemoryAccessgetClobberingMemoryAccess (MemorySSA &MSSA, BatchAAResults &BAA, SinkAndHoistLICMFlags &Flags, MemoryUseOrDef *MA)
 
static bool isTriviallyReplaceablePHI (const PHINode &PN, const Instruction &I)
 Returns true if a PHINode is a trivially replaceable with an Instruction.
 
static bool isFoldableInLoop (const Instruction &I, const Loop *CurLoop, const TargetTransformInfo *TTI)
 Return true if the instruction is foldable in the loop.
 
static InstructionsinkThroughTriviallyReplaceablePHI (PHINode *TPN, Instruction *I, LoopInfo *LI, SmallDenseMap< BasicBlock *, Instruction *, 32 > &SunkCopies, const LoopSafetyInfo *SafetyInfo, const Loop *CurLoop, MemorySSAUpdater &MSSAU)
 
static bool canSplitPredecessors (PHINode *PN, LoopSafetyInfo *SafetyInfo)
 
static void splitPredecessorsOfLoopExit (PHINode *PN, DominatorTree *DT, LoopInfo *LI, const Loop *CurLoop, LoopSafetyInfo *SafetyInfo, MemorySSAUpdater *MSSAU)
 
static bool hoistMinMax (Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU)
 Try to simplify things like (A < INV_1 AND icmp A < INV_2) into (A < min(INV_1, INV_2)), if INV_1 and INV_2 are both loop invariants and their minimun can be computed outside of loop, and X is not a loop-invariant.
 
static bool hoistGEP (Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
 Reassociate gep (gep ptr, idx1), idx2 to gep (gep ptr, idx2), idx1 if this allows hoisting the inner GEP.
 
static bool hoistAdd (ICmpInst::Predicate Pred, Value *VariantLHS, Value *InvariantRHS, ICmpInst &ICmp, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
 Try to turn things like "LV + C1 < C2" into "LV < C2 - C1".
 
static bool hoistSub (ICmpInst::Predicate Pred, Value *VariantLHS, Value *InvariantRHS, ICmpInst &ICmp, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
 Try to reassociate and hoist the following two patterns: LV - C1 < C2 --> LV < C1 + C2, C1 - LV < C2 --> LV > C1 - C2.
 
static bool hoistAddSub (Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
 Reassociate and hoist add/sub expressions.
 
static bool isReassociableOp (Instruction *I, unsigned IntOpcode, unsigned FPOpcode)
 
static bool hoistMulAddAssociation (Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
 Try to reassociate expressions like ((A1 * B1) + (A2 * B2) + ...) * C where A1, A2, ... and C are loop invariants into expressions like ((A1 * C * B1) + (A2 * C * B2) + ...) and hoist the (A1 * C), (A2 * C), ... invariant expressions.
 
static bool hoistBOAssociation (Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
 Reassociate associative binary expressions of the form.
 

Variables

static cl::opt< boolDisablePromotion ("disable-licm-promotion", cl::Hidden, cl::init(false), cl::desc("Disable memory promotion in LICM pass"))
 Memory promotion is enabled by default.
 
static cl::opt< boolControlFlowHoisting ("licm-control-flow-hoisting", cl::Hidden, cl::init(false), cl::desc("Enable control flow (and PHI) hoisting in LICM"))
 
static cl::opt< boolSingleThread ("licm-force-thread-model-single", cl::Hidden, cl::init(false), cl::desc("Force thread model single in LICM pass"))
 
static cl::opt< uint32_tMaxNumUsesTraversed ("licm-max-num-uses-traversed", cl::Hidden, cl::init(8), cl::desc("Max num uses visited for identifying load " "invariance in loop using invariant start (default = 8)"))
 
static cl::opt< unsignedFPAssociationUpperLimit ("licm-max-num-fp-reassociations", cl::init(5U), cl::Hidden, cl::desc("Set upper limit for the number of transformations performed " "during a single round of hoisting the reassociated expressions."))
 
cl::opt< unsignedIntAssociationUpperLimit ("licm-max-num-int-reassociations", cl::init(5U), cl::Hidden, cl::desc("Set upper limit for the number of transformations performed " "during a single round of hoisting the reassociated expressions."))
 
 licm
 
Loop Invariant Code Motion
 
Loop Invariant Code false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "licm"

Definition at line 94 of file LICM.cpp.

Typedef Documentation

◆ PointersAndHasReadsOutsideSet

Definition at line 213 of file LICM.cpp.

Function Documentation

◆ canSplitPredecessors()

static bool canSplitPredecessors ( PHINode PN,
LoopSafetyInfo SafetyInfo 
)
static

◆ cloneInstructionInExitBlock()

static Instruction * cloneInstructionInExitBlock ( Instruction I,
BasicBlock ExitBlock,
PHINode PN,
const LoopInfo LI,
const LoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU 
)
static

◆ collectPromotionCandidates()

static SmallVector< PointersAndHasReadsOutsideSet, 0 > collectPromotionCandidates ( MemorySSA MSSA,
AliasAnalysis AA,
Loop L 
)
static

◆ eraseInstruction()

static void eraseInstruction ( Instruction I,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU 
)
static

◆ foreachMemoryAccess()

static void foreachMemoryAccess ( MemorySSA MSSA,
Loop L,
function_ref< void(Instruction *)>  Fn 
)
static

Definition at line 2274 of file LICM.cpp.

References llvm::MemorySSA::getBlockAccesses().

Referenced by collectPromotionCandidates().

◆ getClobberingMemoryAccess()

static MemoryAccess * getClobberingMemoryAccess ( MemorySSA MSSA,
BatchAAResults BAA,
SinkAndHoistLICMFlags Flags,
MemoryUseOrDef MA 
)
static

◆ hoist()

static void hoist ( Instruction I,
const DominatorTree DT,
const Loop CurLoop,
BasicBlock Dest,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
ScalarEvolution SE,
OptimizationRemarkEmitter ORE 
)
static

When an instruction is found to only use loop invariant operands that is safe to hoist, this instruction is called to do the dirty work.

Definition at line 1738 of file LICM.cpp.

References llvm::dbgs(), DEBUG_TYPE, llvm::OptimizationRemarkEmitter::emit(), llvm::BasicBlock::getFirstNonPHIIt(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getNameOrAsOperand(), llvm::BasicBlock::getTerminator(), I, llvm::ICFLoopSafetyInfo::isGuaranteedToExecute(), LLVM_DEBUG, and moveInstructionBefore().

Referenced by llvm::hoistRegion().

◆ hoistAdd()

static bool hoistAdd ( ICmpInst::Predicate  Pred,
Value VariantLHS,
Value InvariantRHS,
ICmpInst ICmp,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
AssumptionCache AC,
DominatorTree DT 
)
static

◆ hoistAddSub()

static bool hoistAddSub ( Instruction I,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
AssumptionCache AC,
DominatorTree DT 
)
static

◆ hoistArithmetics()

static bool hoistArithmetics ( Instruction I,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
AssumptionCache AC,
DominatorTree DT 
)
static

Aggregates various functions for hoisting computations out of loop.

Definition at line 2848 of file LICM.cpp.

References hoistAddSub(), hoistBOAssociation(), hoistGEP(), hoistMinMax(), hoistMulAddAssociation(), and I.

Referenced by llvm::hoistRegion().

◆ hoistBOAssociation()

static bool hoistBOAssociation ( Instruction I,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
AssumptionCache AC,
DominatorTree DT 
)
static

Reassociate associative binary expressions of the form.

  1. "(LV op C1) op C2" ==> "LV op (C1 op C2)"

where op is an associative binary op, LV is a loop variant, and C1 and C2 are loop invariants that we want to hoist.

TODO: This can be extended to more cases such as

  1. "C1 op (C2 op LV)" ==> "(C1 op C2) op LV"
  2. "(C1 op LV) op C2" ==> "LV op (C1 op C2)" if op is commutative
  3. "C1 op (LV op C2)" ==> "(C1 op C2) op LV" if op is commutative

Definition at line 2796 of file LICM.cpp.

References assert(), llvm::BinaryOperator::Create(), eraseInstruction(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::BasicBlock::getTerminator(), and I.

Referenced by hoistArithmetics().

◆ hoistGEP()

static bool hoistGEP ( Instruction I,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
AssumptionCache AC,
DominatorTree DT 
)
static

Reassociate gep (gep ptr, idx1), idx2 to gep (gep ptr, idx2), idx1 if this allows hoisting the inner GEP.

Definition at line 2485 of file LICM.cpp.

References llvm::all_of(), llvm::IRBuilderBase::CreateGEP(), DL, eraseInstruction(), GEP, llvm::BasicBlock::getTerminator(), I, llvm::isKnownNonNegative(), NonNegative, and llvm::IRBuilderBase::SetInsertPoint().

Referenced by hoistArithmetics().

◆ hoistMinMax()

static bool hoistMinMax ( Instruction I,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU 
)
static

◆ hoistMulAddAssociation()

static bool hoistMulAddAssociation ( Instruction I,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
AssumptionCache AC,
DominatorTree DT 
)
static

Try to reassociate expressions like ((A1 * B1) + (A2 * B2) + ...) * C where A1, A2, ... and C are loop invariants into expressions like ((A1 * C * B1) + (A2 * C * B2) + ...) and hoist the (A1 * C), (A2 * C), ... invariant expressions.

This functions returns true only if any hoisting has actually occured.

Definition at line 2693 of file LICM.cpp.

References llvm::Add, assert(), llvm::BinaryOperator::Create(), llvm::IRBuilderBase::CreateFMulFMF(), llvm::IRBuilderBase::CreateMul(), llvm::SmallVectorBase< Size_T >::empty(), eraseInstruction(), FPAssociationUpperLimit, llvm::User::getOperand(), llvm::User::getOperandUse(), llvm::BasicBlock::getTerminator(), llvm::Value::hasOneUse(), I, IntAssociationUpperLimit, isReassociableOp(), LHS, llvm::Mul, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), RHS, llvm::SmallVectorBase< Size_T >::size(), and std::swap().

Referenced by hoistArithmetics().

◆ hoistSub()

static bool hoistSub ( ICmpInst::Predicate  Pred,
Value VariantLHS,
Value InvariantRHS,
ICmpInst ICmp,
Loop L,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
AssumptionCache AC,
DominatorTree DT 
)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LegacyLICMPass  ,
"licm"  ,
"Loop Invariant Code Motion"  ,
false  ,
false   
)

◆ inSubLoop()

static bool inSubLoop ( BasicBlock BB,
Loop CurLoop,
LoopInfo LI 
)
static

Little predicate that returns true if the specified basic block is in a subloop of the current one, not the current one itself.

Definition at line 2897 of file LICM.cpp.

References assert(), llvm::LoopBase< BlockT, LoopT >::contains(), and llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor().

Referenced by llvm::hoistRegion(), and llvm::sinkRegion().

◆ isFoldableInLoop()

static bool isFoldableInLoop ( const Instruction I,
const Loop CurLoop,
const TargetTransformInfo TTI 
)
static

◆ isLoadInvariantInLoop()

static bool isLoadInvariantInLoop ( LoadInst LI,
DominatorTree DT,
Loop CurLoop 
)
static

◆ isNotUsedOrFoldableInLoop()

static bool isNotUsedOrFoldableInLoop ( const Instruction I,
const Loop CurLoop,
const LoopSafetyInfo SafetyInfo,
TargetTransformInfo TTI,
bool FoldableInLoop,
bool  LoopNestMode 
)
static

Return true if the only users of this instruction are outside of the loop.

If this is true, we can sink the instruction to the exit blocks of the loop.

We also return true if the instruction could be folded away in lowering. (e.g., a GEP can be folded into a load as an addressing mode in the loop).

Definition at line 1386 of file LICM.cpp.

References llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopSafetyInfo::getBlockColors(), llvm::User::getNumOperands(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::hasOneUser(), I, isFoldableInLoop(), and llvm::Instruction::user_back().

Referenced by llvm::sinkRegion().

◆ isReassociableOp()

static bool isReassociableOp ( Instruction I,
unsigned  IntOpcode,
unsigned  FPOpcode 
)
static

◆ isSafeToExecuteUnconditionally()

static bool isSafeToExecuteUnconditionally ( Instruction Inst,
const DominatorTree DT,
const TargetLibraryInfo TLI,
const Loop CurLoop,
const LoopSafetyInfo SafetyInfo,
OptimizationRemarkEmitter ORE,
const Instruction CtxI,
AssumptionCache AC,
bool  AllowSpeculation 
)
static

Only sink or hoist an instruction if it is not a trapping instruction, or if the instruction is known not to trap when moved to the preheader.

or if it is a trapping instruction and is guaranteed to execute.

Definition at line 1784 of file LICM.cpp.

References DEBUG_TYPE, llvm::OptimizationRemarkEmitter::emit(), llvm::LoopSafetyInfo::isGuaranteedToExecute(), llvm::Loop::isLoopInvariant(), and llvm::isSafeToSpeculativelyExecute().

Referenced by llvm::hoistRegion(), and llvm::promoteLoopAccessesToScalars().

◆ isTriviallyReplaceablePHI()

static bool isTriviallyReplaceablePHI ( const PHINode PN,
const Instruction I 
)
static

Returns true if a PHINode is a trivially replaceable with an Instruction.

This is true when all incoming values are that instruction. This pattern occurs most often with LCSSA PHI nodes.

Definition at line 1347 of file LICM.cpp.

References I, and llvm::PHINode::incoming_values().

Referenced by sink(), and sinkThroughTriviallyReplaceablePHI().

◆ moveInstructionBefore()

static void moveInstructionBefore ( Instruction I,
BasicBlock::iterator  Dest,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
ScalarEvolution SE 
)
static

◆ pointerInvalidatedByBlock()

bool pointerInvalidatedByBlock ( BasicBlock BB,
MemorySSA MSSA,
MemoryUse MU 
)
static

◆ pointerInvalidatedByLoop()

static bool pointerInvalidatedByLoop ( MemorySSA MSSA,
MemoryUse MU,
Loop CurLoop,
Instruction I,
SinkAndHoistLICMFlags Flags,
bool  InvariantGroup 
)
static

◆ sink()

static bool sink ( Instruction I,
LoopInfo LI,
DominatorTree DT,
const Loop CurLoop,
ICFLoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU,
OptimizationRemarkEmitter ORE 
)
static

◆ sinkThroughTriviallyReplaceablePHI()

static Instruction * sinkThroughTriviallyReplaceablePHI ( PHINode TPN,
Instruction I,
LoopInfo LI,
SmallDenseMap< BasicBlock *, Instruction *, 32 > &  SunkCopies,
const LoopSafetyInfo SafetyInfo,
const Loop CurLoop,
MemorySSAUpdater MSSAU 
)
static

◆ splitPredecessorsOfLoopExit()

static void splitPredecessorsOfLoopExit ( PHINode PN,
DominatorTree DT,
LoopInfo LI,
const Loop CurLoop,
LoopSafetyInfo SafetyInfo,
MemorySSAUpdater MSSAU 
)
static

◆ STATISTIC() [1/15]

STATISTIC ( NumAddSubHoisted  ,
"Number of add/subtract expressions reassociated " "and hoisted out of the loop"   
)

◆ STATISTIC() [2/15]

STATISTIC ( NumBOAssociationsHoisted  ,
"Number of invariant BinaryOp expressions " "reassociated and hoisted out of the loop"   
)

◆ STATISTIC() [3/15]

STATISTIC ( NumClonedBranches  ,
"Number of branches cloned"   
)

◆ STATISTIC() [4/15]

STATISTIC ( NumCreatedBlocks  ,
"Number of blocks created"   
)

◆ STATISTIC() [5/15]

STATISTIC ( NumFPAssociationsHoisted  ,
"Number of invariant FP expressions " "reassociated and hoisted out of the loop"   
)

◆ STATISTIC() [6/15]

STATISTIC ( NumGEPsHoisted  ,
"Number of geps reassociated and hoisted out of the loop"   
)

◆ STATISTIC() [7/15]

STATISTIC ( NumHoisted  ,
"Number of instructions hoisted out of loop"   
)

◆ STATISTIC() [8/15]

STATISTIC ( NumIntAssociationsHoisted  ,
"Number of invariant int expressions " "reassociated and hoisted out of the loop"   
)

◆ STATISTIC() [9/15]

STATISTIC ( NumLoadPromoted  ,
"Number of load-only promotions"   
)

◆ STATISTIC() [10/15]

STATISTIC ( NumLoadStorePromoted  ,
"Number of load and store promotions"   
)

◆ STATISTIC() [11/15]

STATISTIC ( NumMinMaxHoisted  ,
"Number of min/max expressions hoisted out of the loop"   
)

◆ STATISTIC() [12/15]

STATISTIC ( NumMovedCalls  ,
"Number of call insts hoisted or sunk"   
)

◆ STATISTIC() [13/15]

STATISTIC ( NumMovedLoads  ,
"Number of load insts hoisted or sunk"   
)

◆ STATISTIC() [14/15]

STATISTIC ( NumPromotionCandidates  ,
"Number of promotion candidates"   
)

◆ STATISTIC() [15/15]

STATISTIC ( NumSunk  ,
"Number of instructions sunk out of loop"   
)

Variable Documentation

◆ ControlFlowHoisting

cl::opt< bool > ControlFlowHoisting("licm-control-flow-hoisting", cl::Hidden, cl::init(false), cl::desc("Enable control flow (and PHI) hoisting in LICM")) ( "licm-control-flow-hoisting"  ,
cl::Hidden  ,
cl::init(false)  ,
cl::desc("Enable control flow (and PHI) hoisting in LICM")   
)
static

Referenced by llvm::hoistRegion().

◆ DisablePromotion

cl::opt< bool > DisablePromotion("disable-licm-promotion", cl::Hidden, cl::init(false), cl::desc("Disable memory promotion in LICM pass")) ( "disable-licm-promotion"  ,
cl::Hidden  ,
cl::init(false)  ,
cl::desc("Disable memory promotion in LICM pass")   
)
static

Memory promotion is enabled by default.

◆ false

Loop Invariant Code false

Definition at line 378 of file LICM.cpp.

◆ FPAssociationUpperLimit

cl::opt< unsigned > FPAssociationUpperLimit("licm-max-num-fp-reassociations", cl::init(5U), cl::Hidden, cl::desc( "Set upper limit for the number of transformations performed " "during a single round of hoisting the reassociated expressions.")) ( "licm-max-num-fp-reassociations"  ,
cl::init(5U)  ,
cl::Hidden  ,
cl::desc( "Set upper limit for the number of transformations performed " "during a single round of hoisting the reassociated expressions.")   
)
static

Referenced by hoistMulAddAssociation().

◆ IntAssociationUpperLimit

cl::opt< unsigned > IntAssociationUpperLimit("licm-max-num-int-reassociations", cl::init(5U), cl::Hidden, cl::desc( "Set upper limit for the number of transformations performed " "during a single round of hoisting the reassociated expressions.")) ( "licm-max-num-int-reassociations"  ,
cl::init(5U)  ,
cl::Hidden  ,
cl::desc( "Set upper limit for the number of transformations performed " "during a single round of hoisting the reassociated expressions.")   
)

Referenced by hoistMulAddAssociation().

◆ licm

licm

Definition at line 378 of file LICM.cpp.

◆ MaxNumUsesTraversed

cl::opt< uint32_t > MaxNumUsesTraversed("licm-max-num-uses-traversed", cl::Hidden, cl::init(8), cl::desc("Max num uses visited for identifying load " "invariance in loop using invariant start (default = 8)")) ( "licm-max-num-uses-traversed"  ,
cl::Hidden  ,
cl::init(8)  ,
cl::desc("Max num uses visited for identifying load " "invariance in loop using invariant start (default = 8)")   
)
static

Referenced by isLoadInvariantInLoop().

◆ Motion

Loop Invariant Code Motion

Definition at line 378 of file LICM.cpp.

◆ SingleThread

cl::opt< bool > SingleThread("licm-force-thread-model-single", cl::Hidden, cl::init(false), cl::desc("Force thread model single in LICM pass")) ( "licm-force-thread-model-single"  ,
cl::Hidden  ,
cl::init(false)  ,
cl::desc("Force thread model single in LICM pass")   
)
static