[flang-commits] [flang] [flang][OpenMP] Map `teams loop` to `teams distribute` when required. (PR #127489)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Thu Feb 20 03:54:27 PST 2025


================
@@ -118,6 +119,56 @@ class GenericLoopConversionPattern
     return result;
   }
 
+  /// Checks whether a `teams loop` construct can be rewriten to `teams
+  /// distribute parallel do` or it has to be converted to `teams distribute`.
+  ///
+  /// This checks similar constrains to what is checked by `TeamsLoopChecker` in
+  /// SemaOpenMP.cpp in clang.
+  static bool teamsLoopCanBeParallelFor(mlir::omp::LoopOp loopOp) {
+    bool canBeParallelFor = true;
+    loopOp.walk([&](mlir::omp::LoopOp nestedLoopOp) {
+      if (nestedLoopOp == loopOp)
+        mlir::WalkResult::advance();
----------------
skatrak wrote:

Regardless of the bigger optional comment, this is missing a `return`.
```suggestion
        return mlir::WalkResult::advance();
```

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


More information about the flang-commits mailing list