[polly] [Polly] Limit terms used for delinearization (NFCI) (PR #206711)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 04:31:24 PDT 2026


https://github.com/kasuga-fj created https://github.com/llvm/llvm-project/pull/206711

None

>From c12119f2051691672c516fb6739ff78f26fc6d99 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Tue, 30 Jun 2026 11:08:44 +0000
Subject: [PATCH] [Polly] Limit terms used for delinearization (NFCI)

---
 polly/lib/Analysis/ScopDetection.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 2f2ab4149aba2..3908399ff73b6 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -872,7 +872,13 @@ ScopDetection::getDelinearizationTerms(DetectionContext &Context,
     std::vector<const SCEV *> MaxTerms;
     SCEVRemoveMax::rewrite(Pair.second, SE, &MaxTerms);
     if (!MaxTerms.empty()) {
-      Terms.insert(Terms.begin(), MaxTerms.begin(), MaxTerms.end());
+      // Elements in Terms are used for delinearization. So divisions between
+      // the original access function and the elements in Terms can be
+      // performed. Therefore, we only add elements in MaxTerms that have the
+      // same type as the original access function.
+      for (const SCEV *Max : MaxTerms)
+        if (Max->getType() == Pair.second->getType())
+          Terms.push_back(Max);
       continue;
     }
     // In case the outermost expression is a plain add, we check if any of its



More information about the llvm-commits mailing list