[llvm] be5d454 - [NFC][OpaquePtr] Avoid calling getPointerElementType()
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 15 09:53:21 PDT 2021
Author: Arthur Eubanks
Date: 2021-06-15T09:53:12-07:00
New Revision: be5d454f3f07607a7d9326078f5c47f2e1f3a8ee
URL: https://github.com/llvm/llvm-project/commit/be5d454f3f07607a7d9326078f5c47f2e1f3a8ee
DIFF: https://github.com/llvm/llvm-project/commit/be5d454f3f07607a7d9326078f5c47f2e1f3a8ee.diff
LOG: [NFC][OpaquePtr] Avoid calling getPointerElementType()
Pointee types are going away soon.
For this, we mostly just care about store/load types, which are already
available without the pointee types. The other intrinsics always use
i8*.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D103719
Added:
Modified:
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp b/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
index e8c2ba93d643..1d2b1ed3f626 100644
--- a/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
+++ b/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
@@ -191,11 +191,11 @@ namespace {
/// Collect condition matched(\p isValidCandidate() returns true)
/// candidates in Loop \p L.
- SmallVector<Bucket, 16>
- collectCandidates(Loop *L,
- std::function<bool(const Instruction *, const Value *)>
- isValidCandidate,
- unsigned MaxCandidateNum);
+ SmallVector<Bucket, 16> collectCandidates(
+ Loop *L,
+ std::function<bool(const Instruction *, const Value *, const Type *)>
+ isValidCandidate,
+ unsigned MaxCandidateNum);
/// Add a candidate to candidates \p Buckets.
void addOneCandidate(Instruction *MemI, const SCEV *LSCEV,
@@ -331,18 +331,23 @@ void PPCLoopInstrFormPrep::addOneCandidate(Instruction *MemI, const SCEV *LSCEV,
SmallVector<Bucket, 16> PPCLoopInstrFormPrep::collectCandidates(
Loop *L,
- std::function<bool(const Instruction *, const Value *)> isValidCandidate,
+ std::function<bool(const Instruction *, const Value *, const Type *)>
+ isValidCandidate,
unsigned MaxCandidateNum) {
SmallVector<Bucket, 16> Buckets;
for (const auto &BB : L->blocks())
for (auto &J : *BB) {
Value *PtrValue;
+ Type *PointerElementType;
if (LoadInst *LMemI = dyn_cast<LoadInst>(&J)) {
PtrValue = LMemI->getPointerOperand();
+ PointerElementType = LMemI->getType();
} else if (StoreInst *SMemI = dyn_cast<StoreInst>(&J)) {
PtrValue = SMemI->getPointerOperand();
+ PointerElementType = SMemI->getValueOperand()->getType();
} else if (IntrinsicInst *IMemI = dyn_cast<IntrinsicInst>(&J)) {
+ PointerElementType = Type::getInt8Ty(J.getContext());
if (IMemI->getIntrinsicID() == Intrinsic::prefetch ||
IMemI->getIntrinsicID() == Intrinsic::ppc_vsx_lxvp) {
PtrValue = IMemI->getArgOperand(0);
@@ -363,7 +368,7 @@ SmallVector<Bucket, 16> PPCLoopInstrFormPrep::collectCandidates(
if (!LARSCEV || LARSCEV->getLoop() != L)
continue;
- if (isValidCandidate(&J, PtrValue))
+ if (isValidCandidate(&J, PtrValue, PointerElementType))
addOneCandidate(&J, LSCEV, Buckets, MaxCandidateNum);
}
return Buckets;
@@ -820,12 +825,11 @@ bool PPCLoopInstrFormPrep::runOnLoop(Loop *L) {
}
// Check if a load/store has update form. This lambda is used by function
// collectCandidates which can collect candidates for types defined by lambda.
- auto isUpdateFormCandidate = [&] (const Instruction *I,
- const Value *PtrValue) {
+ auto isUpdateFormCandidate = [&](const Instruction *I, const Value *PtrValue,
+ const Type *PointerElementType) {
assert((PtrValue && I) && "Invalid parameter!");
// There are no update forms for Altivec vector load/stores.
- if (ST && ST->hasAltivec() &&
- PtrValue->getType()->getPointerElementType()->isVectorTy())
+ if (ST && ST->hasAltivec() && PointerElementType->isVectorTy())
return false;
// There are no update forms for P10 lxvp/stxvp intrinsic.
auto *II = dyn_cast<IntrinsicInst>(I);
@@ -837,7 +841,7 @@ bool PPCLoopInstrFormPrep::runOnLoop(Loop *L) {
// fits in a 16-bit signed field but isn't a multiple of 4, it will be
// useless and possible to break some original well-form addressing mode
// to make this pre-inc prep for it.
- if (PtrValue->getType()->getPointerElementType()->isIntegerTy(64)) {
+ if (PointerElementType->isIntegerTy(64)) {
const SCEV *LSCEV = SE->getSCEVAtScope(const_cast<Value *>(PtrValue), L);
const SCEVAddRecExpr *LARSCEV = dyn_cast<SCEVAddRecExpr>(LSCEV);
if (!LARSCEV || LARSCEV->getLoop() != L)
@@ -851,13 +855,13 @@ bool PPCLoopInstrFormPrep::runOnLoop(Loop *L) {
}
return true;
};
-
+
// Check if a load/store has DS form.
- auto isDSFormCandidate = [] (const Instruction *I, const Value *PtrValue) {
+ auto isDSFormCandidate = [](const Instruction *I, const Value *PtrValue,
+ const Type *PointerElementType) {
assert((PtrValue && I) && "Invalid parameter!");
if (isa<IntrinsicInst>(I))
return false;
- Type *PointerElementType = PtrValue->getType()->getPointerElementType();
return (PointerElementType->isIntegerTy(64)) ||
(PointerElementType->isFloatTy()) ||
(PointerElementType->isDoubleTy()) ||
@@ -867,7 +871,8 @@ bool PPCLoopInstrFormPrep::runOnLoop(Loop *L) {
};
// Check if a load/store has DQ form.
- auto isDQFormCandidate = [&] (const Instruction *I, const Value *PtrValue) {
+ auto isDQFormCandidate = [&](const Instruction *I, const Value *PtrValue,
+ const Type *PointerElementType) {
assert((PtrValue && I) && "Invalid parameter!");
// Check if it is a P10 lxvp/stxvp intrinsic.
auto *II = dyn_cast<IntrinsicInst>(I);
@@ -875,8 +880,7 @@ bool PPCLoopInstrFormPrep::runOnLoop(Loop *L) {
return II->getIntrinsicID() == Intrinsic::ppc_vsx_lxvp ||
II->getIntrinsicID() == Intrinsic::ppc_vsx_stxvp;
// Check if it is a P9 vector load/store.
- return ST && ST->hasP9Vector() &&
- (PtrValue->getType()->getPointerElementType()->isVectorTy());
+ return ST && ST->hasP9Vector() && (PointerElementType->isVectorTy());
};
// intrinsic for update form.
More information about the llvm-commits
mailing list