[Mlir-commits] [mlir] [mlir][OpenMP] Fix teams reduction assert with sibling distributes (PR #191475)

Sergio Afonso llvmlistbot at llvm.org
Tue Apr 14 04:35:33 PDT 2026


================
@@ -1981,13 +1981,25 @@ convertOmpSingle(omp::SingleOp &singleOp, llvm::IRBuilderBase &builder,
   return success();
 }
 
-static bool teamsReductionContainedInDistribute(omp::TeamsOp teamsOp) {
+static omp::DistributeOp
+getDistributeCapturingTeamsReduction(omp::TeamsOp teamsOp) {
+  // Early return if we found more than one distribute op or if we can't find
+  // any distribute op in the teams region.
+  omp::DistributeOp distOp;
+  WalkResult walk = teamsOp.getRegion().walk([&](omp::DistributeOp op) {
+    if (distOp)
+      return WalkResult::interrupt();
+    distOp = op;
+    return WalkResult::advance();
----------------
skatrak wrote:

I don't think there's a reason to go over the contents of an `omp.distribute` region here.
```suggestion
    return WalkResult::skip();
```

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


More information about the Mlir-commits mailing list