<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94431>94431</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] Inconsistent results for arith.remf
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wangyongj1a
</td>
</tr>
</table>
<pre>
I have the following MLIR program:
test.mlir:
```
module {
func.func private @func1() {
%cst_0 = arith.constant 7.668000e+03 : f32
%cst_2 = arith.constant 2.515200e+04 : f32
%cst_3 = arith.constant 3.904000e+04 : f32
%1 = arith.remf %cst_2, %cst_3 : f32
vector.print %1 : f32
%26 = arith.remf %cst_0, %1 : f32
vector.print %26 : f32
return
}
}
```
When I ran ```mlir-opt --convert-arith-to-llvm --convert-vector-to-llvm --convert-func-to-llvm test.mlir``` on the program, and executed the executable file, I got the final result of:
```
-13888
7668
```
However, when I ran ```mlir-opt --int-range-optimizations --convert-arith-to-llvm --convert-vector-to-llvm --convert-func-to-llvm test.mlir``` on the program, and executed the executable file, I got the final result of:
```
-13888
-6220
```
I also wrote a C++ program that I supposed to be equivalent to the above MLIR program:
```
#include <cmath>
#include <iostream>
int main()
{
float a = 7.668000e+03;
float b = 2.515200e+04;
float c = 3.904000e+04;
float res1, res2;
res1 = std::fmod(b, c);
std::cout << res1 << "\n";
res2 = std::fmod(a, res1);
std::cout << res2 << "\n";
return 0;
}
```
The execute result of this C++ program is:
```
25152
7668
```
The three above results seem to be inconsistent. I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused these results.
My git version is dd82fd4744397e0510c8204f1a6031441e21858e.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVk2Pq7gS_TXOpgQyNuZjwaI7ua0X6d3N05NmOTJQgK_AztgmPT2_fmRISLo7fe-sR-pO_HHq1Il9qkA6p3qNWBHxTMRhJ2c_GFu9St2_Gd3_S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