31 #define DEBUG_TYPE "nvptx" 50 static const unsigned MaxAggrCopySize = 128;
53 return "Lower aggregate copies/intrinsics into loops";
66 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
72 if (
LoadInst *LI = dyn_cast<LoadInst>(II)) {
79 if (
StoreInst *
SI = dyn_cast<StoreInst>(LI->user_back())) {
80 if (
SI->getOperand(0) != LI)
84 }
else if (
MemIntrinsic *IntrCall = dyn_cast<MemIntrinsic>(II)) {
87 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(IntrCall->getLength())) {
88 if (LenCI->getZExtValue() >= MaxAggrCopySize) {
98 if (AggrLoads.
size() == 0 && MemCalls.
size() == 0) {
106 auto *
SI = cast<StoreInst>(*LI->user_begin());
107 Value *SrcAddr = LI->getOperand(0);
108 Value *DstAddr =
SI->getOperand(1);
119 SI->isVolatile(), TTI);
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();
A parsed version of the target data layout string in and methods for querying it. ...
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
This class represents lattice values for constants.
void expandMemMoveAsLoop(MemMoveInst *MemMove)
Expand MemMove as a loop. MemMove is not deleted.
void push_back(const T &Elt)
This class wraps the llvm.memset intrinsic.
An instruction for reading from memory.
void expandMemSetAsLoop(MemSetInst *MemSet)
Expand MemSet as a loop. MemSet is not deleted.
AnalysisUsage & addRequired()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This class wraps the llvm.memmove intrinsic.
LLVMContext & getContext() const
Get the global data context.
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
An instruction for storing to memory.
static bool runOnFunction(Function &F, bool PostInlining)
void initializeNVPTXLowerAggrCopiesPass(PassRegistry &)
This is an important class for using LLVM in a threaded context.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
This is the common base class for memset/memcpy/memmove.
Iterator for intrusive lists based on ilist_node.
This is the shared class of boolean and integer constants.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
This class wraps the llvm.memcpy intrinsic.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
FunctionPass * createLowerAggrCopies()
static IntegerType * getInt32Ty(LLVMContext &C)
void createMemCpyLoopKnownSize(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, ConstantInt *CopyLen, unsigned SrcAlign, unsigned DestAlign, bool SrcIsVolatile, bool DstIsVolatile, const TargetTransformInfo &TTI)
Emit a loop implementing the semantics of an llvm.memcpy whose size is a compile time constant...
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI)
Expand MemCpy as a loop. MemCpy is not deleted.
INITIALIZE_PASS(NVPTXLowerAggrCopies, "nvptx-lower-aggr-copies", "Lower aggregate copies, and llvm.mem* intrinsics into loops", false, false) FunctionPass *llvm