diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -768,7 +768,8 @@ SmallVector effects; effectInterface.getEffects(effects); if (llvm::any_of(effects, [](const MemoryEffects::EffectInstance &it) { - return isa(it.getEffect()); + return isa( + it.getEffect()); })) { Node node(nextNodeId++, &op); nodes.insert({node.id, node}); diff --git a/mlir/test/Transforms/loop-fusion.mlir b/mlir/test/Transforms/loop-fusion.mlir --- a/mlir/test/Transforms/loop-fusion.mlir +++ b/mlir/test/Transforms/loop-fusion.mlir @@ -2835,3 +2835,27 @@ return } + +// ----- +func @should_not_fuse_due_to_dealloc(%arg0: memref<16xf32>){ + %A = alloc() : memref<16xf32> + %C = alloc() : memref<16xf32> + %cst_1 = constant 1.000000e+00 : f32 + affine.for %arg1 = 0 to 16 { + %a = affine.load %arg0[%arg1] : memref<16xf32> + affine.store %a, %A[%arg1] : memref<16xf32> + affine.store %a, %C[%arg1] : memref<16xf32> + } + dealloc %C : memref<16xf32> + %B = alloc() : memref<16xf32> + affine.for %arg1 = 0 to 16 { + %a = affine.load %A[%arg1] : memref<16xf32> + %b = addf %cst_1, %a : f32 + affine.store %b, %B[%arg1] : memref<16xf32> + } + dealloc %A : memref<16xf32> + return +} +// CHECK-LABEL: func @should_not_fuse_due_to_dealloc +// CHECK: affine.for +// CHECK: affine.for