LLVM 19.0.0git
Classes | Namespaces | Macros | Functions | Variables
X86OptimizeLEAs.cpp File Reference
#include "MCTargetDesc/X86BaseInfo.h"
#include "X86.h"
#include "X86InstrInfo.h"
#include "X86Subtarget.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/CodeGen/LazyMachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineSizeOpts.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Function.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <iterator>

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< MemOpKey >
 Provide DenseMapInfo for MemOpKey. More...
 

Namespaces

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

Macros

#define DEBUG_TYPE   "x86-optimize-LEAs"
 

Functions

 STATISTIC (NumSubstLEAs, "Number of LEA instruction substitutions")
 
 STATISTIC (NumRedundantLEAs, "Number of redundant LEA instructions removed")
 
static bool isIdenticalOp (const MachineOperand &MO1, const MachineOperand &MO2)
 Returns true if two machine operands are identical and they are not physical registers.
 
static bool isSimilarDispOp (const MachineOperand &MO1, const MachineOperand &MO2)
 Returns true if two address displacement operands are of the same type and use the same symbol/index/address regardless of the offset.
 
static bool isLEA (const MachineInstr &MI)
 Returns true if the instruction is LEA.
 
static MemOpKey getMemOpKey (const MachineInstr &MI, unsigned N)
 Returns a hash table key based on memory operands of MI.
 
static bool isValidDispOp (const MachineOperand &MO)
 
 INITIALIZE_PASS (X86OptimizeLEAPass, DEBUG_TYPE, "X86 optimize LEA pass", false, false) int X86OptimizeLEAPass
 

Variables

static cl::opt< boolDisableX86LEAOpt ("disable-x86-lea-opt", cl::Hidden, cl::desc("X86: Disable LEA optimizations."), cl::init(false))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "x86-optimize-LEAs"

Definition at line 55 of file X86OptimizeLEAs.cpp.

Function Documentation

◆ getMemOpKey()

static MemOpKey getMemOpKey ( const MachineInstr MI,
unsigned  N 
)
inlinestatic

Returns a hash table key based on memory operands of MI.

The number of the first memory operand of MI is specified through N.

Definition at line 191 of file X86OptimizeLEAs.cpp.

References llvm::X86::AddrBaseReg, llvm::X86::AddrDisp, llvm::X86::AddrIndexReg, llvm::X86::AddrScaleAmt, llvm::X86::AddrSegmentReg, assert(), isLEA(), MI, and N.

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( X86OptimizeLEAPass  ,
DEBUG_TYPE  ,
"X86 optimize LEA pass"  ,
false  ,
false   
)

Definition at line 315 of file X86OptimizeLEAs.cpp.

References assert(), llvm::First, and llvm::Last.

◆ isIdenticalOp()

static bool isIdenticalOp ( const MachineOperand MO1,
const MachineOperand MO2 
)
inlinestatic

Returns true if two machine operands are identical and they are not physical registers.

Definition at line 201 of file X86OptimizeLEAs.cpp.

References llvm::MachineOperand::getReg(), llvm::MachineOperand::isIdenticalTo(), llvm::Register::isPhysical(), and llvm::MachineOperand::isReg().

◆ isLEA()

static bool isLEA ( const MachineInstr MI)
inlinestatic

Returns true if the instruction is LEA.

Definition at line 231 of file X86OptimizeLEAs.cpp.

References MI.

Referenced by getMemOpKey().

◆ isSimilarDispOp()

static bool isSimilarDispOp ( const MachineOperand MO1,
const MachineOperand MO2 
)
static

◆ isValidDispOp()

static bool isValidDispOp ( const MachineOperand MO)
static

◆ STATISTIC() [1/2]

STATISTIC ( NumRedundantLEAs  ,
"Number of redundant LEA instructions removed"   
)

References Operands.

◆ STATISTIC() [2/2]

STATISTIC ( NumSubstLEAs  ,
"Number of LEA instruction substitutions"   
)

Variable Documentation

◆ DisableX86LEAOpt

cl::opt< bool > DisableX86LEAOpt("disable-x86-lea-opt", cl::Hidden, cl::desc("X86: Disable LEA optimizations."), cl::init(false)) ( "disable-x86-lea-opt"  ,
cl::Hidden  ,
cl::desc("X86: Disable LEA optimizations.")  ,
cl::init(false)   
)
static