[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:44:14 PDT 2025
https://github.com/kasuga-fj created https://github.com/llvm/llvm-project/pull/161822
Replace the delinearization that depends on type information in GEPs with what doesn't rely on it.
This is WIP as the failing tests need to be updated.
>From 614ffa48bf98c7db99cca442c882c70f2e29ab62 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 | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 1f0da8d1830d3..46803b6657510 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();
@@ -3549,8 +3550,7 @@ 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));
+ const SCEV *Range = DimensionSizes[I - 1];
if (!isKnownLessThan(S, Range)) {
LLVM_DEBUG({
dbgs() << "Check failed: !isKnownLessThan(S, Range)\n";
More information about the llvm-commits
mailing list