[llvm] InferAddressSpaces: Make getPredicatedAddrSpace less confusing (PR #104052)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 09:49:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
This takes a pointer value and the user instruction. Name them as
such, and remove the null check which should be dead.
---
Full diff: https://github.com/llvm/llvm-project/pull/104052.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp (+9-11)
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index a5571409bba68..0c8aee8a494c0 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 "
``````````
</details>
https://github.com/llvm/llvm-project/pull/104052
More information about the llvm-commits
mailing list