[polly] [Polly] Distribute the innermost point loop of tile over its statements (PR #225844)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 04:43:55 PDT 2026


================
@@ -548,6 +576,161 @@ ScheduleTreeOptimizer::applyTileBandOpt(isl::schedule_node Node) {
   return Node;
 }
 
+isl::schedule_node
+ScheduleTreeOptimizer::distributeInnermostLoop(isl::schedule_node Node,
+                                               const Dependences *D) {
+  // This runs within a quota of isl operations. Every isl result that is used
+  // in a condition, iterated over or dereferenced is checked for an error
+  // first; in that case the band is left as it is.
+  if (Node.is_null() || !isSimpleInnermostBand(Node))
+    return Node;
+
+  isl::union_set Domain = Node.get_domain();
+  if (Domain.is_null())
+    return Node;
+  isl::set_list DomainList = Domain.get_set_list();
+  if (DomainList.is_null())
+    return Node;
+  SmallVector<std::pair<ScopStmt *, isl::set>, 8> Stmts;
+  for (isl::set Set : DomainList) {
+    isl::id Id = Set.get_tuple_id();
+    if (Id.is_null())
+      return Node;
+    auto *Stmt = static_cast<ScopStmt *>(Id.get_user());
+    if (!Stmt)
+      return Node;
+    Stmts.push_back({Stmt, Set});
+  }
+  unsigned NumStmts = Stmts.size();
+  if (NumStmts < 2)
+    return Node;
+
+  // Number the statements in the order of Scop::Stmts, so that the result does
+  // not depend on the order in which isl lists them.
+  DenseMap<const ScopStmt *, unsigned> ScopOrder;
+  for (const ScopStmt &Stmt : *Stmts.front().first->getParent())
----------------
Meinersbur wrote:

Prefer storing the `Scop*` object in a variable instead of complicated-statement-that-doesnt-tell-the-ready what-it-is-trying-to-get. Even better: pass the Scop by argument.

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


More information about the llvm-commits mailing list