[llvm] [Loads] Support dereference for non-constant offset (PR #149551)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 13:38:27 PDT 2025


================
@@ -361,29 +361,25 @@ 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));
+    auto *OffsetSCEV = SE.removePointerBase(MinAdd);
----------------
nikic wrote:

Can move the removePointerBase() call below `!NewBase`.

https://github.com/llvm/llvm-project/pull/149551


More information about the llvm-commits mailing list