[llvm] InferAddressSpaces: Make getPredicatedAddrSpace less confusing (PR #104052)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 09:48:15 PDT 2024
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/104052
This takes a pointer value and the user instruction. Name them as
such, and remove the null check which should be dead.
>From cb8a43e2968e411540ea9429847dc22dc1412e6b Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 14 Aug 2024 20:42:48 +0400
Subject: [PATCH] InferAddressSpaces: Make getPredicatedAddrSpace less
confusing
This takes a pointer value and the user instruction. Name them as
such, and remove the null check which should be dead.
---
.../Transforms/Scalar/InferAddressSpaces.cpp | 20 +++++++++----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index a5571409bba682..0c8aee8a494c03 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -240,7 +240,8 @@ class InferAddressSpacesImpl {
SmallVectorImpl<const Use *> *PoisonUsesToFix) const;
unsigned joinAddressSpaces(unsigned AS1, unsigned AS2) const;
- unsigned getPredicatedAddrSpace(const Value &V, Value *Opnd) const;
+ unsigned getPredicatedAddrSpace(const Value &PtrV,
+ const Instruction *UserCtxI) const;
public:
InferAddressSpacesImpl(AssumptionCache &AC, const DominatorTree *DT,
@@ -909,18 +910,14 @@ void InferAddressSpacesImpl::inferAddressSpaces(
}
}
-unsigned InferAddressSpacesImpl::getPredicatedAddrSpace(const Value &V,
- Value *Opnd) const {
- const Instruction *I = dyn_cast<Instruction>(&V);
- if (!I)
- return UninitializedAddressSpace;
-
- Opnd = Opnd->stripInBoundsOffsets();
- for (auto &AssumeVH : AC.assumptionsFor(Opnd)) {
+unsigned InferAddressSpacesImpl::getPredicatedAddrSpace(
+ const Value &Ptr, const Instruction *UserCtxI) const {
+ const Value *StrippedPtr = Ptr.stripInBoundsOffsets();
+ for (auto &AssumeVH : AC.assumptionsFor(StrippedPtr)) {
if (!AssumeVH)
continue;
CallInst *CI = cast<CallInst>(AssumeVH);
- if (!isValidAssumeForContext(CI, I, DT))
+ if (!isValidAssumeForContext(CI, UserCtxI, DT))
continue;
const Value *Ptr;
@@ -989,7 +986,8 @@ bool InferAddressSpacesImpl::updateAddressSpace(
OperandAS = PtrOperand->getType()->getPointerAddressSpace();
if (OperandAS == FlatAddrSpace) {
// Check AC for assumption dominating V.
- unsigned AS = getPredicatedAddrSpace(V, PtrOperand);
+ unsigned AS =
+ getPredicatedAddrSpace(*PtrOperand, &cast<Instruction>(V));
if (AS != UninitializedAddressSpace) {
LLVM_DEBUG(dbgs()
<< " deduce operand AS from the predicate addrspace "
More information about the llvm-commits
mailing list