[llvm] [DA] batch delinearization (PR #170519)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 06:54:53 PST 2025
================
@@ -3328,16 +3341,78 @@ bool DependenceInfo::tryDelinearizeParametricSize(
if (!SrcAR || !DstAR || !SrcAR->isAffine() || !DstAR->isAffine())
return false;
+ SmallVector<const SCEV *, 4> Sizes;
+
+ // Try to use cached results from BatchDelinearization.
+ // This provides better precision by using terms from all accesses.
+ if (BatchDelin && BatchDelin->isPopulated()) {
+ const auto *CachedSizes = BatchDelin->getArraySizes(SrcBase);
+ if (CachedSizes) {
+ // Check element size compatibility.
+ const SCEV *CachedElemSize = BatchDelin->getElementSize(SrcBase);
+ if (CachedElemSize && CachedElemSize == ElementSize) {
+ Sizes.assign(CachedSizes->begin(), CachedSizes->end());
+
+ // Try to use pre-computed subscripts if available.
+ const auto *SrcSubs = BatchDelin->getSubscripts(Src);
+ const auto *DstSubs = BatchDelin->getSubscripts(Dst);
+ if (SrcSubs && DstSubs) {
+ SrcSubscripts.assign(SrcSubs->begin(), SrcSubs->end());
+ DstSubscripts.assign(DstSubs->begin(), DstSubs->end());
+
+ if (SrcSubscripts.size() >= 2 && DstSubscripts.size() >= 2 &&
+ SrcSubscripts.size() == DstSubscripts.size()) {
+ LLVM_DEBUG(dbgs() << "Using cached delinearization results\n");
+
+ // Validate the cached subscripts.
+ if (!DisableDelinearizationChecks)
+ if (!validateDelinearizationResult(*SE, Sizes, SrcSubscripts,
+ SrcPtr) ||
+ !validateDelinearizationResult(*SE, Sizes, DstSubscripts,
+ DstPtr))
+ return false;
+
+ return true;
+ }
+ }
+
+ // Cache had sizes but not pre-computed subscripts for these
+ // instructions, or pre-computed subscripts failed validation.
+ // Compute subscripts using cached sizes.
----------------
kasuga-fj wrote:
Can this happen? If so, why? And does it make sense to compute them here?
https://github.com/llvm/llvm-project/pull/170519
More information about the llvm-commits
mailing list