[llvm] [DA] Replace delinearization for fixed size array (PR #161822)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 3 03:53:43 PDT 2025
https://github.com/kasuga-fj updated https://github.com/llvm/llvm-project/pull/161822
>From aa3e203b09bff73104564bef97a443604c319c72 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Fri, 3 Oct 2025 10:34:08 +0000
Subject: [PATCH] [DA] Replace delinearization for fixed size array
---
llvm/lib/Analysis/DependenceAnalysis.cpp | 34 +++++++++++-------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 1f0da8d1830d3..56f29d469b2cd 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -3504,12 +3504,13 @@ bool DependenceInfo::tryDelinearizeFixedSize(
"expected src and dst scev unknowns to be equal");
});
- SmallVector<int, 4> SrcSizes;
- SmallVector<int, 4> DstSizes;
- if (!tryDelinearizeFixedSizeImpl(SE, Src, SrcAccessFn, SrcSubscripts,
- SrcSizes) ||
- !tryDelinearizeFixedSizeImpl(SE, Dst, DstAccessFn, DstSubscripts,
- DstSizes))
+ const SCEV *ElemSize = SE->getElementSize(Src);
+ assert(ElemSize == SE->getElementSize(Dst) && "Different element sizes");
+ SmallVector<const SCEV *, 4> SrcSizes, DstSizes;
+ if (!delinearizeFixedSizeArray(*SE, SE->removePointerBase(SrcAccessFn),
+ SrcSubscripts, SrcSizes, ElemSize) ||
+ !delinearizeFixedSizeArray(*SE, SE->removePointerBase(DstAccessFn),
+ DstSubscripts, DstSizes, ElemSize))
return false;
// Check that the two size arrays are non-empty and equal in length and
@@ -3535,7 +3536,7 @@ bool DependenceInfo::tryDelinearizeFixedSize(
// iff the subscripts are positive and are less than the range of the
// dimension.
if (!DisableDelinearizationChecks) {
- auto AllIndicesInRange = [&](SmallVector<int, 4> &DimensionSizes,
+ auto AllIndicesInRange = [&](ArrayRef<const SCEV *> DimensionSizes,
SmallVectorImpl<const SCEV *> &Subscripts,
Value *Ptr) {
size_t SSize = Subscripts.size();
@@ -3548,17 +3549,14 @@ bool DependenceInfo::tryDelinearizeFixedSize(
});
return false;
}
- if (auto *SType = dyn_cast<IntegerType>(S->getType())) {
- const SCEV *Range = SE->getConstant(
- ConstantInt::get(SType, DimensionSizes[I - 1], false));
- if (!isKnownLessThan(S, Range)) {
- LLVM_DEBUG({
- dbgs() << "Check failed: !isKnownLessThan(S, Range)\n";
- dbgs() << " S: " << *S << "\n"
- << " Range: " << *Range << "\n";
- });
- return false;
- }
+ const SCEV *Range = DimensionSizes[I - 1];
+ if (!isKnownLessThan(S, Range)) {
+ LLVM_DEBUG({
+ dbgs() << "Check failed: !isKnownLessThan(S, Range)\n";
+ dbgs() << " S: " << *S << "\n"
+ << " Range: " << *Range << "\n";
+ });
+ return false;
}
}
return true;
More information about the llvm-commits
mailing list