[Mlir-commits] [mlir] [MLIR][SCF] Handle commuted indices in parallel loop fusion (PR #219665)
purnima shrivastava
llvmlistbot at llvm.org
Mon Aug 31 05:01:45 PDT 2026
================
@@ -1761,3 +1761,33 @@ func.func @do_not_fuse_distinct_dynamic_bounds(%A: memref<16xf32>,
// CHECK-LABEL: func @do_not_fuse_distinct_dynamic_bounds
// CHECK: scf.parallel
// CHECK: scf.parallel
+
+// -----
+
+func.func @fuse_commuted_indices(%arg0: memref<32xf32>,
+ %arg1: memref<32xf32>) {
+ %c0 = arith.constant 0 : index
+ %c1 = arith.constant 1 : index
+ %c16 = arith.constant 16 : index
+ %cst = arith.constant 3.000000e+00 : f32
+
+ scf.parallel (%i) = (%c0) to (%c16) step (%c1) {
+ %index = arith.addi %i, %c1 : index
+ memref.store %cst, %arg0[%index] : memref<32xf32>
+ scf.reduce
+ }
+
+ scf.parallel (%i) = (%c0) to (%c16) step (%c1) {
+ %index = arith.addi %c1, %i : index
----------------
purnima-nlp wrote:
@joker-eph
Thanks, that makes sense. I agree that the constant-on-the-left case should be handled by canonicalization rather than adding complexity to the fusion analysis.
I’ll check whether the issue still reproduces after canonicalization using a dynamic, non-constant offset (`%iv + %offset` versus `%offset + %iv`). If it does, I’ll update the test to use that stronger case; otherwise, I’ll reconsider the approach.
https://github.com/llvm/llvm-project/pull/219665
More information about the Mlir-commits
mailing list