31#define DEBUG_TYPE "nvptx"
50 static const unsigned MaxAggrCopySize = 128;
53 return "Lower aggregate copies/intrinsics into loops";
57char NVPTXLowerAggrCopies::ID = 0;
59bool NVPTXLowerAggrCopies::runOnFunction(
Function &
F) {
66 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F);
71 if (
LoadInst *LI = dyn_cast<LoadInst>(&
I)) {
75 if (
DL.getTypeStoreSize(LI->getType()) < MaxAggrCopySize)
78 if (
StoreInst *SI = dyn_cast<StoreInst>(LI->user_back())) {
79 if (SI->getOperand(0) != LI)
83 }
else if (
MemIntrinsic *IntrCall = dyn_cast<MemIntrinsic>(&
I)) {
86 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(IntrCall->getLength())) {
87 if (LenCI->getZExtValue() >= MaxAggrCopySize) {
97 if (AggrLoads.
size() == 0 && MemCalls.
size() == 0) {
105 auto *SI = cast<StoreInst>(*LI->user_begin());
106 Value *SrcAddr = LI->getOperand(0);
107 Value *DstAddr = SI->getOperand(1);
108 unsigned NumLoads =
DL.getTypeStoreSize(LI->getType());
121 SI->eraseFromParent();
122 LI->eraseFromParent();
127 if (
MemCpyInst *Memcpy = dyn_cast<MemCpyInst>(MemCall)) {
129 }
else if (
MemMoveInst *Memmove = dyn_cast<MemMoveInst>(MemCall)) {
131 }
else if (
MemSetInst *Memset = dyn_cast<MemSetInst>(MemCall)) {
134 MemCall->eraseFromParent();
147 "Lower aggregate copies, and llvm.mem* intrinsics into loops",
151 return new NVPTXLowerAggrCopies();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM Basic Block Representation.
This is the shared class of boolean and integer constants.
A parsed version of the target data layout string in and methods for querying it.
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
This class wraps the llvm.memcpy intrinsic.
This is the common base class for memset/memcpy/memmove.
This class wraps the llvm.memmove intrinsic.
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
void createMemCpyLoopKnownSize(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, ConstantInt *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI, std::optional< uint32_t > AtomicCpySize=std::nullopt)
Emit a loop implementing the semantics of an llvm.memcpy whose size is a compile time constant.
void initializeNVPTXLowerAggrCopiesPass(PassRegistry &)
bool expandMemMoveAsLoop(MemMoveInst *MemMove, const TargetTransformInfo &TTI)
Expand MemMove as a loop.
FunctionPass * createLowerAggrCopies()
void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE=nullptr)
Expand MemCpy as a loop. MemCpy is not deleted.
void expandMemSetAsLoop(MemSetInst *MemSet)
Expand MemSet as a loop. MemSet is not deleted.