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

This file implements the LoadStoreOpt optimization pass. More...

#include "llvm/CodeGen/GlobalISel/LoadStoreOpt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/LowLevelTypeUtils.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Register.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "loadstore-opt"
 

Functions

 STATISTIC (NumStoresMerged, "Number of stores merged")
 
 INITIALIZE_PASS_BEGIN (LoadStoreOpt, DEBUG_TYPE, "Generic memory optimizations", false, false) INITIALIZE_PASS_END(LoadStoreOpt
 
static bool isInstHardMergeHazard (MachineInstr &MI)
 Returns true if the instruction creates an unavoidable hazard that forces a boundary between store merge candidates.
 
static std::optional< int64_t > getTruncStoreByteOffset (GStore &Store, Register &SrcVal, MachineRegisterInfo &MRI)
 Check if the store Store is a truncstore that can be merged.
 

Variables

const unsigned MaxStoreSizeToForm = 128
 
 DEBUG_TYPE
 
Generic memory optimizations
 
Generic memory false
 

Detailed Description

This file implements the LoadStoreOpt optimization pass.

Definition in file LoadStoreOpt.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loadstore-opt"

Definition at line 42 of file LoadStoreOpt.cpp.

Function Documentation

◆ getTruncStoreByteOffset()

static std::optional< int64_t > getTruncStoreByteOffset ( GStore Store,
Register SrcVal,
MachineRegisterInfo MRI 
)
static

Check if the store Store is a truncstore that can be merged.

That is, it's a store of a shifted value of SrcVal. If SrcVal is an empty Register then it does not need to match and SrcVal is set to the source value found. On match, returns the start byte offset of the SrcVal that is being stored.

Definition at line 651 of file LoadStoreOpt.cpp.

References llvm::Register::isValid(), llvm::MIPatternMatch::m_any_of(), llvm::MIPatternMatch::m_GAShr(), llvm::MIPatternMatch::m_GLShr(), llvm::MIPatternMatch::m_GTrunc(), llvm::MIPatternMatch::m_ICst(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::mi_match(), MRI, and llvm::Offset.

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LoadStoreOpt  ,
DEBUG_TYPE  ,
"Generic memory optimizations"  ,
false  ,
false   
)

◆ isInstHardMergeHazard()

static bool isInstHardMergeHazard ( MachineInstr MI)
static

Returns true if the instruction creates an unavoidable hazard that forces a boundary between store merge candidates.

Definition at line 301 of file LoadStoreOpt.cpp.

References MI.

◆ STATISTIC()

STATISTIC ( NumStoresMerged  ,
"Number of stores merged"   
)

Variable Documentation

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 55 of file LoadStoreOpt.cpp.

◆ false

Generic memory false

Definition at line 56 of file LoadStoreOpt.cpp.

◆ MaxStoreSizeToForm

const unsigned MaxStoreSizeToForm = 128

Definition at line 50 of file LoadStoreOpt.cpp.

◆ optimizations

Generic memory optimizations

Definition at line 55 of file LoadStoreOpt.cpp.