LLVM 20.0.0git
Macros | Functions | Variables
HardwareLoops.cpp File Reference

Insert hardware loop intrinsics into loops which are deemed profitable by the target, by querying TargetTransformInfo. More...

#include "llvm/CodeGen/HardwareLoops.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "hardware-loops"
 
#define HW_LOOPS_NAME   "Hardware Loop Insertion"
 

Functions

 STATISTIC (NumHWLoops, "Number of loops converted to hardware loops")
 
static void debugHWLoopFailure (const StringRef DebugMsg, Instruction *I)
 
static OptimizationRemarkAnalysis createHWLoopAnalysis (StringRef RemarkName, Loop *L, Instruction *I)
 
static bool CanGenerateTest (Loop *L, Value *Count)
 

Variables

static cl::opt< boolForceHardwareLoops ("force-hardware-loops", cl::Hidden, cl::init(false), cl::desc("Force hardware loops intrinsics to be inserted"))
 
static cl::opt< boolForceHardwareLoopPHI ("force-hardware-loop-phi", cl::Hidden, cl::init(false), cl::desc("Force hardware loop counter to be updated through a phi"))
 
static cl::opt< boolForceNestedLoop ("force-nested-hardware-loop", cl::Hidden, cl::init(false), cl::desc("Force allowance of nested hardware loops"))
 
static cl::opt< unsignedLoopDecrement ("hardware-loop-decrement", cl::Hidden, cl::init(1), cl::desc("Set the loop decrement value"))
 
static cl::opt< unsignedCounterBitWidth ("hardware-loop-counter-bitwidth", cl::Hidden, cl::init(32), cl::desc("Set the loop counter bitwidth"))
 
static cl::opt< boolForceGuardLoopEntry ("force-hardware-loop-guard", cl::Hidden, cl::init(false), cl::desc("Force generation of loop guard intrinsic"))
 

Detailed Description

Insert hardware loop intrinsics into loops which are deemed profitable by the target, by querying TargetTransformInfo.

A hardware loop comprises of two intrinsics: one, outside the loop, to set the loop iteration count and another, in the exit block, to decrement the counter. The decremented value can either be carried through the loop via a phi or handled in some opaque way by the target.

Definition in file HardwareLoops.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "hardware-loops"

Definition at line 45 of file HardwareLoops.cpp.

◆ HW_LOOPS_NAME

#define HW_LOOPS_NAME   "Hardware Loop Insertion"

Definition at line 47 of file HardwareLoops.cpp.

Function Documentation

◆ CanGenerateTest()

static bool CanGenerateTest ( Loop L,
Value Count 
)
static

◆ createHWLoopAnalysis()

static OptimizationRemarkAnalysis createHWLoopAnalysis ( StringRef  RemarkName,
Loop L,
Instruction I 
)
static

Definition at line 92 of file HardwareLoops.cpp.

References DEBUG_TYPE, DL, and I.

◆ debugHWLoopFailure()

static void debugHWLoopFailure ( const StringRef  DebugMsg,
Instruction I 
)
static

Definition at line 80 of file HardwareLoops.cpp.

References llvm::dbgs(), and I.

◆ STATISTIC()

STATISTIC ( NumHWLoops  ,
"Number of loops converted to hardware loops"   
)

Variable Documentation

◆ CounterBitWidth

cl::opt< unsigned > CounterBitWidth("hardware-loop-counter-bitwidth", cl::Hidden, cl::init(32), cl::desc("Set the loop counter bitwidth")) ( "hardware-loop-counter-bitwidth"  ,
cl::Hidden  ,
cl::init(32)  ,
cl::desc("Set the loop counter bitwidth")   
)
static

◆ ForceGuardLoopEntry

cl::opt< bool > ForceGuardLoopEntry("force-hardware-loop-guard", cl::Hidden, cl::init(false), cl::desc("Force generation of loop guard intrinsic")) ( "force-hardware-loop-guard"  ,
cl::Hidden  ,
cl::init(false)  ,
cl::desc("Force generation of loop guard intrinsic")   
)
static

◆ ForceHardwareLoopPHI

cl::opt< bool > ForceHardwareLoopPHI("force-hardware-loop-phi", cl::Hidden, cl::init(false), cl::desc("Force hardware loop counter to be updated through a phi")) ( "force-hardware-loop-phi"  ,
cl::Hidden  ,
cl::init(false)  ,
cl::desc("Force hardware loop counter to be updated through a phi")   
)
static

◆ ForceHardwareLoops

cl::opt< bool > ForceHardwareLoops("force-hardware-loops", cl::Hidden, cl::init(false), cl::desc("Force hardware loops intrinsics to be inserted")) ( "force-hardware-loops"  ,
cl::Hidden  ,
cl::init(false)  ,
cl::desc("Force hardware loops intrinsics to be inserted")   
)
static

◆ ForceNestedLoop

cl::opt< bool > ForceNestedLoop("force-nested-hardware-loop", cl::Hidden, cl::init(false), cl::desc("Force allowance of nested hardware loops")) ( "force-nested-hardware-loop"  ,
cl::Hidden  ,
cl::init(false)  ,
cl::desc("Force allowance of nested hardware loops")   
)
static

◆ LoopDecrement

cl::opt< unsigned > LoopDecrement("hardware-loop-decrement", cl::Hidden, cl::init(1), cl::desc("Set the loop decrement value")) ( "hardware-loop-decrement"  ,
cl::Hidden  ,
cl::init(1)  ,
cl::desc("Set the loop decrement value")   
)
static