llvm-project/mlir/lib/Dialect/SCF/Transforms
Anthony Canino 3f429e82d3 Implement an scf.for range folding optimization pass.
In cases where arithmetic (addi/muli) ops are performed on an scf.for loops induction variable with a single use, we can fold those ops directly into the scf.for loop.

For example, in the following code:

```
scf.for %i = %c0 to %arg1 step %c1 {
  %0 = addi %arg2, %i : index
  %1 = muli %0, %c4 : index
  %2 = memref.load %arg0[%1] : memref<?xi32>
  %3 = muli %2, %2 : i32
  memref.store %3, %arg0[%1] : memref<?xi32>
}
```

we can lift `%0` up into the scf.for loop range, as it is the only user of %i:

```
%lb = addi %arg2, %c0 : index
%ub = addi %arg2, %i : index
scf.for %i = %lb to %ub step %c1 {
  %1 = muli %0, %c4 : index
  %2 = memref.load %arg0[%1] : memref<?xi32>
  %3 = muli %2, %2 : i32
  memref.store %3, %arg0[%1] : memref<?xi32>
}
```

Reviewed By: mehdi_amini, ftynse, Anthony

Differential Revision: https://reviews.llvm.org/D104289
2021-06-24 01:07:28 +00:00
..
Bufferize.cpp [mlir][NFC] Remove Standard dialect dependency on MemRef dialect 2021-06-21 17:55:23 +09:00
CMakeLists.txt Implement an scf.for range folding optimization pass. 2021-06-24 01:07:28 +00:00
LoopRangeFolding.cpp Implement an scf.for range folding optimization pass. 2021-06-24 01:07:28 +00:00
LoopSpecialization.cpp
ParallelLoopFusion.cpp
ParallelLoopTiling.cpp [mlir][NFC] Add helper for common pattern of replaceAllUsesExcept 2021-05-13 12:42:10 -07:00
PassDetail.h
StructuralTypeConversions.cpp
Utils.cpp