LLVM 24.0.0git
SelectOptimize.cpp File Reference

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.

Macros

#define DEBUG_TYPE   "select-optimize"

Functions

 STATISTIC (NumSelectOptAnalyzed, "Number of select groups considered for conversion to branch")
 STATISTIC (NumSelectConvertedExpColdOperand, "Number of select groups converted due to expensive cold operand")
 STATISTIC (NumSelectConvertedHighPred, "Number of select groups converted due to high-predictability")
 STATISTIC (NumSelectUnPred, "Number of select groups not converted due to unpredictability")
 STATISTIC (NumSelectColdBB, "Number of select groups not converted due to cold basic block")
 STATISTIC (NumSelectConvertedLoop, "Number of select groups converted due to loop-level analysis")
 STATISTIC (NumSelectsConverted, "Number of selects converted")
 INITIALIZE_PASS_BEGIN (SelectOptimize, DEBUG_TYPE, "Optimize selects", false, false) INITIALIZE_PASS_END(SelectOptimize
static Value * getTrueOrFalseValue (SelectOptimizeImpl::SelectLike &SI, bool isTrue, SmallDenseMap< Instruction *, std::pair< Value *, Value * >, 2 > &OptSelects, BasicBlock *B)
 Returns optimised value on IsTrue branch.
static void EmitAndPrintRemark (OptimizationRemarkEmitter *ORE, DiagnosticInfoOptimizationBase &Rem)
static InstructionCost divideNearest (InstructionCost Numerator, uint64_t Denominator)
static bool extractBranchWeights (const SelectOptimizeImpl::SelectLike SI, uint64_t &TrueVal, uint64_t &FalseVal)
static bool isSafeToSinkLoad (Instruction *LoadI, Instruction *SI)

Variables

 DEBUG_TYPE
Optimize selects
Optimize false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "select-optimize"

Definition at line 48 of file SelectOptimize.cpp.

Function Documentation

◆ divideNearest()

InstructionCost divideNearest ( InstructionCost Numerator,
uint64_t Denominator )
static

Definition at line 1057 of file SelectOptimize.cpp.

References uint64_t.

Referenced by llvm::mulDivNearest().

◆ EmitAndPrintRemark()

◆ extractBranchWeights()

bool extractBranchWeights ( const SelectOptimizeImpl::SelectLike SI,
uint64_t & TrueVal,
uint64_t & FalseVal )
static

Definition at line 1062 of file SelectOptimize.cpp.

References llvm::extractBranchWeights(), llvm::isa(), and uint64_t.

◆ getTrueOrFalseValue()

Value * getTrueOrFalseValue ( SelectOptimizeImpl::SelectLike & SI,
bool isTrue,
SmallDenseMap< Instruction *, std::pair< Value *, Value * >, 2 > & OptSelects,
BasicBlock * B )
static

Returns optimised value on IsTrue branch.

For SelectInst that would be either True or False value. For (BinaryOperator) instructions, where the condition may be skipped, the operation will use a non-conditional operand. For example, for or(V,zext(cond)) this function would return V. However, if the conditional operand on IsTrue branch matters, we create a clone of instruction at the end of that branch B and replace the condition operand with a constant.

Also /p OptSelects contains previously optimised select-like instructions. If the current value uses one of the optimised values, we can optimise it further by replacing it with the corresponding value on the given branch

Definition at line 455 of file SelectOptimize.cpp.

References assert(), B(), llvm::cast(), llvm::dyn_cast(), llvm::Constant::getAllOnesValue(), llvm::isa(), IV, and V.

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( SelectOptimize ,
DEBUG_TYPE ,
"Optimize selects" ,
false ,
false  )

◆ isSafeToSinkLoad()

◆ STATISTIC() [1/7]

STATISTIC ( NumSelectColdBB ,
"Number of select groups not converted due to cold basic block"  )

◆ STATISTIC() [2/7]

STATISTIC ( NumSelectConvertedExpColdOperand ,
"Number of select groups converted due to expensive cold operand"  )

◆ STATISTIC() [3/7]

STATISTIC ( NumSelectConvertedHighPred ,
"Number of select groups converted due to high-predictability"  )

◆ STATISTIC() [4/7]

STATISTIC ( NumSelectConvertedLoop ,
"Number of select groups converted due to loop-level analysis"  )

◆ STATISTIC() [5/7]

STATISTIC ( NumSelectOptAnalyzed ,
"Number of select groups considered for conversion to branch"  )

◆ STATISTIC() [6/7]

STATISTIC ( NumSelectsConverted ,
"Number of selects converted"  )

◆ STATISTIC() [7/7]

STATISTIC ( NumSelectUnPred ,
"Number of select groups not converted due to unpredictability"  )

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 320 of file SelectOptimize.cpp.

◆ false

Optimize false

Definition at line 320 of file SelectOptimize.cpp.

◆ selects

Optimize selects

Definition at line 320 of file SelectOptimize.cpp.