diff options
| author | Renato Golin <renato.golin@linaro.org> | 2018-03-09 21:05:58 +0000 |
|---|---|---|
| committer | Renato Golin <renato.golin@linaro.org> | 2018-03-09 21:05:58 +0000 |
| commit | 038ede2a16a55106ada3970265037ba0327385bb (patch) | |
| tree | e439d0f35ec332982fbb7f1411cd6081b96c32de /llvm/lib/Analysis | |
| parent | 0fab41782ddc6479602b496e72f7c86700a1d602 (diff) | |
| download | bcm5719-llvm-038ede2a16a55106ada3970265037ba0327385bb.tar.gz bcm5719-llvm-038ede2a16a55106ada3970265037ba0327385bb.zip | |
[NFC] Consolidate six getPointerOperand() utility functions into one place
There are six separate instances of getPointerOperand() utility.
LoopVectorize.cpp has one of them,
and I don't want to create a 7th one while I'm trying to move
LoopVectorizationLegality into a separate file
(eventual objective is to move it to Analysis tree).
See http://lists.llvm.org/pipermail/llvm-dev/2018-February/120999.html
for llvm-dev discussions
Closes D43323.
Patch by Hideki Saito <hideki.saito@intel.com>.
llvm-svn: 327173
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/Delinearization.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/Analysis/DependenceAnalysis.cpp | 27 | ||||
| -rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 14 |
3 files changed, 13 insertions, 40 deletions
diff --git a/llvm/lib/Analysis/Delinearization.cpp b/llvm/lib/Analysis/Delinearization.cpp index dd5af9d43ef..4cafb7da16d 100644 --- a/llvm/lib/Analysis/Delinearization.cpp +++ b/llvm/lib/Analysis/Delinearization.cpp @@ -69,16 +69,6 @@ bool Delinearization::runOnFunction(Function &F) { return false; } -static Value *getPointerOperand(Instruction &Inst) { - if (LoadInst *Load = dyn_cast<LoadInst>(&Inst)) - return Load->getPointerOperand(); - else if (StoreInst *Store = dyn_cast<StoreInst>(&Inst)) - return Store->getPointerOperand(); - else if (GetElementPtrInst *Gep = dyn_cast<GetElementPtrInst>(&Inst)) - return Gep->getPointerOperand(); - return nullptr; -} - void Delinearization::print(raw_ostream &O, const Module *) const { O << "Delinearization on function " << F->getName() << ":\n"; for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { @@ -93,7 +83,7 @@ void Delinearization::print(raw_ostream &O, const Module *) const { // Delinearize the memory access as analyzed in all the surrounding loops. // Do not analyze memory accesses outside loops. for (Loop *L = LI->getLoopFor(BB); L != nullptr; L = L->getParentLoop()) { - const SCEV *AccessFn = SE->getSCEVAtScope(getPointerOperand(*Inst), L); + const SCEV *AccessFn = SE->getSCEVAtScope(getPointerOperand(Inst), L); const SCEVUnknown *BasePointer = dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFn)); diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp index 0d89bbd4eba..b63ec2772e4 100644 --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -643,17 +643,6 @@ bool isLoadOrStore(const Instruction *I) { } -static -Value *getPointerOperand(Instruction *I) { - if (LoadInst *LI = dyn_cast<LoadInst>(I)) - return LI->getPointerOperand(); - if (StoreInst *SI = dyn_cast<StoreInst>(I)) - return SI->getPointerOperand(); - llvm_unreachable("Value is not load or store instruction"); - return nullptr; -} - - // Examines the loop nesting of the Src and Dst // instructions and establishes their shared loops. Sets the variables // CommonLevels, SrcLevels, and MaxLevels. @@ -3176,8 +3165,10 @@ void DependenceInfo::updateDirection(Dependence::DVEntry &Level, /// for each loop level. bool DependenceInfo::tryDelinearize(Instruction *Src, Instruction *Dst, SmallVectorImpl<Subscript> &Pair) { - Value *SrcPtr = getPointerOperand(Src); - Value *DstPtr = getPointerOperand(Dst); + assert(isLoadOrStore(Src) && "instruction is not load or store"); + assert(isLoadOrStore(Dst) && "instruction is not load or store"); + Value *SrcPtr = getLoadStorePointerOperand(Src); + Value *DstPtr = getLoadStorePointerOperand(Dst); Loop *SrcLoop = LI->getLoopFor(Src->getParent()); Loop *DstLoop = LI->getLoopFor(Dst->getParent()); @@ -3302,8 +3293,10 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst, return make_unique<Dependence>(Src, Dst); } - Value *SrcPtr = getPointerOperand(Src); - Value *DstPtr = getPointerOperand(Dst); + assert(isLoadOrStore(Src) && "instruction is not load or store"); + assert(isLoadOrStore(Dst) && "instruction is not load or store"); + Value *SrcPtr = getLoadStorePointerOperand(Src); + Value *DstPtr = getLoadStorePointerOperand(Dst); switch (underlyingObjectsAlias(AA, F->getParent()->getDataLayout(), DstPtr, SrcPtr)) { @@ -3720,8 +3713,8 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep, assert(Dst->mayReadFromMemory() || Dst->mayWriteToMemory()); assert(isLoadOrStore(Src)); assert(isLoadOrStore(Dst)); - Value *SrcPtr = getPointerOperand(Src); - Value *DstPtr = getPointerOperand(Dst); + Value *SrcPtr = getLoadStorePointerOperand(Src); + Value *DstPtr = getLoadStorePointerOperand(Dst); assert(underlyingObjectsAlias(AA, F->getParent()->getDataLayout(), DstPtr, SrcPtr) == MustAlias); diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index beef7007651..98366374520 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1087,16 +1087,6 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, return Stride; } -/// Take the pointer operand from the Load/Store instruction. -/// Returns NULL if this is not a valid Load/Store instruction. -static Value *getPointerOperand(Value *I) { - if (auto *LI = dyn_cast<LoadInst>(I)) - return LI->getPointerOperand(); - if (auto *SI = dyn_cast<StoreInst>(I)) - return SI->getPointerOperand(); - return nullptr; -} - /// Take the address space operand from the Load/Store instruction. /// Returns -1 if this is not a valid Load/Store instruction. static unsigned getAddressSpaceOperand(Value *I) { @@ -1110,8 +1100,8 @@ static unsigned getAddressSpaceOperand(Value *I) { /// Returns true if the memory operations \p A and \p B are consecutive. bool llvm::isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL, ScalarEvolution &SE, bool CheckType) { - Value *PtrA = getPointerOperand(A); - Value *PtrB = getPointerOperand(B); + Value *PtrA = getLoadStorePointerOperand(A); + Value *PtrB = getLoadStorePointerOperand(B); unsigned ASA = getAddressSpaceOperand(A); unsigned ASB = getAddressSpaceOperand(B); |

