From: Arthur Eubanks Date: Fri, 4 Jun 2021 19:07:03 +0000 (-0700) Subject: [NFC][OpaquePtr] Avoid calling getPointerElementType() X-Git-Tag: llvmorg-14-init~3906 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be5d454f3f07607a7d9326078f5c47f2e1f3a8ee;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp b/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp index e8c2ba9..1d2b1ed 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 - collectCandidates(Loop *L, - std::function - isValidCandidate, - unsigned MaxCandidateNum); + SmallVector collectCandidates( + Loop *L, + std::function + 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 PPCLoopInstrFormPrep::collectCandidates( Loop *L, - std::function isValidCandidate, + std::function + isValidCandidate, unsigned MaxCandidateNum) { SmallVector Buckets; for (const auto &BB : L->blocks()) for (auto &J : *BB) { Value *PtrValue; + Type *PointerElementType; if (LoadInst *LMemI = dyn_cast(&J)) { PtrValue = LMemI->getPointerOperand(); + PointerElementType = LMemI->getType(); } else if (StoreInst *SMemI = dyn_cast(&J)) { PtrValue = SMemI->getPointerOperand(); + PointerElementType = SMemI->getValueOperand()->getType(); } else if (IntrinsicInst *IMemI = dyn_cast(&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 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(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(PtrValue), L); const SCEVAddRecExpr *LARSCEV = dyn_cast(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(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(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.