-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Copy link
Labels
Description
| Bugzilla Link | 49359 |
| Version | unspecified |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @joker-eph,@bondhugula |
Extended Description
Incorrect affine loop fusion occurs in case of a producer that has a self-dependence. As consumer only consumes a part of the memref produced, producer(source) cannot be deleted after the fusion.
Example below:
func @​trial(%producer : memref<32xf32>, %consumer: memref<16xf32>){
%cst = constant 2.000000e+00 : f32
affine.for %arg3 = 0 to 32 {
%0 = affine.load %producer[%arg3] : memref<32xf32>
%2 = mulf %0, %cst : f32
affine.store %2, %producer[%arg3] : memref<32xf32>
}
affine.for %arg3 = 0 to 16 {
%0 = affine.load %producer[%arg3] : memref<32xf32>
%2 = addf %0, %cst : f32
affine.store %2, %consumer[%arg3] : memref<16xf32>
}
return
}
-affine-loop-fusion results in the following result:
module {
func @​trial(%arg0: memref<16xf32>, %arg1: memref<32xf32>) {
%cst = constant 2.000000e+00 : f32
affine.for %arg2 = 0 to 32 {
%0 = affine.load %arg1[%arg2] : memref<32xf32>
%1 = mulf %0, %cst : f32
affine.store %1, %arg1[%arg2] : memref<32xf32>
}
affine.for %arg2 = 0 to 16 {
%0 = affine.load %arg1[%arg2] : memref<32xf32>
%1 = mulf %0, %cst : f32
affine.store %1, %arg1[%arg2] : memref<32xf32>
%2 = affine.load %arg1[%arg2] : memref<32xf32>
%3 = addf %2, %cst : f32
affine.store %3, %arg0[%arg2] : memref<16xf32>
}
return
}
}