LLVM  13.0.0git
Macros | Functions | Variables
LoopRotationUtils.cpp File Reference
#include "llvm/Transforms/Utils/LoopRotationUtils.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
Include dependency graph for LoopRotationUtils.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "loop-rotate"
 

Functions

 STATISTIC (NumNotRotatedDueToHeaderSize, "Number of loops not rotated due to the header size")
 
 STATISTIC (NumInstrsHoisted, "Number of instructions hoisted into loop preheader")
 
 STATISTIC (NumInstrsDuplicated, "Number of instructions cloned into loop preheader")
 
 STATISTIC (NumRotated, "Number of loops rotated")
 
static void InsertNewValueIntoMap (ValueToValueMapTy &VM, Value *K, Value *V)
 Insert (K, V) pair into the ValueToValueMap, and verify the key did not previously exist in the map, and the value was inserted. More...
 
static void RewriteUsesOfClonedInstructions (BasicBlock *OrigHeader, BasicBlock *OrigPreheader, ValueToValueMapTy &ValueMap, SmallVectorImpl< PHINode * > *InsertedPHIs)
 RewriteUsesOfClonedInstructions - We just cloned the instructions from the old header into the preheader. More...
 
static bool profitableToRotateLoopExitingLatch (Loop *L)
 
static bool canRotateDeoptimizingLatchExit (Loop *L)
 
static bool shouldSpeculateInstrs (BasicBlock::iterator Begin, BasicBlock::iterator End, Loop *L)
 Determine whether the instructions in this range may be safely and cheaply speculated. More...
 

Variables

static cl::opt< bool > MultiRotate ("loop-rotate-multi", cl::init(false), cl::Hidden, cl::desc("Allow loop rotation multiple times in order to reach " "a better latch exit"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-rotate"

Definition at line 45 of file LoopRotationUtils.cpp.

Function Documentation

◆ canRotateDeoptimizingLatchExit()

static bool canRotateDeoptimizingLatchExit ( Loop L)
static

◆ InsertNewValueIntoMap()

static void InsertNewValueIntoMap ( ValueToValueMapTy VM,
Value K,
Value V 
)
static

Insert (K, V) pair into the ValueToValueMap, and verify the key did not previously exist in the map, and the value was inserted.

Definition at line 94 of file LoopRotationUtils.cpp.

References assert(), and llvm::ValueMap< KeyT, ValueT, Config >::insert().

◆ profitableToRotateLoopExitingLatch()

static bool profitableToRotateLoopExitingLatch ( Loop L)
static

◆ RewriteUsesOfClonedInstructions()

static void RewriteUsesOfClonedInstructions ( BasicBlock OrigHeader,
BasicBlock OrigPreheader,
ValueToValueMapTy ValueMap,
SmallVectorImpl< PHINode * > *  InsertedPHIs 
)
static

RewriteUsesOfClonedInstructions - We just cloned the instructions from the old header into the preheader.

If there were uses of the values produced by these instruction that were outside of the loop, we have to insert PHI nodes to merge the two values. Do this now.

Definition at line 103 of file LoopRotationUtils.cpp.

References llvm::BasicBlock::begin(), E, llvm::BasicBlock::end(), llvm::findDbgValues(), llvm::UndefValue::get(), llvm::Value::getName(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::Value::getType(), llvm::Use::getUser(), I, llvm::ValueMap< KeyT, ValueT, Config >::lookup(), SSA, llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().

◆ shouldSpeculateInstrs()

static bool shouldSpeculateInstrs ( BasicBlock::iterator  Begin,
BasicBlock::iterator  End,
Loop L 
)
static

Determine whether the instructions in this range may be safely and cheaply speculated.

This is not an important enough situation to develop complex heuristics. We handle a single arithmetic instruction along with any type conversions.

Definition at line 697 of file LoopRotationUtils.cpp.

◆ STATISTIC() [1/4]

STATISTIC ( NumInstrsDuplicated  ,
"Number of instructions cloned into loop preheader  
)

◆ STATISTIC() [2/4]

STATISTIC ( NumInstrsHoisted  ,
"Number of instructions hoisted into loop preheader  
)

◆ STATISTIC() [3/4]

STATISTIC ( NumNotRotatedDueToHeaderSize  ,
"Number of loops not rotated due to the header size  
)

◆ STATISTIC() [4/4]

STATISTIC ( NumRotated  ,
"Number of loops rotated"   
)

Variable Documentation

◆ MultiRotate

cl::opt<bool> MultiRotate("loop-rotate-multi", cl::init(false), cl::Hidden, cl::desc("Allow loop rotation multiple times in order to reach " "a better latch exit"))
static