Go to the documentation of this file.
31 #define DEBUG_TYPE "nvptx"
50 static const unsigned MaxAggrCopySize = 128;
53 return "Lower aggregate copies/intrinsics into loops";
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)
81 AggrLoads.push_back(LI);
83 }
else if (
MemIntrinsic *IntrCall = dyn_cast<MemIntrinsic>(&
I)) {
86 if (
ConstantInt *LenCI = dyn_cast<ConstantInt>(IntrCall->getLength())) {
87 if (LenCI->getZExtValue() >= MaxAggrCopySize) {
88 MemCalls.push_back(IntrCall);
91 MemCalls.push_back(IntrCall);
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();
This is an optimization pass for GlobalISel generic memory operations.
A parsed version of the target data layout string in and methods for querying it.
This class wraps the llvm.memmove intrinsic.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is the common base class for memset/memcpy/memmove.
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM Basic Block Representation.
This is the shared class of boolean and integer constants.
void initializeNVPTXLowerAggrCopiesPass(PassRegistry &)
FunctionPass * createLowerAggrCopies()
Represent the analysis usage information of a pass.
INITIALIZE_PASS(NVPTXLowerAggrCopies, "nvptx-lower-aggr-copies", "Lower aggregate copies, and llvm.mem* intrinsics into loops", false, false) FunctionPass *llvm
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
An instruction for storing to memory.
This is an important class for using LLVM in a threaded context.
StandardInstrumentations SI(Debug, VerifyEach)
void expandMemSetAsLoop(MemSetInst *MemSet)
Expand MemSet as a loop. MemSet is not deleted.
StringRef - Represent a constant reference to a string, i.e.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
An instruction for reading from memory.
static bool runOnFunction(Function &F, bool PostInlining)
void expandMemMoveAsLoop(MemMoveInst *MemMove)
Expand MemMove as a loop. MemMove is not deleted.
This class wraps the llvm.memcpy intrinsic.
FunctionPass class - This class is used to implement most global optimizations.
void createMemCpyLoopKnownSize(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, ConstantInt *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI, Optional< uint32_t > AtomicCpySize=None)
Emit a loop implementing the semantics of an llvm.memcpy whose size is a compile time constant.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
AnalysisUsage & addRequired()
void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE=nullptr)
Expand MemCpy as a loop. MemCpy is not deleted.
LLVM Value Representation.