[all-commits] [llvm/llvm-project] f202d3: [mlir][SCF] Add canonicalization pattern for scf::...
Nicolas Vasilache via All-commits
all-commits at lists.llvm.org
Wed Nov 4 03:37:34 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: f202d32216c64b1ae8853a0506b85674cf52126a
https://github.com/llvm/llvm-project/commit/f202d32216c64b1ae8853a0506b85674cf52126a
Author: Nicolas Vasilache <nicolas.vasilache at gmail.com>
Date: 2020-11-04 (Wed, 04 Nov 2020)
Changed paths:
M mlir/include/mlir/Dialect/SCF/SCFOps.td
M mlir/lib/Dialect/SCF/SCF.cpp
M mlir/test/Dialect/SCF/canonicalize.mlir
Log Message:
-----------
[mlir][SCF] Add canonicalization pattern for scf::For to eliminate yields that just forward.
For instance:
```
func @for_yields_3(%lb : index, %ub : index, %step : index) -> (i32, i32, i32) {
%a = call @make_i32() : () -> (i32)
%b = call @make_i32() : () -> (i32)
%r:3 = scf.for %i = %lb to %ub step %step iter_args(%0 = %a, %1 = %a, %2 = %b) -> (i32, i32, i32) {
%c = call @make_i32() : () -> (i32)
scf.yield %0, %c, %2 : i32, i32, i32
}
return %r#0, %r#1, %r#2 : i32, i32, i32
}
```
Canonicalizes as:
```
func @for_yields_3(%arg0: index, %arg1: index, %arg2: index) -> (i32, i32, i32) {
%0 = call @make_i32() : () -> i32
%1 = call @make_i32() : () -> i32
%2 = scf.for %arg3 = %arg0 to %arg1 step %arg2 iter_args(%arg4 = %0) -> (i32) {
%3 = call @make_i32() : () -> i32
scf.yield %3 : i32
}
return %0, %2, %1 : i32, i32, i32
}
```
Differential Revision: https://reviews.llvm.org/D90745
More information about the All-commits
mailing list