LLVM 22.0.0git
X86SelectionDAGInfo.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "x86-selectiondag-info"

Functions

static MVT getOptimalRepType (const X86Subtarget &Subtarget, Align Alignment)
 Returns the best type to use with repmovs/repstos depending on alignment.
static SDValue emitRepstos (const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Val, SDValue Size, MVT AVT)
 Emit a single REP STOSB instruction for a particular constant size.
static SDValue emitRepstosB (const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Val, uint64_t Size)
 Emit a single REP STOSB instruction for a particular constant size.
static SDValue emitConstantSizeRepstos (SelectionDAG &DAG, const X86Subtarget &Subtarget, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Val, uint64_t Size, EVT SizeVT, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo)
 Returns a REP STOS instruction, possibly with a few load/stores to implement a constant size memory set.
static SDValue emitRepmovs (const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, MVT AVT)
 Emit a single REP MOVS{B,W,D,Q} instruction.
static SDValue emitRepmovsB (const X86Subtarget &Subtarget, SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size)
 Emit a single REP MOVSB instruction for a particular constant size.
static SDValue emitConstantSizeRepmov (SelectionDAG &DAG, const X86Subtarget &Subtarget, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, EVT SizeVT, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
 Returns a REP MOVS instruction, possibly with a few load/stores to implement a constant size memory copy.

Variables

static cl::opt< boolUseFSRMForMemcpy ("x86-use-fsrm-for-memcpy", cl::Hidden, cl::init(false), cl::desc("Use fast short rep mov in memcpy lowering"))

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "x86-selectiondag-info"

Definition at line 24 of file X86SelectionDAGInfo.cpp.

Function Documentation

◆ emitConstantSizeRepmov()

SDValue emitConstantSizeRepmov ( SelectionDAG & DAG,
const X86Subtarget & Subtarget,
const SDLoc & dl,
SDValue Chain,
SDValue Dst,
SDValue Src,
uint64_t Size,
EVT SizeVT,
Align Alignment,
bool isVolatile,
bool AlwaysInline,
MachinePointerInfo DstPtrInfo,
MachinePointerInfo SrcPtrInfo )
static

Returns a REP MOVS instruction, possibly with a few load/stores to implement a constant size memory copy.

In some cases where we know REP MOVS is inefficient we return an empty SDValue so the calling code can either generate a load/store sequence or call the runtime memcpy function.

In case we optimize for size, we use repmovsb even if it's less efficient so we can save the loads/stores of the leftover.

TODO: Revisit next line: big copy with ERMSB on march >= haswell are very efficient.

If we have enhanced repmovs we use it.

We assume runtime memcpy will do a better job for unaligned copies when ERMS is not present.

RepMov can process the whole length.

Definition at line 267 of file X86SelectionDAGInfo.cpp.

References llvm::ISD::ADD, assert(), emitRepmovs(), emitRepmovsB(), llvm::SelectionDAG::getConstant(), llvm::MachineFunction::getFunction(), llvm::SelectionDAG::getIntPtrConstant(), llvm::SelectionDAG::getMachineFunction(), llvm::X86Subtarget::getMaxInlineSizeThreshold(), llvm::SelectionDAG::getMemcpy(), llvm::SelectionDAG::getNode(), getOptimalRepType(), llvm::MachinePointerInfo::getWithOffset(), llvm::Function::hasMinSize(), llvm::Offset, Results, SDValue(), Size, and llvm::ISD::TokenFactor.

Referenced by llvm::X86SelectionDAGInfo::EmitTargetCodeForMemcpy().

◆ emitConstantSizeRepstos()

SDValue emitConstantSizeRepstos ( SelectionDAG & DAG,
const X86Subtarget & Subtarget,
const SDLoc & dl,
SDValue Chain,
SDValue Dst,
SDValue Val,
uint64_t Size,
EVT SizeVT,
Align Alignment,
bool isVolatile,
bool AlwaysInline,
MachinePointerInfo DstPtrInfo )
static

Returns a REP STOS instruction, possibly with a few load/stores to implement a constant size memory set.

In some cases where we know REP MOVS is inefficient we return an empty SDValue so the calling code can either generate a store sequence or call the runtime memset function.

In case we optimize for size, we use repstosb even if it's less efficient so we can save the loads/stores of the leftover.

RepStos can process the whole length.

Definition at line 122 of file X86SelectionDAGInfo.cpp.

References llvm::ISD::ADD, llvm::dyn_cast(), emitRepstos(), emitRepstosB(), llvm::SelectionDAG::getConstant(), llvm::MachineFunction::getFunction(), llvm::SelectionDAG::getIntPtrConstant(), llvm::SelectionDAG::getMachineFunction(), llvm::X86Subtarget::getMaxInlineSizeThreshold(), llvm::SelectionDAG::getMemset(), llvm::SelectionDAG::getNode(), getOptimalRepType(), llvm::MachinePointerInfo::getWithOffset(), llvm::Function::hasMinSize(), llvm::Offset, Results, SDValue(), Size, and llvm::ISD::TokenFactor.

Referenced by llvm::X86SelectionDAGInfo::EmitTargetCodeForMemset().

◆ emitRepmovs()

◆ emitRepmovsB()

SDValue emitRepmovsB ( const X86Subtarget & Subtarget,
SelectionDAG & DAG,
const SDLoc & dl,
SDValue Chain,
SDValue Dst,
SDValue Src,
uint64_t Size )
static

Emit a single REP MOVSB instruction for a particular constant size.

Definition at line 256 of file X86SelectionDAGInfo.cpp.

References emitRepmovs(), llvm::SelectionDAG::getIntPtrConstant(), and Size.

Referenced by emitConstantSizeRepmov().

◆ emitRepstos()

◆ emitRepstosB()

SDValue emitRepstosB ( const X86Subtarget & Subtarget,
SelectionDAG & DAG,
const SDLoc & dl,
SDValue Chain,
SDValue Dst,
SDValue Val,
uint64_t Size )
static

Emit a single REP STOSB instruction for a particular constant size.

Definition at line 111 of file X86SelectionDAGInfo.cpp.

References emitRepstos(), llvm::SelectionDAG::getIntPtrConstant(), and Size.

Referenced by emitConstantSizeRepstos().

◆ getOptimalRepType()

MVT getOptimalRepType ( const X86Subtarget & Subtarget,
Align Alignment )
static

Returns the best type to use with repmovs/repstos depending on alignment.

Definition at line 41 of file X86SelectionDAGInfo.cpp.

References assert(), llvm::isPowerOf2_64(), and llvm::Align::value().

Referenced by emitConstantSizeRepmov(), and emitConstantSizeRepstos().

Variable Documentation

◆ UseFSRMForMemcpy

cl::opt< bool > UseFSRMForMemcpy("x86-use-fsrm-for-memcpy", cl::Hidden, cl::init(false), cl::desc("Use fast short rep mov in memcpy lowering")) ( "x86-use-fsrm-for-memcpy" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Use fast short rep mov in memcpy lowering")  )
static