[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())
+ ScopOrder.insert({&Stmt, ScopOrder.size()});
+ llvm::sort(Stmts, [&](const auto &A, const auto &B) {
+ return ScopOrder.lookup(A.first) < ScopOrder.lookup(B.first);
+ });
+ DenseMap<const ScopStmt *, unsigned> StmtIndex;
+ for (auto [Idx, Stmt] : enumerate(Stmts))
+ StmtIndex[Stmt.first] = Idx;
----------------
Meinersbur wrote:
Could you add a comment on why not using the `ScopOrder` Idx already available?
https://github.com/llvm/llvm-project/pull/225844
More information about the llvm-commits
mailing list