[PATCH] D79502: [mlir] Support partial folding of affine.min/max

Nicolas Vasilache via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 14:09:33 PDT 2020


nicolasvasilache accepted this revision.
nicolasvasilache added inline comments.


================
Comment at: mlir/lib/Dialect/Affine/IR/AffineOps.cpp:2107
+
+  results.reserve(map.getNumResults());
+  for (AffineExpr expr : map.getResults()) {
----------------
How about a 2 steps impl?

```
if (llvm::any_of(...))
  return failure();
auto range = llvm::map_range();
results.assign(range.begin(), range.end());
``` 

I'd say the readability improvements are worth it, you choose.


================
Comment at: mlir/lib/Dialect/Affine/IR/AffineOps.cpp:2162
+  // If some of the map results are not constant, try changing the map in-place.
+  SmallVector<int64_t, 2> results;
+  if (failed(extractIntegerResults(foldedMap, results))) {
----------------
andydavis1 wrote:
> Seems like this block of code could be shared with AffineMin::Fold
Or have the whole impl factored out and just take either `std::min/max_element` as a parameter?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79502





More information about the llvm-commits mailing list