[llvm] cc64ece - [NFC][OpaquePtr] Avoid using PointerType::getElementType() in VectorUtils.cpp
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon May 17 18:41:09 PDT 2021
Author: Arthur Eubanks
Date: 2021-05-17T18:35:44-07:00
New Revision: cc64ece77dddfa7aa590b6d69fe026fcd64d00cf
URL: https://github.com/llvm/llvm-project/commit/cc64ece77dddfa7aa590b6d69fe026fcd64d00cf
DIFF: https://github.com/llvm/llvm-project/commit/cc64ece77dddfa7aa590b6d69fe026fcd64d00cf.diff
LOG: [NFC][OpaquePtr] Avoid using PointerType::getElementType() in VectorUtils.cpp
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D102533
Added:
Modified:
llvm/include/llvm/IR/Instructions.h
llvm/lib/Analysis/VectorUtils.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index b8d0460b122bd..52b8bf5cf0803 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -5280,6 +5280,15 @@ inline unsigned getLoadStoreAddressSpace(Value *I) {
return cast<StoreInst>(I)->getPointerAddressSpace();
}
+/// A helper function that returns the type of a load or store instruction.
+inline Type *getLoadStoreType(Value *I) {
+ assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
+ "Expected Load or Store instruction");
+ if (auto *LI = dyn_cast<LoadInst>(I))
+ return LI->getType();
+ return cast<StoreInst>(I)->getValueOperand()->getType();
+}
+
//===----------------------------------------------------------------------===//
// FreezeInst Class
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index f7c392961fa42..800cd3be46ea9 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -959,12 +959,11 @@ void InterleavedAccessInfo::collectConstStrideAccesses(
DFS.perform(LI);
for (BasicBlock *BB : make_range(DFS.beginRPO(), DFS.endRPO()))
for (auto &I : *BB) {
- auto *LI = dyn_cast<LoadInst>(&I);
- auto *SI = dyn_cast<StoreInst>(&I);
- if (!LI && !SI)
+ Value *Ptr = getLoadStorePointerOperand(&I);
+ if (!Ptr)
continue;
+ Type *ElementTy = getLoadStoreType(&I);
- Value *Ptr = getLoadStorePointerOperand(&I);
// We don't check wrapping here because we don't know yet if Ptr will be
// part of a full group or a group with gaps. Checking wrapping for all
// pointers (even those that end up in groups with no gaps) will be overly
@@ -976,8 +975,7 @@ void InterleavedAccessInfo::collectConstStrideAccesses(
/*Assume=*/true, /*ShouldCheckWrap=*/false);
const SCEV *Scev = replaceSymbolicStrideSCEV(PSE, Strides, Ptr);
- PointerType *PtrTy = cast<PointerType>(Ptr->getType());
- uint64_t Size = DL.getTypeAllocSize(PtrTy->getElementType());
+ uint64_t Size = DL.getTypeAllocSize(ElementTy);
AccessStrideInfo[&I] = StrideDescriptor(Stride, Scev, Size,
getLoadStoreAlignment(&I));
}
More information about the llvm-commits
mailing list