LLVM 17.0.0git
|
#include "llvm/Transforms/Utils/LoopRotationUtils.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IntrinsicInst.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/SSAUpdater.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
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. | |
static void | RewriteUsesOfClonedInstructions (BasicBlock *OrigHeader, BasicBlock *OrigPreheader, ValueToValueMapTy &ValueMap, ScalarEvolution *SE, SmallVectorImpl< PHINode * > *InsertedPHIs) |
RewriteUsesOfClonedInstructions - We just cloned the instructions from the old header into the preheader. | |
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. | |
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")) |
#define DEBUG_TYPE "loop-rotate" |
Definition at line 38 of file LoopRotationUtils.cpp.
Definition at line 209 of file LoopRotationUtils.cpp.
References llvm::any_of(), assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::SmallVectorBase< Size_T >::empty(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::BasicBlock::getPostdominatingDeoptimizeCall(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::LoopBase< BlockT, LoopT >::getUniqueExitBlocks(), and llvm::BranchInst::isConditional().
|
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 87 of file LoopRotationUtils.cpp.
References assert(), and llvm::ValueMap< KeyT, ValueT, Config >::insert().
Definition at line 184 of file LoopRotationUtils.cpp.
References llvm::any_of(), assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::BranchInst::getSuccessor(), and llvm::BranchInst::isConditional().
|
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 96 of file LoopRotationUtils.cpp.
References llvm::BasicBlock::begin(), E, llvm::BasicBlock::end(), llvm::findDbgValues(), llvm::ScalarEvolution::forgetValue(), llvm::UndefValue::get(), llvm::Value::getName(), llvm::Instruction::getParent(), llvm::Value::getType(), I, llvm::ValueMap< KeyT, ValueT, Config >::lookup(), llvm::make_early_inc_range(), SSA, llvm::Value::use_empty(), and llvm::Value::uses().
|
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 698 of file LoopRotationUtils.cpp.
References llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getExitingBlock(), I, llvm::isSafeToSpeculativelyExecute(), and llvm::Value::users().
STATISTIC | ( | NumInstrsDuplicated | , |
"Number of instructions cloned into loop preheader" | |||
) |
STATISTIC | ( | NumInstrsHoisted | , |
"Number of instructions hoisted into loop preheader" | |||
) |
STATISTIC | ( | NumNotRotatedDueToHeaderSize | , |
"Number of loops not rotated due to the header size" | |||
) |
STATISTIC | ( | NumRotated | , |
"Number of loops rotated" | |||
) |
|
static |