[Mlir-commits] [mlir] [mlir][SCF] Add support for peeling the first iteration out of the loop (PR #74015)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Dec 7 15:03:20 PST 2023


MaheshRavishankar wrote:

> Could you add some description to the commit? What is the intent here? Is it peeling only one iteration? Why not multiple ones?

Yeah it would be useful to add some more description, but let me provide some context. Peeling only one-iteration has some benefits w.r.t fusion, for example

```
%0 =linalg.fill 
%result = scf.for ... (%arg0 = %0) {
  %1 = linalg.matmul ins(...) outs(%arg0) -> ...
  scf.yield %1 
} -> 
```

Here the fill is by itself. If we peel the first iteration we get

```
%0 = linalg.fill
%1 = linalg.matmul ins(...) outs(%0) -> ...
%result = scf.for ... (%arg0 = %1) {
  %2 = linalg.matmul ins(...) outs(%arg0) -> ...
  scf.yield %2
}
```

So now you can fuse the fill with matmul. This is useful in some cases.

If we need to peel many iterations this specific thing doesnt apply. Not to say it is not worth peeling the first "n" iterations. I would say we  start with peeling one iteration now, and then think about generalizing it to peeling a subset of iterations (though from my perspective, I see little use of peeling more than one iteration...)

https://github.com/llvm/llvm-project/pull/74015


More information about the Mlir-commits mailing list