LLVM API Documentation
#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>
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 DEBUG_TYPE "loop-unroll" |
Definition at line 39 of file LoopUnrollRuntime.cpp.
static void CloneLoopBlocks | ( | Loop * | L, |
bool | FirstCopy, | ||
BasicBlock * | InsertTop, | ||
BasicBlock * | InsertBot, | ||
std::vector< BasicBlock * > & | NewBlocks, | ||
LoopBlocksDFS & | LoopBlocks, | ||
ValueToValueMapTy & | VMap, | ||
ValueToValueMapTy & | LVMap, | ||
LoopInfo * | LI | ||
) | [static] |
Create a clone of the blocks in a loop and connect them together. This function doesn't create a clone of the loop structure.
There are two value maps that are defined and used. VMap is for the values in the current loop instance. LVMap contains the values from the last loop instance. We need the LVMap values to update the initial values for the current loop instance.
Definition at line 137 of file LoopUnrollRuntime.cpp.
References llvm::ValueMap< KeyT, ValueT, Config >::begin(), llvm::BasicBlock::begin(), llvm::LoopBlocksDFS::beginRPO(), llvm::CloneBasicBlock(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::BranchInst::Create(), llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::LoopBlocksDFS::endRPO(), llvm::ValueMap< KeyT, ValueT, Config >::erase(), llvm::iplist< NodeTy, Traits >::erase(), llvm::Instruction::eraseFromParent(), F(), llvm::LoopInfo::getBase(), llvm::PHINode::getBasicBlockIndex(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getIncomingValueForBlock(), llvm::BasicBlock::getInstList(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::BasicBlock::getParent(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::BasicBlock::getTerminator(), I, llvm::PHINode::setIncomingBlock(), llvm::PHINode::setIncomingValue(), and llvm::TerminatorInst::setSuccessor().
Referenced by llvm::UnrollRuntimeLoopProlog().
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:
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().