[polly] [Polly][NFC] Convert ScopBuilder::getPwAff() to isl++ (PR #190458)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 4 06:08:02 PDT 2026


https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/190458

None

>From c378e709cd8fd520c4bb04e10086ec0bc8343bb7 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Sat, 4 Apr 2026 15:06:37 +0200
Subject: [PATCH] [Polly][NFC] Convert ScopBuilder::getPwAff() to isl++

---
 polly/include/polly/ScopBuilder.h  |  7 ++++---
 polly/lib/Analysis/ScopBuilder.cpp | 29 ++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/polly/include/polly/ScopBuilder.h b/polly/include/polly/ScopBuilder.h
index dc29dcb944b7f..1e433800b5903 100644
--- a/polly/include/polly/ScopBuilder.h
+++ b/polly/include/polly/ScopBuilder.h
@@ -260,9 +260,10 @@ class ScopBuilder final {
   ///
   /// Note that this function will also adjust the invalid context
   /// accordingly.
-  __isl_give isl_pw_aff *
-  getPwAff(BasicBlock *BB, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
-           const SCEV *E, bool NonNegative = false, bool IsInsideDomain = true);
+  isl::pw_aff getPwAff(BasicBlock *BB,
+                       DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
+                       const SCEV *E, bool NonNegative = false,
+                       bool IsInsideDomain = true);
 
   /// Create equivalence classes for required invariant accesses.
   ///
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index 8a143645a3198..6a39c1f1c5432 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -333,14 +333,14 @@ isl::set ScopBuilder::adjustDomainDimensions(isl::set Dom, Loop *OldL,
   return Dom;
 }
 
-__isl_give isl_pw_aff *
+isl::pw_aff
 ScopBuilder::getPwAff(BasicBlock *BB,
                       DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
                       const SCEV *E, bool NonNegative, bool IsInsideDomain) {
   PWACtx PWAC =
       scop->getPwAff(E, BB, NonNegative, &RecordedAssumptions, IsInsideDomain);
   InvalidDomainMap[BB] = InvalidDomainMap[BB].unite(PWAC.second);
-  return PWAC.first.release();
+  return std::move(PWAC.first);
 }
 
 /// Build condition sets for unsigned ICmpInst(s).
@@ -359,10 +359,12 @@ __isl_give isl_set *ScopBuilder::buildUnsignedConditionSets(
   // Do not take NonNeg assumption on TestVal
   // as it might have MSB (Sign bit) set.
   isl_pw_aff *TestVal = getPwAff(BB, InvalidDomainMap, SCEV_TestVal,
-                                 /*NonNegative=*/false, IsInsideDomain);
+                                 /*NonNegative=*/false, IsInsideDomain)
+                            .release();
   // Take NonNeg assumption on UpperBound.
   isl_pw_aff *UpperBound = getPwAff(BB, InvalidDomainMap, SCEV_UpperBound,
-                                    /*NonNegative=*/true, IsInsideDomain);
+                                    /*NonNegative=*/true, IsInsideDomain)
+                               .release();
 
   // 0 <= TestVal
   isl_set *First =
@@ -390,7 +392,8 @@ bool ScopBuilder::buildConditionSets(
 
   isl_pw_aff *LHS, *RHS;
   LHS = getPwAff(BB, InvalidDomainMap, SE.getSCEVAtScope(Condition, L),
-                 /*NonNegative=*/false, IsInsideDomain);
+                 /*NonNegative=*/false, IsInsideDomain)
+            .release();
 
   unsigned NumSuccessors = SI->getNumSuccessors();
   ConditionSets.resize(NumSuccessors);
@@ -399,7 +402,8 @@ bool ScopBuilder::buildConditionSets(
     ConstantInt *CaseValue = Case.getCaseValue();
 
     RHS = getPwAff(BB, InvalidDomainMap, SE.getSCEV(CaseValue),
-                   /*NonNegative=*/false, IsInsideDomain);
+                   /*NonNegative=*/false, IsInsideDomain)
+              .release();
     isl_set *CaseConditionSet =
         buildConditionSet(ICmpInst::ICMP_EQ, isl::manage_copy(LHS),
                           isl::manage(RHS))
@@ -432,9 +436,11 @@ bool ScopBuilder::buildConditionSets(
     const SCEV *RHSSCEV = SE.getZero(LHSSCEV->getType());
     bool NonNeg = false;
     isl_pw_aff *LHS =
-        getPwAff(BB, InvalidDomainMap, LHSSCEV, NonNeg, IsInsideDomain);
+        getPwAff(BB, InvalidDomainMap, LHSSCEV, NonNeg, IsInsideDomain)
+            .release();
     isl_pw_aff *RHS =
-        getPwAff(BB, InvalidDomainMap, RHSSCEV, NonNeg, IsInsideDomain);
+        getPwAff(BB, InvalidDomainMap, RHSSCEV, NonNeg, IsInsideDomain)
+            .release();
     ConsequenceCondSet = buildConditionSet(ICmpInst::ICMP_SLE, isl::manage(LHS),
                                            isl::manage(RHS))
                              .release();
@@ -518,9 +524,10 @@ bool ScopBuilder::buildConditionSets(
           /*IsStrictUpperBound=*/false, IsInsideDomain);
       break;
     default:
-      LHS = getPwAff(BB, InvalidDomainMap, LeftOperand, NonNeg, IsInsideDomain);
-      RHS =
-          getPwAff(BB, InvalidDomainMap, RightOperand, NonNeg, IsInsideDomain);
+      LHS = getPwAff(BB, InvalidDomainMap, LeftOperand, NonNeg, IsInsideDomain)
+                .release();
+      RHS = getPwAff(BB, InvalidDomainMap, RightOperand, NonNeg, IsInsideDomain)
+                .release();
       ConsequenceCondSet = buildConditionSet(ICond->getPredicate(),
                                              isl::manage(LHS), isl::manage(RHS))
                                .release();



More information about the llvm-commits mailing list