LLVM: lib/CodeGen/PeepholeOptimizer.cpp File Reference (original ) (raw )Go to the source code of this file.
Functions
STATISTIC (NumReuse, "Number of extension results reused")
STATISTIC (NumCmps, "Number of compares eliminated")
STATISTIC (NumImmFold, "Number of move immediate folded")
STATISTIC (NumLoadFold, "Number of loads folded")
STATISTIC (NumSelects, "Number of selects optimized")
STATISTIC (NumUncoalescableCopies, "Number of uncoalescable copies optimized")
STATISTIC (NumRewrittenCopies, "Number of copies rewritten")
STATISTIC (NumNAPhysCopies, "Number of non-allocatable physical copies removed")
INITIALIZE_PASS_BEGIN (PeepholeOptimizerLegacy, DEBUG_TYPE , "Peephole Optimizations", false, false) INITIALIZE_PASS_END (PeepholeOptimizerLegacy
static MachineInstr &
insertPHI (MachineRegisterInfo &MRI , const TargetInstrInfo &TII , const SmallVectorImpl < RegSubRegPair > &SrcRegs, MachineInstr &OrigPHI)
Insert a PHI instruction with incoming edges SrcRegs that are guaranteed to have the same register class.
static RegSubRegPair
getNewSource (MachineRegisterInfo *MRI , const TargetInstrInfo *TII , RegSubRegPair Def, const PeepholeOptimizer::RewriteMapTy &RewriteMap, bool HandleMultipleSources=true)
Given a Def.Reg and Def.SubReg pair, use RewriteMap to find the new source to use for rewrite.
static bool
isVirtualRegisterOperand (MachineOperand &MO)
\bried Returns true if MO is a virtual register operand.
Variables
static cl::opt < bool >
Aggressive ("aggressive-ext-opt", cl::Hidden, cl::desc ("Aggressive extension optimization"))
static cl::opt < bool >
DisablePeephole ("disable-peephole", cl::Hidden, cl::init(false), cl::desc ("Disable the peephole optimizer"))
static cl::opt < bool >
DisableAdvCopyOpt ("disable-adv-copy-opt", cl::Hidden, cl::init(false), cl::desc ("Disable advanced copy optimization"))
Specifiy whether or not the value tracking looks through complex instructions.
static cl::opt < bool >
DisableNAPhysCopyOpt ("disable-non-allocatable-phys-copy-opt", cl::Hidden, cl::init(false), cl::desc ("Disable non-allocatable physical register copy optimization"))
static cl::opt < unsigned >
RewritePHILimit ("rewrite-phi-limit", cl::Hidden, cl::init(10), cl::desc ("Limit the length of PHI chains to lookup"))
static cl::opt < unsigned >
MaxRecurrenceChain ("recurrence-chain-limit", cl::Hidden, cl::init(3), cl::desc ("Maximum length of recurrence chain when evaluating the benefit " "of commuting operands"))
DEBUG_TYPE
Peephole
Optimizations
Peephole
false
◆ DEBUG_TYPE#define DEBUG_TYPE "peephole-opt"
◆ RegSubRegPairAndIdx◆ getNewSource()Given a Def.Reg and Def.SubReg pair, use RewriteMap to find the new source to use for rewrite.
If HandleMultipleSources is true and multiple sources for a given Def are found along the way, we found a PHI instructions that needs to be rewritten. TODO: HandleMultipleSources should be removed once we test PHI handling with coalescable copies.
Definition at line 1128 of file PeepholeOptimizer.cpp .
References llvm::dbgs() , getNewSource() , llvm::MachineInstr::getOperand() , llvm::MachineOperand::getReg() , llvm::MachineOperand::getSubReg() , insertPHI() , LLVM_DEBUG , llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup() , MRI , llvm::SmallVectorTemplateBase< T, bool >::push_back() , llvm::TargetInstrInfo::RegSubRegPair::Reg , llvm::TargetInstrInfo::RegSubRegPair::SubReg , and TII .
Referenced by getNewSource() .
◆ INITIALIZE_PASS_BEGIN()
INITIALIZE_PASS_BEGIN
(
PeepholeOptimizerLegacy
,
DEBUG_TYPE
,
"Peephole Optimizations"
,
false
,
false
)
◆ insertPHI()Insert a PHI instruction with incoming edges SrcRegs that are guaranteed to have the same register class.
This is necessary whenever we successfully traverse a PHI instruction and find suitable sources coming from its edges. By inserting a new PHI, we provide a rewritten PHI def suitable to be used in a new COPY instruction.
Definition at line 1092 of file PeepholeOptimizer.cpp .
References llvm::MachineInstrBuilder::addMBB() , llvm::MachineInstrBuilder::addReg() , assert() , llvm::BuildMI() , llvm::SmallVectorTemplateCommon< T, typename >::empty() , llvm::MachineInstr::getDebugLoc() , llvm::MachineOperand::getMBB() , llvm::MachineInstr::getOperand() , llvm::MachineInstr::getParent() , MBB , MRI , Reg , SubReg , and TII .
Referenced by getNewSource() .
◆ isVirtualRegisterOperand()◆ STATISTIC() [1/8]
STATISTIC
(
NumCmps
,
"Number of compares eliminated"
)
◆ STATISTIC() [2/8]
STATISTIC
(
NumImmFold
,
"Number of move immediate folded"
)
◆ STATISTIC() [3/8]
STATISTIC
(
NumLoadFold
,
"Number of loads folded"
)
◆ STATISTIC() [4/8]
STATISTIC
(
NumNAPhysCopies
,
"Number of non-allocatable physical copies removed"
)
◆ STATISTIC() [5/8]
STATISTIC
(
NumReuse
,
"Number of extension results reused"
)
◆ STATISTIC() [6/8]
STATISTIC
(
NumRewrittenCopies
,
"Number of copies rewritten"
)
◆ STATISTIC() [7/8]
STATISTIC
(
NumSelects
,
"Number of selects optimized"
)
◆ STATISTIC() [8/8]
STATISTIC
(
NumUncoalescableCopies
,
"Number of uncoalescable copies optimized"
)
◆ Aggressive
cl::opt < bool > Aggressive("aggressive-ext-opt", cl::Hidden, cl::desc ("Aggressive extension optimization")) ( "aggressive-ext-opt" , cl::Hidden , cl::desc ("Aggressive extension optimization") )
static
◆ DEBUG_TYPE◆ DisableAdvCopyOpt
cl::opt < bool > DisableAdvCopyOpt("disable-adv-copy-opt", cl::Hidden, cl::init(false), cl::desc ("Disable advanced copy optimization")) ( "disable-adv-copy-opt" , cl::Hidden , cl::init(false) , cl::desc ("Disable advanced copy optimization") )
static
Specifiy whether or not the value tracking looks through complex instructions.
When this is true, the value tracker bails on everything that is not a copy or a bitcast.
◆ DisableNAPhysCopyOpt
cl::opt < bool > DisableNAPhysCopyOpt("disable-non-allocatable-phys-copy-opt", cl::Hidden, cl::init(false), cl::desc ("Disable non-allocatable physical register copy optimization")) ( "disable-non-allocatable-phys-copy-opt" , cl::Hidden , cl::init(false) , cl::desc ("Disable non-allocatable physical register copy optimization") )
static
◆ DisablePeephole
cl::opt < bool > DisablePeephole("disable-peephole", cl::Hidden, cl::init(false), cl::desc ("Disable the peephole optimizer")) ( "disable-peephole" , cl::Hidden , cl::init(false) , cl::desc ("Disable the peephole optimizer") )
static
◆ false◆ MaxRecurrenceChain
cl::opt < unsigned > MaxRecurrenceChain("recurrence-chain-limit", cl::Hidden, cl::init(3), cl::desc ("Maximum length of recurrence chain when evaluating the benefit " "of commuting operands")) ( "recurrence-chain-limit" , cl::Hidden , cl::init(3) , cl::desc ("Maximum length of recurrence chain when evaluating the benefit " "of commuting operands") )
static
◆ Optimizations◆ RewritePHILimit
cl::opt < unsigned > RewritePHILimit("rewrite-phi-limit", cl::Hidden, cl::init(10), cl::desc ("Limit the length of PHI chains to lookup")) ( "rewrite-phi-limit" , cl::Hidden , cl::init(10) , cl::desc ("Limit the length of PHI chains to lookup") )
static