[all-commits] [llvm/llvm-project] a4b227: [mlir] Fix loop unrolling: properly replace the ar...

grosul1 via All-commits all-commits at lists.llvm.org
Wed May 11 18:55:05 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a4b227c28aba3487ffbfde12fb59fdb69a6b5bfe
      https://github.com/llvm/llvm-project/commit/a4b227c28aba3487ffbfde12fb59fdb69a6b5bfe
  Author: grosul1 <grosul at google.com>
  Date:   2022-05-12 (Thu, 12 May 2022)

  Changed paths:
    M mlir/lib/Dialect/SCF/Utils/Utils.cpp
    M mlir/test/Dialect/SCF/loop-unroll.mlir

  Log Message:
  -----------
  [mlir] Fix loop unrolling: properly replace the arguments of the epilogue loop.

Using "replaceUsesOfWith" is incorrect because the same initializer value may appear multiple times.

For example, if the epilogue is needed when this loop is unrolled
```
%x:2 = scf.for ... iter_args(%arg1 = %c1, %arg2 = %c1) {
  ...
}
```
then both epilogue's arguments will be incorrectly renamed to use the same result index (note #1 in both cases):
```
%x_unrolled:2 = scf.for ... iter_args(%arg1 = %c1, %arg2 = %c1) {
  ...
}
%x_epilogue:2 = scf.for ... iter_args(%arg1 = %x_unrolled#1, %arg2 = %x_unrolled#1) {
  ...
}
```




More information about the All-commits mailing list