[flang-commits] [flang] [llvm] [mlir] [flang][OpenMP] Enable tiling (PR #143715)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Wed Aug 27 05:57:54 PDT 2025


================
@@ -1660,6 +1687,20 @@ genLoopNestClauses(lower::AbstractConverter &converter,
     cp.processCollapse(loc, eval, clauseOps, iv);
 
   clauseOps.loopInclusive = converter.getFirOpBuilder().getUnitAttr();
+
+  fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
+  for (auto &clause : clauses)
+    if (clause.id == llvm::omp::Clause::OMPC_collapse) {
+      const auto &collapse = std::get<clause::Collapse>(clause.u);
+      int64_t collapseValue = evaluate::ToInt64(collapse.v).value();
+      clauseOps.numCollapse = firOpBuilder.getI64IntegerAttr(collapseValue);
+    }
+
+  llvm::SmallVector<int64_t> sizeValues;
+  auto *ompCons{eval.getIf<parser::OpenMPConstruct>()};
+  collectTileSizesFromOpenMPConstruct(ompCons, sizeValues, semaCtx);
+  if (sizeValues.size() > 0)
+    clauseOps.tileSizes = sizeValues;
----------------
skatrak wrote:

This should be moved to a new `ClauseProcessor::processTile` method and guarded against re-evaluation if it was host-evaluated, the same way it is currently done for `collapse` at the top of this same method. I suppose this won't currently cause an issue as long as tile sizes are constant, but it will break as soon as we introduce variables and we evaluate them in the host.

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


More information about the flang-commits mailing list