<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54541>54541</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
affine-loop-fusion does not respect fusion-compute-tolerance
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir:affine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
aqjune
</td>
</tr>
</table>
<pre>
Hello all,
It seems `-affine-loop-fusion` does not respect its `fusion-compute-tolerance` option, sometimes causing a big increase in running time.
I attach the source file (a.mlir - [a.zip](https://github.com/llvm/llvm-project/files/8346729/a.zip)) and its output ([a_out.zip](https://github.com/llvm/llvm-project/files/8346732/a_out.zip)).
I ran:
```
bin/mlir-opt '-affine-loop-fusion=mode=producer fusion-compute-tolerance=0.0' a.mlir -o a_out.mlir
```
a.mlir contains three loops that look as follows:
```
affine.for %i = 0 to 131072 {
... // A
}
affine.for %j = 0 to 30 {
affine.for %i = 0 to 131072 {
... // B
}
}
```
affine-loop-fusion fuses the loops as follows:
```
affine.for %j = 0 to 30 {
affine.for %i = 0 to 131072 {
... // A <- this iterates 29 times more than before!
... // B
}
}
```
Any idea about how to fully disable this fusion?
Thanks in advance,
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VEtvnDAQ_jVwGYGMvYRw4LDZVdTee68MDIsTY1PbJEp_fceQzaPdHCKlCOEZPP7mm5db2z8131BrC1LrhB8SdkzYfvt-D-ARJw_JFcvkMCiDmbZ2zobFK2voL_QWPRgbwKGfsQugwmq-WWSdneYlYBasRidNh_GMnUM8zQ_g7YRBTQTRSTpgTiChVSdQpnMoPZIAbjEm7kS7_B07kCHIboQwIiEtrkMYlEZI-LXMJ60cZJCUNzL_reakPNLvMYTZJ2Kf8Ft6TyqMS5sTR1K0fjgv2ezsHcVCasTztF6L3VXFa5I2tCjWIE2_xmuXQFFGv9HdT1K_yqXg0eUL4uo2P4dPCY3AW0qu2PO7qq2i_N7GHGSUbWJWXaqfOE62R1rIe7906ODDsokjyxnBwDmz1C8rrahdpLB9n807a4JUxlOtHCJEElGWIYr3ID0Mlnrw0X8U0MY-H6yjYEoFRAgYBAuFKFjFIaluNkOgJ89z2PINZ7TqeAnn7hVHsPcYn3L4l9M3Oy-OX4VLgb0tSywC-rWrtzx9Njv_Kao9WR8y4qU8dT31RSCWNAXbAE_WYayogRYJHhNefEl-tu_ePIHqUYJsqelgtI-R9LBo_QS98rLVuBE7d_bt29M_iNa9j5eJ7B_WduaHtG9EX4tapkEFjc2FOvxzt300HenidPPpQVfeL-ukl7tyV6RjU_KyrnnHRCWEKGqUQ9cXdVnses5lW7epli1q39Alk3C-Dp54Lj3pdN2kquGMcyZ4yYpSlCLnfd3VrGI7WTLB8DrZMZyk0nnkklt3Sl2z0mqXk6dNrXzwr5vSe3UyiKtLwpdLGK1r5K-7xWC6BtCs7P8A4oLcmQ">