Issue 156421
Summary [MLIR][Affine] Missed sibling fusion opportunity
Labels mlir:affine
Assignees bondhugula
Reporter bondhugula
    Fusion of nests like these is being missed. There is reuse on %0 here, and sibling fusion is supposed to fuse this.

```
func.func @disjoint_stores(%0: memref<8xf32>) {
  %alloc_1 = memref.alloc() : memref<16xf32>
  affine.for %arg2 = 0 to 8 {
    %2 = affine.load %0[%arg2] : memref<8xf32>
 affine.store %2, %alloc_1[%arg2] : memref<16xf32>
  }
  affine.for %arg2 = 0 to 8 {
    %2 = affine.load %0[%arg2] : memref<8xf32>
    %3 = arith.negf %2 : f32
    affine.store %3, %alloc_1[%arg2 + 8] : memref<16xf32>
  }
 return
}
```
```
$ bin/mlir-opt -affine-loop-fusion='mode=sibling' sib.mlir
  func.func @disjoint_stores(%arg0: memref<8xf32>) {
    %alloc = memref.alloc() : memref<16xf32>
    affine.for %arg1 = 0 to 8 {
      %0 = affine.load %arg0[%arg1] : memref<8xf32>
      affine.store %0, %alloc[%arg1] : memref<16xf32>
    }
    affine.for %arg1 = 0 to 8 {
 %0 = affine.load %arg0[%arg1] : memref<8xf32>
      %1 = arith.negf %0 : f32
      affine.store %1, %alloc[%arg1 + 8] : memref<16xf32>
    }
 return
  }
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to