[llvm] [Loads] Support dereferenceable assumption with variable size. (PR #128436)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 08:50:48 PDT 2025


================
@@ -339,9 +347,11 @@ bool llvm::isDereferenceableAndAlignedInLoop(
 
   Value *Base = nullptr;
   APInt AccessSize;
+  const SCEV *AccessSizeSCEV = nullptr;
   if (const SCEVUnknown *NewBase = dyn_cast<SCEVUnknown>(AccessStart)) {
     Base = NewBase->getValue();
     AccessSize = MaxPtrDiff;
+    AccessSizeSCEV = PtrDiff;
   } else if (auto *MinAdd = dyn_cast<SCEVAddExpr>(AccessStart)) {
----------------
annamthomas wrote:

just to complete the loop here: I got it working for a case where we have more than 2 operands, by using `getPointerBase` and `removePointerBase` along with SCEV's APIs for non-constant offset. 

I'll place a patch for review.

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


More information about the llvm-commits mailing list