LLVM 22.0.0git
LoopRotationUtils.cpp File Reference

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")
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 void updateBranchWeights (BranchInst &PreHeaderBI, BranchInst &LoopBI, bool HasConditionalPreHeader, bool SuccsSwapped)
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 constexpr uint32_t ZeroTripCountWeights [] = {1, 127}

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-rotate"

Definition at line 40 of file LoopRotationUtils.cpp.

Function Documentation

◆ InsertNewValueIntoMap()

void InsertNewValueIntoMap ( ValueToValueMapTy & VM,
Value * K,
Value * V )
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 86 of file LoopRotationUtils.cpp.

References assert(), and llvm::ValueMap< KeyT, ValueT, Config >::insert().

◆ profitableToRotateLoopExitingLatch()

bool profitableToRotateLoopExitingLatch ( Loop * L)
static

◆ RewriteUsesOfClonedInstructions()

void RewriteUsesOfClonedInstructions ( BasicBlock * OrigHeader,
BasicBlock * OrigPreheader,
ValueToValueMapTy & ValueMap,
ScalarEvolution * SE,
SmallVectorImpl< PHINode * > * InsertedPHIs )
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 95 of file LoopRotationUtils.cpp.

References llvm::BasicBlock::begin(), llvm::cast(), llvm::dyn_cast(), E(), llvm::BasicBlock::end(), llvm::findDbgValues(), llvm::ScalarEvolution::forgetValue(), llvm::PoisonValue::get(), llvm::BasicBlock::getMarker(), llvm::Value::getName(), llvm::DbgMarker::getParent(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Value::getType(), I, llvm::isa(), llvm::ValueMap< KeyT, ValueT, Config >::lookup(), llvm::make_early_inc_range(), SSA, llvm::Value::use_empty(), and llvm::Value::uses().

◆ shouldSpeculateInstrs()

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 831 of file LoopRotationUtils.cpp.

References llvm::cast(), I, llvm::isa(), llvm::isSafeToSpeculativelyExecute(), and llvm::Value::users().

◆ STATISTIC() [1/3]

STATISTIC ( NumInstrsDuplicated ,
"Number of instructions cloned into loop preheader"  )

◆ STATISTIC() [2/3]

STATISTIC ( NumInstrsHoisted ,
"Number of instructions hoisted into loop preheader"  )

◆ STATISTIC() [3/3]

STATISTIC ( NumNotRotatedDueToHeaderSize ,
"Number of loops not rotated due to the header size"  )

◆ updateBranchWeights()

void updateBranchWeights ( BranchInst & PreHeaderBI,
BranchInst & LoopBI,
bool HasConditionalPreHeader,
bool SuccsSwapped )
static

Variable Documentation

◆ ZeroTripCountWeights

uint32_t ZeroTripCountWeights[] = {1, 127}
staticconstexpr

Definition at line 50 of file LoopRotationUtils.cpp.

Referenced by updateBranchWeights().