[llvm] 79658d6 - InferAddressSpaces: Make getPredicatedAddrSpace less confusing (#104052)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 03:42:12 PDT 2024
Author: Matt Arsenault
Date: 2024-08-15T14:42:08+04:00
New Revision: 79658d65c3c7a075382b74d81e74714e2ea9bd2d
URL: https://github.com/llvm/llvm-project/commit/79658d65c3c7a075382b74d81e74714e2ea9bd2d
DIFF: https://github.com/llvm/llvm-project/commit/79658d65c3c7a075382b74d81e74714e2ea9bd2d.diff
LOG: InferAddressSpaces: Make getPredicatedAddrSpace less confusing (#104052)
This takes a pointer value and the user instruction. Name them as
such, and remove the null check which should be dead.
Added:
Modified:
llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
Removed:
################################################################################
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