LLVM  14.0.0git
Classes | Macros | Functions | Variables
LoopFlatten.cpp File Reference
#include "llvm/Transforms/Scalar/LoopFlatten.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#include "llvm/Transforms/Utils/SimplifyIndVar.h"
Include dependency graph for LoopFlatten.cpp:

Go to the source code of this file.

Classes

struct  FlattenInfo
 

Macros

#define DEBUG_TYPE   "loop-flatten"
 

Functions

 STATISTIC (NumFlattened, "Number of loops flattened")
 
static bool setLoopComponents (Value *&TC, Value *&TripCount, BinaryOperator *&Increment, SmallPtrSetImpl< Instruction * > &IterationInstructions)
 
static bool findLoopComponents (Loop *L, SmallPtrSetImpl< Instruction * > &IterationInstructions, PHINode *&InductionPHI, Value *&TripCount, BinaryOperator *&Increment, BranchInst *&BackBranch, ScalarEvolution *SE, bool IsWidened)
 
static bool checkPHIs (FlattenInfo &FI, const TargetTransformInfo *TTI)
 
static bool checkOuterLoopInsts (FlattenInfo &FI, SmallPtrSetImpl< Instruction * > &IterationInstructions, const TargetTransformInfo *TTI)
 
static bool checkIVUsers (FlattenInfo &FI)
 
static OverflowResult checkOverflow (FlattenInfo &FI, DominatorTree *DT, AssumptionCache *AC)
 
static bool CanFlattenLoopPair (FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI)
 
static bool DoFlattenLoopPair (FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI, LPMUpdater *U)
 
static bool CanWidenIV (FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI)
 
static bool FlattenLoopPair (FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI, LPMUpdater *U)
 
bool Flatten (LoopNest &LN, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, TargetTransformInfo *TTI, LPMUpdater *U)
 
 INITIALIZE_PASS_BEGIN (LoopFlattenLegacyPass, "loop-flatten", "Flattens loops", false, false) INITIALIZE_PASS_END(LoopFlattenLegacyPass
 

Variables

static cl::opt< unsigned > RepeatedInstructionThreshold ("loop-flatten-cost-threshold", cl::Hidden, cl::init(2), cl::desc("Limit on the cost of instructions that can be repeated due to " "loop flattening"))
 
static cl::opt< bool > AssumeNoOverflow ("loop-flatten-assume-no-overflow", cl::Hidden, cl::init(false), cl::desc("Assume that the product of the two iteration " "trip counts will never overflow"))
 
static cl::opt< bool > WidenIV ("loop-flatten-widen-iv", cl::Hidden, cl::init(true), cl::desc("Widen the loop induction variables, if possible, so " "overflow checks won't reject flattening"))
 
loop flatten
 
loop Flattens loops
 
loop Flattens false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-flatten"

Definition at line 57 of file LoopFlatten.cpp.

Function Documentation

◆ CanFlattenLoopPair()

static bool CanFlattenLoopPair ( FlattenInfo FI,
DominatorTree DT,
LoopInfo LI,
ScalarEvolution SE,
AssumptionCache AC,
const TargetTransformInfo TTI 
)
static

◆ CanWidenIV()

static bool CanWidenIV ( FlattenInfo FI,
DominatorTree DT,
LoopInfo LI,
ScalarEvolution SE,
AssumptionCache AC,
const TargetTransformInfo TTI 
)
static

◆ checkIVUsers()

static bool checkIVUsers ( FlattenInfo FI)
static

◆ checkOuterLoopInsts()

static bool checkOuterLoopInsts ( FlattenInfo FI,
SmallPtrSetImpl< Instruction * > &  IterationInstructions,
const TargetTransformInfo TTI 
)
static

◆ checkOverflow()

static OverflowResult checkOverflow ( FlattenInfo FI,
DominatorTree DT,
AssumptionCache AC 
)
static

◆ checkPHIs()

static bool checkPHIs ( FlattenInfo FI,
const TargetTransformInfo TTI 
)
static

◆ DoFlattenLoopPair()

static bool DoFlattenLoopPair ( FlattenInfo FI,
DominatorTree DT,
LoopInfo LI,
ScalarEvolution SE,
AssumptionCache AC,
const TargetTransformInfo TTI,
LPMUpdater U 
)
static

◆ findLoopComponents()

static bool findLoopComponents ( Loop L,
SmallPtrSetImpl< Instruction * > &  IterationInstructions,
PHINode *&  InductionPHI,
Value *&  TripCount,
BinaryOperator *&  Increment,
BranchInst *&  BackBranch,
ScalarEvolution SE,
bool  IsWidened 
)
static

◆ Flatten()

bool Flatten ( LoopNest LN,
DominatorTree DT,
LoopInfo LI,
ScalarEvolution SE,
AssumptionCache AC,
TargetTransformInfo TTI,
LPMUpdater U 
)

Definition at line 797 of file LoopFlatten.cpp.

References FlattenLoopPair(), and llvm::LoopNest::getLoops().

Referenced by llvm::LoopFlattenPass::run().

◆ FlattenLoopPair()

static bool FlattenLoopPair ( FlattenInfo FI,
DominatorTree DT,
LoopInfo LI,
ScalarEvolution SE,
AssumptionCache AC,
const TargetTransformInfo TTI,
LPMUpdater U 
)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LoopFlattenLegacyPass  ,
"loop-flatten ,
"Flattens loops ,
false  ,
false   
)

◆ setLoopComponents()

static bool setLoopComponents ( Value *&  TC,
Value *&  TripCount,
BinaryOperator *&  Increment,
SmallPtrSetImpl< Instruction * > &  IterationInstructions 
)
static

◆ STATISTIC()

STATISTIC ( NumFlattened  ,
"Number of loops flattened"   
)

Variable Documentation

◆ AssumeNoOverflow

cl::opt<bool> AssumeNoOverflow("loop-flatten-assume-no-overflow", cl::Hidden, cl::init(false), cl::desc("Assume that the product of the two iteration " "trip counts will never overflow"))
static

Referenced by checkOverflow().

◆ false

loop Flattens false

Definition at line 855 of file LoopFlatten.cpp.

◆ flatten

loop flatten

Definition at line 854 of file LoopFlatten.cpp.

◆ loops

loop Flattens loops

Definition at line 854 of file LoopFlatten.cpp.

◆ RepeatedInstructionThreshold

cl::opt<unsigned> RepeatedInstructionThreshold("loop-flatten-cost-threshold", cl::Hidden, cl::init(2), cl::desc("Limit on the cost of instructions that can be repeated due to " "loop flattening"))
static

Referenced by checkOuterLoopInsts().

◆ WidenIV

WidenIV::WidenIV
static

Definition at line 1129 of file SimplifyIndVar.cpp.

Referenced by CanWidenIV(), and llvm::createWideIV().