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

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


================
@@ -1660,6 +1687,30 @@ 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);
+    } else if (clause.id == llvm::omp::Clause::OMPC_sizes) {
+      // This case handles the stand-alone tiling construct
+      const auto &sizes = std::get<clause::Sizes>(clause.u);
+      llvm::SmallVector<int64_t> sizeValues;
+      for (auto &size : sizes.v) {
+        int64_t sizeValue = evaluate::ToInt64(size).value();
+        sizeValues.push_back(sizeValue);
+      }
+      clauseOps.tileSizes = sizeValues;
----------------
skatrak wrote:

I think this should go into a new `ClauseProcessor::processTileSizes` function. Also, like it's done at the beginning of the function for the call to `cp.processCollapse`, we should first check if this clause has been host evaluated and only evaluate it here if it hasn't. I imagine this doesn't make a difference right now as long as tile sizes are a constant attribute, but if we ever passed a runtime value this would break otherwise.

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


More information about the llvm-commits mailing list