Tung D. Le
05c6c648ec
[MLIR] [affine-loop-fusion] Fix a bug about non-result ops in affine-loop-fusion
This patch fixes the following bug when calling --affine-loop-fusion
Input program:
```mlir
func @should_not_fuse_since_top_level_non_affine_non_result_users(
%in0 : memref<32xf32>, %in1 : memref<32xf32>) {
%c0 = constant 0 : index
%cst_0 = constant 0.000000e+00 : f32
affine.for %d = 0 to 32 {
%lhs = affine.load %in0[%d] : memref<32xf32>
%rhs = affine.load %in1[%d] : memref<32xf32>
%add = addf %lhs, %rhs : f32
affine.store %add, %in0[%d] : memref<32xf32>
}
store %cst_0, %in0[%c0] : memref<32xf32>
affine.for %d = 0 to 32 {
%lhs = affine.load %in0[%d] : memref<32xf32>
%rhs = affine.load %in1[%d] : memref<32xf32>
%add = addf %lhs, %rhs: f32
affine.store %add, %in0[%d] : memref<32xf32>
}
return
}
```
call --affine-loop-fusion, we got an incorrect output:
```mlir
func @should_not_fuse_since_top_level_non_affine_non_result_users(%arg0: memref<32xf32>, %arg1: memref<32xf32>) {
%c0 = constant 0 : index
%cst = constant 0.000000e+00 : f32
store %cst, %arg0[%c0] : memref<32xf32>
affine.for %arg2 = 0 to 32 {
%0 = affine.load %arg0[%arg2] : memref<32xf32>
%1 = affine.load %arg1[%arg2] : memref<32xf32>
%2 = addf %0, %1 : f32
affine.store %2, %arg0[%arg2] : memref<32xf32>
%3 = affine.load %arg0[%arg2] : memref<32xf32>
%4 = affine.load %arg1[%arg2] : memref<32xf32>
%5 = addf %3, %4 : f32
affine.store %5, %arg0[%arg2] : memref<32xf32>
}
return
}
```
This happened because when analyzing the source and destination nodes,
affine loop fusion ignored non-result ops sandwitched between them. In
other words, the MemRefDependencyGraph in the affine loop fusion ignored
these non-result ops.
This patch solves the issue by adding these non-result ops to the
MemRefDependencyGraph.
Reviewed By: bondhugula
Differential Revision: https://reviews.llvm.org/D95668
2021-02-06 13:30:16 +05:30
..
2021-01-20 12:15:28 +01:00
2021-01-14 11:35:49 -08:00
2021-01-14 11:35:49 -08:00
2020-11-16 16:05:32 -08:00
2021-01-14 11:35:49 -08:00
2020-06-12 00:43:09 +00:00
2021-01-19 13:49:25 -08:00
2021-01-14 11:35:49 -08:00
2021-01-14 11:35:49 -08:00
2021-01-14 11:35:49 -08:00
2020-11-16 16:05:32 -08:00
2020-11-30 17:04:14 -08:00
2020-11-09 11:08:08 -08:00
2020-12-14 18:09:47 -08:00
2020-11-09 21:54:47 -08:00
2020-05-13 19:20:21 +02:00
2020-05-13 19:20:21 +02:00
2021-02-06 13:30:16 +05:30
2020-11-09 21:54:47 -08:00
2020-06-16 13:59:53 +05:30
2020-07-28 11:30:54 -07:00
2020-08-28 00:34:23 +05:30
2021-01-07 02:36:02 +09:00
2020-11-16 16:05:32 -08:00
2021-01-29 21:32:36 +01:00
2020-05-13 19:20:21 +02:00
2021-01-14 11:35:49 -08:00
2020-06-12 00:43:09 +00:00
2021-01-14 11:35:49 -08:00
2021-01-14 11:35:49 -08:00
2021-01-14 11:35:49 -08:00
2021-01-14 11:35:49 -08:00
2020-08-07 14:49:49 -04:00
2020-10-10 14:18:25 +05:30
2020-08-07 14:49:49 -04:00
2021-01-29 21:32:36 +01:00
2020-11-09 21:54:47 -08:00
2021-02-04 01:58:56 +00:00
2021-01-07 19:48:31 +01:00
2020-07-14 13:06:08 -07:00
2021-02-04 11:15:11 +01:00
2020-06-18 13:58:47 -07:00
2020-11-19 21:24:10 +01:00
2020-11-26 17:39:14 +01:00
2020-08-27 15:37:42 +09:00
2021-01-14 11:58:21 -08:00
2020-11-16 16:05:32 -08:00