[llvm] [SLPVectorizer] Check std::optional coming out of getPointersDiff (PR #175784)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 14 07:51:39 PST 2026
================
@@ -7436,10 +7442,16 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
Ptr0 = PointerOps[Order.front()];
PtrN = PointerOps[Order.back()];
}
- std::optional<int64_t> Diff =
- getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE);
+ // sortPtrAccesses validates getPointersDiff for all pointers relative to
+ // PointerOps[0], so compute the span using PointerOps[0] as intermediate:
+ // Diff = offset(PtrN) - offset(Ptr0) relative to PointerOps[0]
+ std::optional<int64_t> Diff0 =
+ getPointersDiff(ScalarTy, PointerOps[0], ScalarTy, Ptr0, *DL, *SE);
+ std::optional<int64_t> DiffN =
+ getPointersDiff(ScalarTy, PointerOps[0], ScalarTy, PtrN, *DL, *SE);
+ int64_t Diff = *DiffN - *Diff0;
----------------
alexey-bataev wrote:
I would add the assertion here that checks that DifN and Diff0 are set.
https://github.com/llvm/llvm-project/pull/175784
More information about the llvm-commits
mailing list