|
LLVM
4.0.0
|
#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/LoopIterator.h"#include "llvm/Analysis/LoopPass.h"#include "llvm/Analysis/ScalarEvolution.h"#include "llvm/Analysis/TargetTransformInfo.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/MDBuilder.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Module.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Scalar.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Cloning.h"#include "llvm/Transforms/Utils/LoopUtils.h"#include "llvm/Transforms/Utils/UnrollLoop.h"#include <algorithm>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "loop-unroll" |
Functions | |
| STATISTIC (NumPeeled,"Number of loops peeled") | |
| static bool | canPeel (Loop *L) |
| static void | updateBranchWeights (BasicBlock *Header, BranchInst *LatchBR, unsigned IterNumber, unsigned AvgIters, uint64_t &PeeledHeaderWeight) |
| Update the branch weights of the latch of a peeled-off loop iteration. More... | |
| static void | cloneLoopBlocks (Loop *L, unsigned IterNumber, BasicBlock *InsertTop, BasicBlock *InsertBot, BasicBlock *Exit, SmallVectorImpl< BasicBlock * > &NewBlocks, LoopBlocksDFS &LoopBlocks, ValueToValueMapTy &VMap, ValueToValueMapTy &LVMap, LoopInfo *LI) |
Clones the body of the loop L, putting it between InsertTop and InsertBot. More... | |
Variables | |
| static cl::opt< unsigned > | UnrollPeelMaxCount ("unroll-peel-max-count", cl::init(7), cl::Hidden, cl::desc("Max average trip count which will cause loop peeling.")) |
| static cl::opt< unsigned > | UnrollForcePeelCount ("unroll-force-peel-count", cl::init(0), cl::Hidden, cl::desc("Force a peel count regardless of profiling information.")) |
| #define DEBUG_TYPE "loop-unroll" |
Definition at line 37 of file LoopUnrollPeel.cpp.
Definition at line 49 of file LoopUnrollPeel.cpp.
References llvm::LoopBase< N, M >::getExitingBlock(), llvm::Loop::getUniqueExitBlock(), and llvm::Loop::isLoopSimplifyForm().
Referenced by llvm::computePeelCount(), and llvm::peelLoop().
|
static |
Clones the body of the loop L, putting it between InsertTop and InsertBot.
| IterNumber | The serial number of the iteration currently being peeled off. | |
| Exit | The exit block of the original loop. | |
| [out] | NewBlocks | A list of the the blocks in the newly created clone |
| [out] | VMap | The value map between the loop and the new clone. |
| LoopBlocks | A helper for DFS-traversal of the loop. | |
| LVMap | A value-map that maps instructions from the original loop to instructions in the last peeled-off iteration. |
Definition at line 163 of file LoopUnrollPeel.cpp.
References llvm::LoopBase< N, M >::addBasicBlockToLoop(), llvm::PHINode::addIncoming(), llvm::BasicBlock::begin(), llvm::LoopBlocksDFS::beginRPO(), llvm::CloneBasicBlock(), llvm::LoopBase< N, M >::contains(), llvm::dyn_cast(), llvm::LoopBlocksDFS::endRPO(), F, llvm::LoopBase< N, M >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopBase< N, M >::getLoopLatch(), llvm::LoopBase< N, M >::getLoopPreheader(), llvm::BasicBlock::getParent(), llvm::LoopBase< N, M >::getParentLoop(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), I, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::TerminatorInst::setSuccessor(), and llvm::BranchInst::setSuccessor().
Referenced by llvm::peelLoop().
| STATISTIC | ( | NumPeeled | , |
| "Number of loops peeled" | |||
| ) |
|
static |
Update the branch weights of the latch of a peeled-off loop iteration.
This sets the branch weights for the latch of the recently peeled off loop iteration correctly. Our goal is to make sure that: a) The total weight of all the copies of the loop body is preserved. b) The total weight of the loop exit is preserved. c) The body weight is reasonably distributed between the peeled iterations.
| Header | The copy of the header block that belongs to next iteration. | |
| LatchBR | The copy of the latch branch that belongs to this iteration. | |
| IterNumber | The serial number of the iteration that was just peeled off. | |
| AvgIters | The average number of iterations we expect the loop to have. | |
| [in,out] | PeeledHeaderWeight | The total number of dynamic loop iterations that are unaccounted for. As an input, it represents the number of times we expect to enter the header of the iteration currently being peeled off. The output is the number of times we expect to enter the header of the next iteration. |
Definition at line 130 of file LoopUnrollPeel.cpp.
References llvm::Value::getContext(), llvm::BranchInst::getSuccessor(), llvm::LLVMContext::MD_prof, and llvm::Instruction::setMetadata().
Referenced by llvm::peelLoop().
|
static |
Referenced by llvm::computePeelCount().
|
static |
Referenced by llvm::computePeelCount().
1.8.6