[llvm] [Loads] Support dereference for non-constant offset (PR #149551)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 13:51:36 PDT 2025
================
@@ -361,29 +361,29 @@ bool llvm::isDereferenceableAndAlignedInLoop(
AccessSize = MaxPtrDiff;
AccessSizeSCEV = PtrDiff;
} else if (auto *MinAdd = dyn_cast<SCEVAddExpr>(AccessStart)) {
- if (MinAdd->getNumOperands() != 2)
- return false;
+ const auto *NewBase = dyn_cast<SCEVUnknown>(SE.getPointerBase(MinAdd));
+ const auto *OffsetSCEV = SE.removePointerBase(MinAdd);
- const auto *Offset = dyn_cast<SCEVConstant>(MinAdd->getOperand(0));
- const auto *NewBase = dyn_cast<SCEVUnknown>(MinAdd->getOperand(1));
- if (!Offset || !NewBase)
+ if (!OffsetSCEV || !NewBase)
----------------
nikic wrote:
`removePointerBase()` is infallible, no need to check `!OffsetSCEV`.
https://github.com/llvm/llvm-project/pull/149551
More information about the llvm-commits
mailing list