LLVM 22.0.0git
AArch64LoadStoreOptimizer.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "aarch64-ldst-opt"
#define AARCH64_LOAD_STORE_OPT_NAME   "AArch64 load / store optimization pass"

Functions

 STATISTIC (NumPairCreated, "Number of load/store pair instructions generated")
 STATISTIC (NumPostFolded, "Number of post-index updates folded")
 STATISTIC (NumPreFolded, "Number of pre-index updates folded")
 STATISTIC (NumUnscaledPairCreated, "Number of load/store from unscaled generated")
 STATISTIC (NumZeroStoresPromoted, "Number of narrow zero stores promoted")
 STATISTIC (NumLoadsFromStoresPromoted, "Number of loads from stores promoted")
 STATISTIC (NumFailedAlignmentCheck, "Number of load/store pair transformation " "not passed the alignment check")
 STATISTIC (NumConstOffsetFolded, "Number of const offset of index address folded")
 DEBUG_COUNTER (RegRenamingCounter, DEBUG_TYPE "-reg-renaming", "Controls which pairs are considered for renaming")
 INITIALIZE_PASS (AArch64LoadStoreOpt, "aarch64-ldst-opt", AARCH64_LOAD_STORE_OPT_NAME, false, false) static bool isNarrowStore(unsigned Opc)
static bool isTagStore (const MachineInstr &MI)
static unsigned getMatchingNonSExtOpcode (unsigned Opc, bool *IsValidLdStrOpc=nullptr)
static unsigned getMatchingWideOpcode (unsigned Opc)
static unsigned getMatchingPairOpcode (unsigned Opc)
static unsigned isMatchingStore (MachineInstr &LoadInst, MachineInstr &StoreInst)
static unsigned getPreIndexedOpcode (unsigned Opc)
static unsigned getBaseAddressOpcode (unsigned Opc)
static unsigned getPostIndexedOpcode (unsigned Opc)
static bool isPreLdStPairCandidate (MachineInstr &FirstMI, MachineInstr &MI)
static void getPrePostIndexedMemOpInfo (const MachineInstr &MI, int &Scale, int &MinOffset, int &MaxOffset)
static MachineOperandgetLdStRegOp (MachineInstr &MI, unsigned PairedRegOp=0)
static bool isLdOffsetInRangeOfSt (MachineInstr &LoadInst, MachineInstr &StoreInst, const AArch64InstrInfo *TII)
static bool isPromotableZeroStoreInst (MachineInstr &MI)
static bool isPromotableLoadFromStore (MachineInstr &MI)
static bool isMergeableLdStUpdate (MachineInstr &MI, AArch64FunctionInfo &AFI)
static bool isMergeableIndexLdSt (MachineInstr &MI, int &Scale)
static bool isRewritableImplicitDef (unsigned Opc)
static bool forAllMIsUntilDef (MachineInstr &MI, MCPhysReg DefReg, const TargetRegisterInfo *TRI, unsigned Limit, std::function< bool(MachineInstr &, bool)> &Fn)
static void updateDefinedRegisters (MachineInstr &MI, LiveRegUnits &Units, const TargetRegisterInfo *TRI)
static void addDebugSubstitutionsToTable (MachineFunction *MF, unsigned InstrNumToSet, MachineInstr &OriginalInstr, MachineInstr &MergedInstr)
 This function will add a new entry into the debugValueSubstitutions table when two instruction have been merged into a new one represented by MergedInstr.
static bool inBoundsForPair (bool IsUnscaled, int Offset, int OffsetStride)
static int alignTo (int Num, int PowOf2)
static bool mayAlias (MachineInstr &MIa, SmallVectorImpl< MachineInstr * > &MemInsns, AliasAnalysis *AA)
static bool needsWinCFI (const MachineFunction *MF)
static bool areCandidatesToMergeOrPair (MachineInstr &FirstMI, MachineInstr &MI, LdStPairFlags &Flags, const AArch64InstrInfo *TII)
static bool canRenameMOP (const MachineOperand &MOP, const TargetRegisterInfo *TRI)
static bool canRenameUpToDef (MachineInstr &FirstMI, LiveRegUnits &UsedInBetween, SmallPtrSetImpl< const TargetRegisterClass * > &RequiredClasses, const TargetRegisterInfo *TRI)
static bool canRenameUntilSecondLoad (MachineInstr &FirstLoad, MachineInstr &SecondLoad, LiveRegUnits &UsedInBetween, SmallPtrSetImpl< const TargetRegisterClass * > &RequiredClasses, const TargetRegisterInfo *TRI)
static std::optional< MCPhysRegtryToFindRegisterToRename (const MachineFunction &MF, Register Reg, LiveRegUnits &DefinedInBB, LiveRegUnits &UsedInBetween, SmallPtrSetImpl< const TargetRegisterClass * > &RequiredClasses, const TargetRegisterInfo *TRI)
static std::optional< MCPhysRegfindRenameRegForSameLdStRegPair (std::optional< bool > MaybeCanRename, MachineInstr &FirstMI, MachineInstr &MI, Register Reg, LiveRegUnits &DefinedInBB, LiveRegUnits &UsedInBetween, SmallPtrSetImpl< const TargetRegisterClass * > &RequiredClasses, const TargetRegisterInfo *TRI)
static MachineBasicBlock::iterator maybeMoveCFI (MachineInstr &MI, MachineBasicBlock::iterator MaybeCFI)

Variables

static cl::opt< unsignedLdStLimit ("aarch64-load-store-scan-limit", cl::init(20), cl::Hidden)
static cl::opt< unsignedUpdateLimit ("aarch64-update-scan-limit", cl::init(100), cl::Hidden)
static cl::opt< unsignedLdStConstLimit ("aarch64-load-store-const-scan-limit", cl::init(10), cl::Hidden)
static cl::opt< boolEnableRenaming ("aarch64-load-store-renaming", cl::init(true), cl::Hidden)

Macro Definition Documentation

◆ AARCH64_LOAD_STORE_OPT_NAME

#define AARCH64_LOAD_STORE_OPT_NAME   "AArch64 load / store optimization pass"

Definition at line 90 of file AArch64LoadStoreOptimizer.cpp.

Referenced by INITIALIZE_PASS().

◆ DEBUG_TYPE

#define DEBUG_TYPE   "aarch64-ldst-opt"

Definition at line 55 of file AArch64LoadStoreOptimizer.cpp.

Function Documentation

◆ addDebugSubstitutionsToTable()

void addDebugSubstitutionsToTable ( MachineFunction * MF,
unsigned InstrNumToSet,
MachineInstr & OriginalInstr,
MachineInstr & MergedInstr )
static

This function will add a new entry into the debugValueSubstitutions table when two instruction have been merged into a new one represented by MergedInstr.

Definition at line 969 of file AArch64LoadStoreOptimizer.cpp.

References llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineFunction::makeDebugValueSubstitution(), llvm::MachineInstr::operands(), llvm::MachineInstr::peekDebugInstrNum(), and Reg.

◆ alignTo()

int alignTo ( int Num,
int PowOf2 )
static

◆ areCandidatesToMergeOrPair()

◆ canRenameMOP()

◆ canRenameUntilSecondLoad()

◆ canRenameUpToDef()

◆ DEBUG_COUNTER()

DEBUG_COUNTER ( RegRenamingCounter ,
DEBUG_TYPE "-reg-renaming" ,
"Controls which pairs are considered for renaming"  )

References DEBUG_TYPE.

◆ findRenameRegForSameLdStRegPair()

◆ forAllMIsUntilDef()

bool forAllMIsUntilDef ( MachineInstr & MI,
MCPhysReg DefReg,
const TargetRegisterInfo * TRI,
unsigned Limit,
std::function< bool(MachineInstr &, bool)> & Fn )
static

Definition at line 932 of file AArch64LoadStoreOptimizer.cpp.

References llvm::any_of(), I, llvm::instructionsWithoutDebug(), MBB, MI, and TRI.

Referenced by canRenameUpToDef().

◆ getBaseAddressOpcode()

unsigned getBaseAddressOpcode ( unsigned Opc)
static

Definition at line 516 of file AArch64LoadStoreOptimizer.cpp.

References llvm_unreachable, and Opc.

◆ getLdStRegOp()

◆ getMatchingNonSExtOpcode()

unsigned getMatchingNonSExtOpcode ( unsigned Opc,
bool * IsValidLdStrOpc = nullptr )
static

Definition at line 275 of file AArch64LoadStoreOptimizer.cpp.

References Opc.

Referenced by areCandidatesToMergeOrPair().

◆ getMatchingPairOpcode()

unsigned getMatchingPairOpcode ( unsigned Opc)
static

Definition at line 349 of file AArch64LoadStoreOptimizer.cpp.

References llvm_unreachable, and Opc.

Referenced by areCandidatesToMergeOrPair().

◆ getMatchingWideOpcode()

unsigned getMatchingWideOpcode ( unsigned Opc)
static

Definition at line 330 of file AArch64LoadStoreOptimizer.cpp.

References llvm_unreachable, and Opc.

◆ getPostIndexedOpcode()

unsigned getPostIndexedOpcode ( unsigned Opc)
static

Definition at line 552 of file AArch64LoadStoreOptimizer.cpp.

References llvm_unreachable, and Opc.

◆ getPreIndexedOpcode()

unsigned getPreIndexedOpcode ( unsigned Opc)
static

Definition at line 443 of file AArch64LoadStoreOptimizer.cpp.

References llvm_unreachable, and Opc.

◆ getPrePostIndexedMemOpInfo()

void getPrePostIndexedMemOpInfo ( const MachineInstr & MI,
int & Scale,
int & MinOffset,
int & MaxOffset )
static

◆ inBoundsForPair()

bool inBoundsForPair ( bool IsUnscaled,
int Offset,
int OffsetStride )
static

Definition at line 1527 of file AArch64LoadStoreOptimizer.cpp.

References llvm::Offset.

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( AArch64LoadStoreOpt ,
"aarch64-ldst-opt" ,
AARCH64_LOAD_STORE_OPT_NAME ,
false ,
false  )

Definition at line 246 of file AArch64LoadStoreOptimizer.cpp.

References AARCH64_LOAD_STORE_OPT_NAME, and Opc.

◆ isLdOffsetInRangeOfSt()

bool isLdOffsetInRangeOfSt ( MachineInstr & LoadInst,
MachineInstr & StoreInst,
const AArch64InstrInfo * TII )
static

◆ isMatchingStore()

unsigned isMatchingStore ( MachineInstr & LoadInst,
MachineInstr & StoreInst )
static

◆ isMergeableIndexLdSt()

bool isMergeableIndexLdSt ( MachineInstr & MI,
int & Scale )
static

Definition at line 803 of file AArch64LoadStoreOptimizer.cpp.

References MI, and Opc.

◆ isMergeableLdStUpdate()

◆ isPreLdStPairCandidate()

bool isPreLdStPairCandidate ( MachineInstr & FirstMI,
MachineInstr & MI )
static

Definition at line 631 of file AArch64LoadStoreOptimizer.cpp.

References llvm::MachineInstr::getOpcode(), and MI.

Referenced by areCandidatesToMergeOrPair().

◆ isPromotableLoadFromStore()

bool isPromotableLoadFromStore ( MachineInstr & MI)
static

Definition at line 719 of file AArch64LoadStoreOptimizer.cpp.

References MI.

◆ isPromotableZeroStoreInst()

bool isPromotableZeroStoreInst ( MachineInstr & MI)
static

Definition at line 712 of file AArch64LoadStoreOptimizer.cpp.

References getLdStRegOp(), llvm::MachineOperand::getReg(), MI, and Opc.

◆ isRewritableImplicitDef()

bool isRewritableImplicitDef ( unsigned Opc)
static

Definition at line 837 of file AArch64LoadStoreOptimizer.cpp.

References Opc.

Referenced by canRenameMOP().

◆ isTagStore()

bool isTagStore ( const MachineInstr & MI)
static

Definition at line 263 of file AArch64LoadStoreOptimizer.cpp.

References MI.

Referenced by getPrePostIndexedMemOpInfo().

◆ mayAlias()

◆ maybeMoveCFI()

◆ needsWinCFI()

◆ STATISTIC() [1/8]

STATISTIC ( NumConstOffsetFolded ,
"Number of const offset of index address folded"  )

◆ STATISTIC() [2/8]

STATISTIC ( NumFailedAlignmentCheck ,
"Number of load/store pair transformation " "not passed the alignment check"  )

◆ STATISTIC() [3/8]

STATISTIC ( NumLoadsFromStoresPromoted ,
"Number of loads from stores promoted"  )

◆ STATISTIC() [4/8]

STATISTIC ( NumPairCreated ,
"Number of load/store pair instructions generated"  )

◆ STATISTIC() [5/8]

STATISTIC ( NumPostFolded ,
"Number of post-index updates folded"  )

◆ STATISTIC() [6/8]

STATISTIC ( NumPreFolded ,
"Number of pre-index updates folded"  )

◆ STATISTIC() [7/8]

STATISTIC ( NumUnscaledPairCreated ,
"Number of load/store from unscaled generated"  )

◆ STATISTIC() [8/8]

STATISTIC ( NumZeroStoresPromoted ,
"Number of narrow zero stores promoted"  )

◆ tryToFindRegisterToRename()

◆ updateDefinedRegisters()

void updateDefinedRegisters ( MachineInstr & MI,
LiveRegUnits & Units,
const TargetRegisterInfo * TRI )
static

Variable Documentation

◆ EnableRenaming

cl::opt< bool > EnableRenaming("aarch64-load-store-renaming", cl::init(true), cl::Hidden) ( "aarch64-load-store-renaming" ,
cl::init(true) ,
cl::Hidden  )
static

◆ LdStConstLimit

cl::opt< unsigned > LdStConstLimit("aarch64-load-store-const-scan-limit", cl::init(10), cl::Hidden) ( "aarch64-load-store-const-scan-limit" ,
cl::init(10) ,
cl::Hidden  )
static

◆ LdStLimit

cl::opt< unsigned > LdStLimit("aarch64-load-store-scan-limit", cl::init(20), cl::Hidden) ( "aarch64-load-store-scan-limit" ,
cl::init(20) ,
cl::Hidden  )
static

Referenced by canRenameUpToDef().

◆ UpdateLimit

cl::opt< unsigned > UpdateLimit("aarch64-update-scan-limit", cl::init(100), cl::Hidden) ( "aarch64-update-scan-limit" ,
cl::init(100) ,
cl::Hidden  )
static