[Mlir-commits] [mlir] [MLIR][SCF] Support permutation-based parallel loop fusion (PR #203207)

Ivan Butygin llvmlistbot at llvm.org
Fri Jun 12 02:01:01 PDT 2026


Hardcode84 wrote:

Also, crashes on loops with reductions
```mlir
func.func @fuse_interchanged_reductions(
    %A: memref<2x3xf32>, %B: memref<2x3xf32>) -> (f32, f32) {
  %c0 = arith.constant 0 : index
  %c1 = arith.constant 1 : index
  %c2 = arith.constant 2 : index
  %c3 = arith.constant 3 : index
  %init1 = arith.constant 1.0 : f32
  %init2 = arith.constant 2.0 : f32

  %res1 = scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c3)
      step (%c1, %c1) init(%init1) -> f32 {
    %A_elem = memref.load %A[%i, %j] : memref<2x3xf32>
    scf.reduce(%A_elem : f32) {
    ^bb0(%lhs: f32, %rhs: f32):
      %1 = arith.addf %lhs, %rhs : f32
      scf.reduce.return %1 : f32
    }
  }

  %res2 = scf.parallel (%j2, %i2) = (%c0, %c0) to (%c3, %c2)
      step (%c1, %c1) init(%init2) -> f32 {
    %B_elem = memref.load %B[%i2, %j2] : memref<2x3xf32>
    scf.reduce(%B_elem : f32) {
    ^bb0(%lhs: f32, %rhs: f32):
      %1 = arith.mulf %lhs, %rhs : f32
      scf.reduce.return %1 : f32
    }
  }

  return %res1, %res2 : f32, f32
}
```

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


More information about the Mlir-commits mailing list