[MLIR][Affine-loop-fusion] Fix a bug in affine-loop-fusion pass when there are non...
authorTung D. Le <tung@jp.ibm.com>
Wed, 24 Jun 2020 16:56:05 +0000 (22:26 +0530)
committerUday Bondhugula <uday@polymagelabs.com>
Fri, 26 Jun 2020 12:56:42 +0000 (18:26 +0530)
commit2b5d1776ffad2614756ef059d64b957c7731e7be
treebea7b181da49a3a5659c2fcec9dd1cfd0336af74
parent41eb63929183c0913886c407b925f1716234cf8e
[MLIR][Affine-loop-fusion] Fix a bug in affine-loop-fusion pass when there are non-affine operations

When there is a mix of affine load/store and non-affine operations (e.g. std.load, std.store),
affine-loop-fusion ignores the present of non-affine ops, thus changing the program semantics.

E.g. we have a program of three affine loops operating on the same memref in which one of them uses std.load and std.store, as follows.
```
affine.for
  affine.store %1
affine.for
  std.load %1
  std.store %1
affine.for
  affine.load %1
  affine.store %1
```
affine-loop-fusion will produce the following result which changed the program semantics:
```
affine.for
  std.load %1
  std.store %1
affine.for
  affine.store %1
  affine.load %1
  affine.store %1
```

This patch is to fix the above problem by checking non-affine users of the memref that are between the source and destination nodes of interest.

Differential Revision: https://reviews.llvm.org/D82158
mlir/lib/Transforms/LoopFusion.cpp
mlir/test/Transforms/loop-fusion.mlir