[llvm] 8d0830e - [LoopCacheAnalysis] Remove tryDelinearizeFixedSize (NFCI) (#177552)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 2 00:26:55 PST 2026


Author: Ryotaro Kasuga
Date: 2026-02-02T08:26:51Z
New Revision: 8d0830e344c2f537ac70499a92d26ccd7568f385

URL: https://github.com/llvm/llvm-project/commit/8d0830e344c2f537ac70499a92d26ccd7568f385
DIFF: https://github.com/llvm/llvm-project/commit/8d0830e344c2f537ac70499a92d26ccd7568f385.diff

LOG: [LoopCacheAnalysis] Remove tryDelinearizeFixedSize (NFCI) (#177552)

LoopCacheAnalysis has its own function `tryDelinearizeFixedSize`, which
is a wrapper of Delinearization. Due to recent changes in
Delinearization, this function has become almost equivalent to
`delinearizeFixedSizeArray` and is no longer necessary. This patch
removes it.

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/LoopCacheAnalysis.h
    llvm/lib/Analysis/LoopCacheAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
index 70ccd8aaed20f..5184944e36232 100644
--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
@@ -100,11 +100,6 @@ class IndexedReference {
   /// Attempt to delinearize the indexed reference.
   bool delinearize(const LoopInfo &LI);
 
-  /// Attempt to delinearize \p AccessFn for fixed-size arrays.
-  bool tryDelinearizeFixedSize(const SCEV *AccessFn,
-                               SmallVectorImpl<const SCEV *> &Subscripts,
-                               const SCEV *ElementSize);
-
   /// Return true if the index reference is invariant with respect to loop \p L.
   bool isLoopInvariant(const Loop &L) const;
 

diff  --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
index 3bba2e8c0d8ad..be4dfde85e8da 100644
--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
@@ -354,34 +354,6 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,
   return CacheCostTy::getInvalid();
 }
 
-bool IndexedReference::tryDelinearizeFixedSize(
-    const SCEV *AccessFn, SmallVectorImpl<const SCEV *> &Subscripts,
-    const SCEV *ElementSize) {
-  const SCEV *Offset = SE.removePointerBase(AccessFn);
-  if (!delinearizeFixedSizeArray(SE, Offset, Subscripts, Sizes, ElementSize)) {
-    Sizes.clear();
-    return false;
-  }
-
-  // We expect Sizes and Subscipts have the same number of elements, and the
-  // last element of Sizes is ElementSize. It is for ensuring consistency with
-  // the load/store instruction being analyzed. It is not needed for further
-  // analysis.
-  // TODO: Maybe this property should be enforced in delinearizeFixedSizeArray.
-#ifndef NDEBUG
-  assert(!Sizes.empty() && Subscripts.size() == Sizes.size() &&
-         "Inconsistent length of Sizes and Subscripts");
-  Type *WideTy =
-      SE.getWiderType(ElementSize->getType(), Sizes.back()->getType());
-  const SCEV *ElemSizeExt = SE.getNoopOrZeroExtend(ElementSize, WideTy);
-  const SCEV *LastSizeExt = SE.getNoopOrZeroExtend(Sizes.back(), WideTy);
-  assert(ElemSizeExt == LastSizeExt && "Unexpected last element of Sizes");
-#endif
-
-  Sizes.pop_back();
-  return true;
-}
-
 bool IndexedReference::delinearize(const LoopInfo &LI) {
   assert(Subscripts.empty() && "Subscripts should be empty");
   assert(Sizes.empty() && "Sizes should be empty");
@@ -404,21 +376,20 @@ bool IndexedReference::delinearize(const LoopInfo &LI) {
     }
 
     bool IsFixedSize = false;
+    AccessFn = SE.getMinusSCEV(AccessFn, BasePointer);
+
     // Try to delinearize fixed-size arrays.
-    if (tryDelinearizeFixedSize(AccessFn, Subscripts, ElemSize)) {
+    if (delinearizeFixedSizeArray(SE, AccessFn, Subscripts, Sizes, ElemSize)) {
       IsFixedSize = true;
-      // The last element of Sizes is the element size.
-      Sizes.push_back(ElemSize);
       LLVM_DEBUG(dbgs().indent(2) << "In Loop '" << L->getName()
                                   << "', AccessFn: " << *AccessFn << "\n");
     }
 
-    AccessFn = SE.getMinusSCEV(AccessFn, BasePointer);
-
     // Try to delinearize parametric-size arrays.
     if (!IsFixedSize) {
       LLVM_DEBUG(dbgs().indent(2) << "In Loop '" << L->getName()
                                   << "', AccessFn: " << *AccessFn << "\n");
+      Sizes.clear();
       llvm::delinearize(SE, AccessFn, Subscripts, Sizes,
                         SE.getElementSize(&StoreOrLoadInst));
     }


        


More information about the llvm-commits mailing list