LLVM API Documentation

Defines | Functions
LoopUnrollRuntime.cpp File Reference
#include "llvm/Transforms/Utils/UnrollLoop.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpander.h"
#include "llvm/IR/BasicBlock.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 <algorithm>
Include dependency graph for LoopUnrollRuntime.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "loop-unroll"

Functions

 STATISTIC (NumRuntimeUnrolled,"Number of loops unrolled with run-time trip counts")
static void ConnectProlog (Loop *L, Value *TripCount, unsigned Count, BasicBlock *LastPrologBB, BasicBlock *PrologEnd, BasicBlock *OrigPH, BasicBlock *NewPH, ValueToValueMapTy &LVMap, Pass *P)
static void CloneLoopBlocks (Loop *L, bool FirstCopy, BasicBlock *InsertTop, BasicBlock *InsertBot, std::vector< BasicBlock * > &NewBlocks, LoopBlocksDFS &LoopBlocks, ValueToValueMapTy &VMap, ValueToValueMapTy &LVMap, LoopInfo *LI)

Define Documentation

#define DEBUG_TYPE   "loop-unroll"

Definition at line 39 of file LoopUnrollRuntime.cpp.


Function Documentation

static void CloneLoopBlocks ( Loop L,
bool  FirstCopy,
BasicBlock InsertTop,
BasicBlock InsertBot,
std::vector< BasicBlock * > &  NewBlocks,
LoopBlocksDFS LoopBlocks,
ValueToValueMapTy VMap,
ValueToValueMapTy LVMap,
LoopInfo LI 
) [static]
static void ConnectProlog ( Loop L,
Value TripCount,
unsigned  Count,
BasicBlock LastPrologBB,
BasicBlock PrologEnd,
BasicBlock OrigPH,
BasicBlock NewPH,
ValueToValueMapTy LVMap,
Pass P 
) [static]

Connect the unrolling prolog code to the original loop. The unrolling prolog code contains code to execute the 'extra' iterations if the run-time trip count modulo the unroll count is non-zero.

This function performs the following:

  • Create PHI nodes at prolog end block to combine values that exit the prolog code and jump around the prolog.
  • Add a PHI operand to a PHI node at the loop exit block for values that exit the prolog and go around the loop.
  • Branch around the original loop if the trip count is less than the unroll factor.

Definition at line 57 of file LoopUnrollRuntime.cpp.

References llvm::PHINode::addIncoming(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::PHINode::Create(), llvm::BranchInst::Create(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::ConstantInt::get(), llvm::PHINode::getBasicBlockIndex(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::Value::getName(), llvm::Constant::getNullValue(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Loop::getUniqueExitBlock(), I, llvm::CmpInst::ICMP_ULT, llvm::BasicBlock::isLandingPad(), llvm::pred_begin(), llvm::pred_end(), llvm::PHINode::setIncomingValue(), llvm::SplitBlockPredecessors(), llvm::SplitLandingPadPredecessors(), llvm::succ_begin(), and llvm::succ_end().

Referenced by llvm::UnrollRuntimeLoopProlog().

STATISTIC ( NumRuntimeUnrolled  ,
"Number of loops unrolled with run-time trip counts"   
)