[mlir][scf] Simplify affine.min ops after loop peeling
authorMatthias Springer <springerm@google.com>
Thu, 19 Aug 2021 08:08:21 +0000 (17:08 +0900)
committerMatthias Springer <springerm@google.com>
Thu, 19 Aug 2021 08:24:53 +0000 (17:24 +0900)
commit8e8b70aa8479e44c5a9a09ea832857d51f3faa6d
treeebc217447120c34235d1d839818c04df27879029
parent3330b2532f50c5df0d6188fc766812b6132c1981
[mlir][scf] Simplify affine.min ops after loop peeling

Simplify affine.min ops, enabling various other canonicalizations inside the peeled loop body.

affine.min ops such as:
```
map = affine_map<(d0)[s0, s1] -> (s0, -d0 + s1)>
%r = affine.min #affine.min #map(%iv)[%step, %ub]
```
are rewritten them into (in the case the peeled loop):
```
%r = %step
```

To determine how an affine.min op should be rewritten and to prove its correctness, FlatAffineConstraints is utilized.

Differential Revision: https://reviews.llvm.org/D107222
mlir/include/mlir/Analysis/AffineStructures.h
mlir/include/mlir/Dialect/SCF/Transforms.h
mlir/include/mlir/IR/AffineExpr.h
mlir/include/mlir/IR/AffineMap.h
mlir/lib/Analysis/AffineStructures.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
mlir/lib/IR/AffineExpr.cpp
mlir/test/Dialect/SCF/for-loop-peeling.mlir
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel