[Mlir-commits] [mlir] 689b8a3 - [mlir][scf] Skip ops having results with warning in forall-to-for pass (#175926)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jan 19 15:49:01 PST 2026


Author: Prathamesh Tagore
Date: 2026-01-19T15:48:57-08:00
New Revision: 689b8a3ed4e1f693a3c8029f0d42cbb69a2cf3ae

URL: https://github.com/llvm/llvm-project/commit/689b8a3ed4e1f693a3c8029f0d42cbb69a2cf3ae
DIFF: https://github.com/llvm/llvm-project/commit/689b8a3ed4e1f693a3c8029f0d42cbb69a2cf3ae.diff

LOG: [mlir][scf] Skip ops having results with warning in forall-to-for pass (#175926)

Avoid converting scf.forall ops that have results in forall-to-for pass.
Emit a warning instead of failing the pass, so mlir-opt can still
produce output on mixed IR.

Fixes https://github.com/llvm/llvm-project/issues/174319

Added: 
    

Modified: 
    mlir/lib/Dialect/SCF/Transforms/ForallToFor.cpp
    mlir/test/Dialect/SCF/forall-to-for.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SCF/Transforms/ForallToFor.cpp b/mlir/lib/Dialect/SCF/Transforms/ForallToFor.cpp
index 00bef707fadd3..20a64a3d2b4d7 100644
--- a/mlir/lib/Dialect/SCF/Transforms/ForallToFor.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/ForallToFor.cpp
@@ -30,6 +30,12 @@ mlir::scf::forallToForLoop(RewriterBase &rewriter, scf::ForallOp forallOp,
   OpBuilder::InsertionGuard guard(rewriter);
   rewriter.setInsertionPoint(forallOp);
 
+  if (!forallOp.getOutputs().empty()) {
+    forallOp.emitWarning()
+        << "skipping scf.forall with outputs, currently not supported";
+    return success();
+  }
+
   Location loc = forallOp.getLoc();
   SmallVector<Value> lbs = forallOp.getLowerBound(rewriter);
   SmallVector<Value> ubs = forallOp.getUpperBound(rewriter);

diff  --git a/mlir/test/Dialect/SCF/forall-to-for.mlir b/mlir/test/Dialect/SCF/forall-to-for.mlir
index e7d183fb9d2b5..d917cd1d8d2d4 100644
--- a/mlir/test/Dialect/SCF/forall-to-for.mlir
+++ b/mlir/test/Dialect/SCF/forall-to-for.mlir
@@ -55,3 +55,27 @@ func.func @nested(%ub1: index, %ub2: index, %ub3: index, %ub4: index) {
   }
   return
 }
+
+// -----
+
+// The pass should bail out cleanly and not crash here. `scf.forall` with outputs
+// is not supported, but we should still handle the `forall` op with no results
+// present in the same function.
+
+func.func private @callee(%i: index)
+
+// CHECK-LABEL: @shared_outs
+func.func @shared_outs(%arg0: tensor<1xf32>, %ub: index) -> tensor<1xf32> {
+  // CHECK: %{{.*}} = scf.forall
+  %0 = scf.forall (%i) in (1) shared_outs(%out = %arg0) -> (tensor<1xf32>) {
+    scf.forall.in_parallel {
+      tensor.parallel_insert_slice %out into %out[%i] [1] [1] : tensor<1xf32> into tensor<1xf32>
+    }
+  }
+
+  // CHECK: scf.for
+  scf.forall (%i) in (%ub) {
+    func.call @callee(%i) : (index) -> ()
+  }
+  return %0 : tensor<1xf32>
+}


        


More information about the Mlir-commits mailing list