[flang] [llvm] [mlir] [flang][OpenMP] Enable tiling (PR #143715)
Jan Leyonberg via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 9 08:19:28 PDT 2025
================
@@ -595,9 +660,43 @@ bool collectLoopRelatedInfo(
if (auto *clause =
ClauseFinder::findUniqueClause<omp::clause::Collapse>(clauses)) {
collapseValue = evaluate::ToInt64(clause->v).value();
- found = true;
+ numCollapse = collapseValue;
+ }
+
+ // Collect sizes from tile directive if present
+ std::int64_t sizesLengthValue = 0l;
+ if (auto *ompCons{eval.getIf<parser::OpenMPConstruct>()}) {
+ if (auto *ompLoop{std::get_if<parser::OpenMPLoopConstruct>(&ompCons->u)}) {
+ const auto &nestedOptional =
+ std::get<std::optional<parser::NestedConstruct>>(ompLoop->t);
+ assert(nestedOptional.has_value() &&
+ "Expected a DoConstruct or OpenMPLoopConstruct");
+ const auto *innerConstruct =
+ std::get_if<common::Indirection<parser::OpenMPLoopConstruct>>(
+ &(nestedOptional.value()));
+ if (innerConstruct) {
+ const auto &innerLoopDirective = innerConstruct->value();
+ const auto &innerBegin =
+ std::get<parser::OmpBeginLoopDirective>(innerLoopDirective.t);
+ const auto &innerDirective =
+ std::get<parser::OmpLoopDirective>(innerBegin.t).v;
+
+ if (innerDirective == llvm::omp::Directive::OMPD_tile) {
+ // Get the size values from parse tree and convert to a vector
+ const auto &innerClauseList{
+ std::get<parser::OmpClauseList>(innerBegin.t)};
+ for (const auto &clause : innerClauseList.v)
+ if (const auto tclause{
+ std::get_if<parser::OmpClause::Sizes>(&clause.u)}) {
+ sizesLengthValue = tclause->v.size();
+ break;
+ }
+ }
+ }
+ }
}
----------------
jsjodin wrote:
I created a helper function with a callback so I didn't have to get the context in the other use.
https://github.com/llvm/llvm-project/pull/143715
More information about the llvm-commits
mailing list