LLVM 20.0.0git
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/LoopNestAnalysis.h"
#include "llvm/Analysis/MemorySSAUpdater.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/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/LoopVersioning.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#include "llvm/Transforms/Utils/SimplifyIndVar.h"
#include <optional>

Go to the source code of this file.

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 verifyTripCount (Value *RHS, Loop *L, SmallPtrSetImpl< Instruction * > &IterationInstructions, PHINode *&InductionPHI, Value *&TripCount, BinaryOperator *&Increment, BranchInst *&BackBranch, ScalarEvolution *SE, bool IsWidened)
 
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, MemorySSAUpdater *MSSAU)
 
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, MemorySSAUpdater *MSSAU, const LoopAccessInfo &LAI)
 

Variables

static cl::opt< unsignedRepeatedInstructionThreshold ("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< boolAssumeNoOverflow ("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< boolWidenIV ("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"))
 
static cl::opt< boolVersionLoops ("loop-flatten-version-loops", cl::Hidden, cl::init(true), cl::desc("Version loops if flattened loop could overflow"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-flatten"

Definition at line 81 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

Definition at line 620 of file LoopFlatten.cpp.

References llvm::dbgs(), and LLVM_DEBUG.

Referenced by CanFlattenLoopPair().

◆ 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,
MemorySSAUpdater MSSAU 
)
static

◆ findLoopComponents()

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

◆ FlattenLoopPair()

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

◆ setLoopComponents()

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

◆ STATISTIC()

STATISTIC ( NumFlattened  ,
"Number of loops flattened"   
)

◆ verifyTripCount()

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

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")) ( "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().

◆ 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")) ( "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().

◆ VersionLoops

cl::opt< bool > VersionLoops("loop-flatten-version-loops", cl::Hidden, cl::init(true), cl::desc("Version loops if flattened loop could overflow")) ( "loop-flatten-version-loops"  ,
cl::Hidden  ,
cl::init(true ,
cl::desc("Version loops if flattened loop could overflow")   
)
static

Referenced by FlattenLoopPair().

◆ WidenIV

WidenIV::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")   
)
static

Definition at line 1227 of file SimplifyIndVar.cpp.

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