[Mlir-commits] [mlir] [MLIR][SCF] Add canonicalization pattern to fold away iter args of scf.forall (PR #90189)

Matthias Springer llvmlistbot at llvm.org
Sat May 4 06:34:06 PDT 2024


================
@@ -1415,6 +1416,31 @@ InParallelOp ForallOp::getTerminator() {
   return cast<InParallelOp>(getBody()->getTerminator());
 }
 
+FailureOr<SubsetInsertionOpInterface>
+ForallOp::getStoreOpUser(BlockArgument bbArg) {
+  Value::user_range users = bbArg.getUsers();
+  bool foundUser = false;
+  SubsetInsertionOpInterface storeOp = nullptr;
+  for (Operation *userOp : users) {
+    if (auto parallelInsertSliceOp =
+            dyn_cast<tensor::ParallelInsertSliceOp>(userOp);
+        parallelInsertSliceOp && isa<InParallelOp>(userOp->getParentOp())) {
+      // Return failure in case we find more than one user of the block argument
+      // within scf.forall.in_parallel.
+      if (foundUser) {
+        return failure();
+      }
+      storeOp = cast<SubsetInsertionOpInterface>(userOp);
----------------
matthias-springer wrote:

What I meant is we don’t need the SubsetInsertionOpInterface in this PR at all. It should be sufficient to check whether the bbarg is used in the terminator region (as a destination) or not. No need to analyze the loop body.

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


More information about the Mlir-commits mailing list