[llvm] [Delinearization] Extract array dimensions from global declarations (PR #175158)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 9 04:07:16 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm/Analysis/Delinearization.h llvm/lib/Analysis/Delinearization.cpp llvm/lib/Analysis/DependenceAnalysis.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Analysis/Delinearization.h b/llvm/include/llvm/Analysis/Delinearization.h
index a616fbb03..4f46d93e8 100644
--- a/llvm/include/llvm/Analysis/Delinearization.h
+++ b/llvm/include/llvm/Analysis/Delinearization.h
@@ -47,7 +47,6 @@ void computeAccessFunctions(ScalarEvolution &SE, const SCEV *Expr,
                             SmallVectorImpl<const SCEV *> &Sizes,
                             const SCEV *ElementSize = nullptr);
 
-
 bool delinearizeUsingArrayInfo(ScalarEvolution &SE, const SCEV *AccessFn,
                                SmallVectorImpl<const SCEV *> &Subscripts,
                                SmallVectorImpl<const SCEV *> &Sizes,
diff --git a/llvm/lib/Analysis/Delinearization.cpp b/llvm/lib/Analysis/Delinearization.cpp
index cd0481c93..55f193939 100644
--- a/llvm/lib/Analysis/Delinearization.cpp
+++ b/llvm/lib/Analysis/Delinearization.cpp
@@ -428,16 +428,14 @@ void llvm::computeAccessFunctions(ScalarEvolution &SE, const SCEV *Expr,
 //   be easy as we would need to emit and pick up meta-data (or something
 //   similar).
 //
-static bool
-extractArrayInfoFromGlobal(ScalarEvolution &SE, Value *BasePtr,
-                           SmallVectorImpl<const SCEV *> &Sizes,
-                           const SCEV *ElementSize) {
+static bool extractArrayInfoFromGlobal(ScalarEvolution &SE, Value *BasePtr,
+                                       SmallVectorImpl<const SCEV *> &Sizes,
+                                       const SCEV *ElementSize) {
   // Clear output vector.
   Sizes.clear();
 
-  LLVM_DEBUG(
-      dbgs() << "extractArrayInfoFromGlobal called with BasePtr: "
-             << *BasePtr << "\n");
+  LLVM_DEBUG(dbgs() << "extractArrayInfoFromGlobal called with BasePtr: "
+                    << *BasePtr << "\n");
 
   // Distinguish between simple array accesses and complex pointer arithmetic,
   // i.e. check if this is a simple array access pattern:
@@ -492,8 +490,8 @@ extractArrayInfoFromGlobal(ScalarEvolution &SE, Value *BasePtr,
   Sizes.push_back(ElementSize);
 
   LLVM_DEBUG({
-    dbgs() << "Extracted array info from global for base pointer "
-           << *BasePtr << "\n";
+    dbgs() << "Extracted array info from global for base pointer " << *BasePtr
+           << "\n";
     dbgs() << "Dimensions: ";
     for (const SCEV *Size : Sizes)
       dbgs() << *Size << " ";
@@ -983,7 +981,7 @@ void printDelinearization(raw_ostream &O, Function *F, LoopInfo *LI,
     SmallVector<const SCEV *, 3> Subscripts, Sizes;
 
     auto IsDelinearizationFailed = [&]() {
-     return Subscripts.empty() || Sizes.empty();
+      return Subscripts.empty() || Sizes.empty();
     };
 
     delinearize(*SE, AccessFn, Subscripts, Sizes, SE->getElementSize(&Inst));
@@ -1023,8 +1021,7 @@ void printDelinearization(raw_ostream &O, Function *F, LoopInfo *LI,
     O << "ArrayRef";
     for (int i = 0; i < NumSubscripts; i++)
       O << "[" << *Subscripts[i] << "]";
-    O << "\n"; 
-
+    O << "\n";
   }
 }
 
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index b6ee848eb..0a5af2739 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -3363,10 +3363,12 @@ bool DependenceInfo::tryDelinearizeFixedSize(
   const SCEV *ElemSize = SE->getElementSize(Src);
   assert(ElemSize == SE->getElementSize(Dst) && "Different element sizes");
   SmallVector<const SCEV *, 4> SrcSizes, DstSizes;
-  if (!delinearizeFixedSizeArray(*SE, SrcAccessFn /*SE->removePointerBase(SrcAccessFn)*/,
-                                 SrcSubscripts, SrcSizes, ElemSize) ||
-      !delinearizeFixedSizeArray(*SE, DstAccessFn /*SE->removePointerBase(DstAccessFn)*/,
-                                 DstSubscripts, DstSizes, ElemSize))
+  if (!delinearizeFixedSizeArray(
+          *SE, SrcAccessFn /*SE->removePointerBase(SrcAccessFn)*/,
+          SrcSubscripts, SrcSizes, ElemSize) ||
+      !delinearizeFixedSizeArray(
+          *SE, DstAccessFn /*SE->removePointerBase(DstAccessFn)*/,
+          DstSubscripts, DstSizes, ElemSize))
     return false;
 
   // Check that the two size arrays are non-empty and equal in length and

``````````

</details>


https://github.com/llvm/llvm-project/pull/175158


More information about the llvm-commits mailing list