LLVM  3.7.0
Macros | Functions | Variables
LoopRotation.cpp File Reference
#include "llvm/Transforms/Scalar.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.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/Local.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
Include dependency graph for LoopRotation.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "loop-rotate"
 

Functions

 STATISTIC (NumRotated,"Number of loops rotated")
 
static void RewriteUsesOfClonedInstructions (BasicBlock *OrigHeader, BasicBlock *OrigPreheader, ValueToValueMapTy &ValueMap)
 RewriteUsesOfClonedInstructions - We just cloned the instructions from the old header into the preheader. More...
 
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< unsignedDefaultRotationThreshold ("rotation-max-header-size", cl::init(16), cl::Hidden, cl::desc("The default maximum header size for automatic loop rotation"))
 

Macro Definition Documentation

#define DEBUG_TYPE   "loop-rotate"

Definition at line 37 of file LoopRotation.cpp.

Function Documentation

static void RewriteUsesOfClonedInstructions ( BasicBlock OrigHeader,
BasicBlock OrigPreheader,
ValueToValueMapTy ValueMap 
)
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 138 of file LoopRotation.cpp.

References llvm::SSAUpdater::AddAvailableValue(), llvm::BasicBlock::begin(), llvm::dyn_cast(), llvm::BasicBlock::end(), llvm::PHINode::getBasicBlockIndex(), llvm::Value::getName(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::Use::getUser(), I, llvm::SSAUpdater::Initialize(), llvm::PHINode::removeIncomingValue(), llvm::SSAUpdater::RewriteUse(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().

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 203 of file LoopRotation.cpp.

References llvm::APIntOps::And(), llvm::LoopBase< N, M >::contains(), llvm::LoopBase< N, M >::getExitingBlock(), I, llvm::isSafeToSpeculativelyExecute(), llvm::APIntOps::Or(), llvm::Value::users(), and llvm::APIntOps::Xor().

STATISTIC ( NumRotated  ,
"Number of loops rotated"   
)

Variable Documentation

cl::opt<unsigned> DefaultRotationThreshold("rotation-max-header-size", cl::init(16), cl::Hidden, cl::desc("The default maximum header size for automatic loop rotation"))
static