29#define DEBUG_TYPE "nvptx"
48 static const unsigned MaxAggrCopySize = 128;
51 return "Lower aggregate copies/intrinsics into loops";
55char NVPTXLowerAggrCopies::ID = 0;
57bool NVPTXLowerAggrCopies::runOnFunction(
Function &
F) {
64 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F);
69 if (
LoadInst *LI = dyn_cast<LoadInst>(&
I)) {
73 if (
DL.getTypeStoreSize(LI->getType()) < MaxAggrCopySize)
76 if (
StoreInst *SI = dyn_cast<StoreInst>(LI->user_back())) {
77 if (SI->getOperand(0) != LI)
81 }
else if (
MemIntrinsic *IntrCall = dyn_cast<MemIntrinsic>(&
I)) {
84 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(IntrCall->getLength())) {
85 if (LenCI->getZExtValue() >= MaxAggrCopySize) {
95 if (AggrLoads.
size() == 0 && MemCalls.
size() == 0) {
103 auto *SI = cast<StoreInst>(*LI->user_begin());
104 Value *SrcAddr = LI->getOperand(0);
105 Value *DstAddr = SI->getOperand(1);
106 unsigned NumLoads =
DL.getTypeStoreSize(LI->getType());
119 SI->eraseFromParent();
120 LI->eraseFromParent();
125 if (
MemCpyInst *Memcpy = dyn_cast<MemCpyInst>(MemCall)) {
127 }
else if (
MemMoveInst *Memmove = dyn_cast<MemMoveInst>(MemCall)) {
129 }
else if (
MemSetInst *Memset = dyn_cast<MemSetInst>(MemCall)) {
132 MemCall->eraseFromParent();
145 "Lower aggregate copies, and llvm.mem* intrinsics into loops",
149 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.