[PATCH] D75599: [mlir] support conversion of parallel reduction loops to std

Alexander Belyaev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 06:44:37 PST 2020


pifon2a accepted this revision.
pifon2a added a comment.
This revision is now accepted and ready to land.

Thank you for doing that!



================
Comment at: mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp:284
+  auto range = parallelOp.initVals();
+  iterArgs.assign(range.begin(), range.end());
+  bool first = true;
----------------
will this work? 
```
SmallVector<Value, 4> iterArgs = llvm::to_vector(parallelOp.initVals());
```


================
Comment at: mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp:311
+    }
+    first = false;
+
----------------
nit:
```

    if (first) {
      // Store the results of the outermost loop that will be used to replace
      // the results of the parallel loop when it is fully rewritten.
      loopResults.assign(forOp.result_begin(), forOp.result_end());
      first = false;
      continue;
    } 
    // A loop is constructed with an empty "yield" terminator by default.
    // Replace it with another "yield" that forwards the results of the nested
    // loop to the parent loop. We need to explicitly make sure the new
    // terminator is the last operation in the block because further transfoms
    // rely on this.
    rewriter.setInsertionPointToEnd(rewriter.getInsertionBlock());
    rewriter.replaceOpWithNewOp<YieldOp>(
        rewriter.getInsertionBlock()->getTerminator(), forOp.getResults());
 ```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75599/new/

https://reviews.llvm.org/D75599





More information about the llvm-commits mailing list