aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index f9bd7167317f..19a24ac6a484 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -666,6 +666,29 @@ static bool isNoWrap(PredicatedScalarEvolution &PSE,
return false;
}
+static void visitPointers(Value *StartPtr, const Loop &InnermostLoop,
+ function_ref<void(Value *)> AddPointer) {
+ SmallPtrSet<Value *, 8> Visited;
+ SmallVector<Value *> WorkList;
+ WorkList.push_back(StartPtr);
+
+ while (!WorkList.empty()) {
+ Value *Ptr = WorkList.pop_back_val();
+ if (!Visited.insert(Ptr).second)
+ continue;
+ auto *PN = dyn_cast<PHINode>(Ptr);
+ // SCEV does not look through non-header PHIs inside the loop. Such phis
+ // can be analyzed by adding separate accesses for each incoming pointer
+ // value.
+ if (PN && InnermostLoop.contains(PN->getParent()) &&
+ PN->getParent() != InnermostLoop.getHeader()) {
+ for (const Use &Inc : PN->incoming_values())
+ WorkList.push_back(Inc);
+ } else
+ AddPointer(Ptr);
+ }
+}
+
bool AccessAnalysis::createCheckForAccess(RuntimePointerChecking &RtCheck,
MemAccessInfo Access,
const ValueToValueMap &StridesMap,
@@ -1032,13 +1055,11 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy,
bool ShouldCheckWrap) {
Type *Ty = Ptr->getType();
assert(Ty->isPointerTy() && "Unexpected non-ptr");
- unsigned AddrSpace = Ty->getPointerAddressSpace();
+ assert(!AccessTy->isAggregateType() && "Bad stride - Not a pointer to a scalar type");
- // Make sure we're not accessing an aggregate type.
- // TODO: Why? This doesn't make any sense.
- if (AccessTy->isAggregateType()) {
- LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not a pointer to a scalar type"
- << *Ptr << "\n");
+ if (isa<ScalableVectorType>(AccessTy)) {
+ LLVM_DEBUG(dbgs() << "LAA: Bad stride - Scalable object: " << *AccessTy
+ << "\n");
return 0;
}
@@ -1068,6 +1089,7 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy,
// An getelementptr without an inbounds attribute and unit stride would have
// to access the pointer value "0" which is undefined behavior in address
// space 0, therefore we can also vectorize this case.
+ unsigned AddrSpace = Ty->getPointerAddressSpace();
bool IsInBoundsGEP = isInBoundsGep(Ptr);
bool IsNoWrapAddRec = !ShouldCheckWrap ||
PSE.hasNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW) ||
@@ -1101,7 +1123,8 @@ int64_t llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy,
}
auto &DL = Lp->getHeader()->getModule()->getDataLayout();
- int64_t Size = DL.getTypeAllocSize(AccessTy);
+ TypeSize AllocSize = DL.getTypeAllocSize(AccessTy);
+ int64_t Size = AllocSize.getFixedSize();
const APInt &APStepVal = C->getAPInt();
// Huge step value - give up.
@@ -1263,29 +1286,6 @@ bool llvm::isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL,
return Diff && *Diff == 1;
}
-static void visitPointers(Value *StartPtr, const Loop &InnermostLoop,
- function_ref<void(Value *)> AddPointer) {
- SmallPtrSet<Value *, 8> Visited;
- SmallVector<Value *> WorkList;
- WorkList.push_back(StartPtr);
-
- while (!WorkList.empty()) {
- Value *Ptr = WorkList.pop_back_val();
- if (!Visited.insert(Ptr).second)
- continue;
- auto *PN = dyn_cast<PHINode>(Ptr);
- // SCEV does not look through non-header PHIs inside the loop. Such phis
- // can be analyzed by adding separate accesses for each incoming pointer
- // value.
- if (PN && InnermostLoop.contains(PN->getParent()) &&
- PN->getParent() != InnermostLoop.getHeader()) {
- for (const Use &Inc : PN->incoming_values())
- WorkList.push_back(Inc);
- } else
- AddPointer(Ptr);
- }
-}
-
void MemoryDepChecker::addAccess(StoreInst *SI) {
visitPointers(SI->getPointerOperand(), *InnermostLoop,
[this, SI](Value *Ptr) {