<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60837>60837</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
numerical differences in x87 fpu code generated by clang-14 and clang-15
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
anbe42
</td>
</tr>
</table>
<pre>
As I've reported in Debian: https://bugs.debian.org/1031500
I've extracted a function (`_Z8_cl_fmodff`) from pocl generated bytecode (`pocl_cl_fmod.ll`, part of the pocl OpenCL implementation of `float fmod(float,float)`) that produces different numeric results when compiled with lvm-14 and llvm-15. I've added a small C main to demonstrate that (`main.c`, `Makefile`).
These numerical differences from pocl-3.1/llvm-15 cause test failures in pyopencl, libgpuarray.
This happens when generating 32-bit x87 fpu code with `-O2 --target=i386-unknown-linux-gnu -march=i686`.
```
$ ./test_pocl_cl_fmod_llvm14
a=0 b=0.1 c=0 d=0 abserr=0 relerr=0
a=0.1 b=0.1221239 c=0.1 d=0.1 abserr=0 relerr=0
a=0.2 b=0.14424779 c=0.055752218 d=0.055752218 abserr=0 relerr=0
a=0.3 b=0.16637169 c=0.13362832 d=0.13362832 abserr=0 relerr=0
a=0.4 b=0.18849558 c=0.023008853 d=0.023008853 abserr=0 relerr=0
a=0.5 b=0.21061946 c=0.078761071 d=0.078761071 abserr=0 relerr=0
a=0.6 b=0.23274337 c=0.13451329 d=0.13451329 abserr=0 relerr=0
a=0.7 b=0.25486726 c=0.19026548 d=0.19026548 abserr=0 relerr=0
a=0.8 b=0.27699116 c=0.24601769 d=0.24601769 abserr=0 relerr=0
a=0.9 b=0.29911503 c=0.0026548803 d=0.0026548803 abserr=0 relerr=0
```
```
$ ./test_pocl_cl_fmod_llvm15
a=0 b=0.1 c=0 d=0 abserr=0 relerr=0
a=0.1 b=0.1221239 c=0.1 d=0.1 abserr=0 relerr=0
a=0.2 b=0.14424779 c=0.055752218 d=0.055752218 abserr=0 relerr=0
a=0.3 b=0.16637169 c=0.13362832 d=0.13362832 abserr=0 relerr=0
a=0.4 b=0.18849558 c=0.023008853 d=0.023008853 abserr=0 relerr=0
a=0.5 b=0.21061946 c=0.078761071 d=0.078761071 abserr=0 relerr=0
a=0.6 b=0.23274337 c=0.13451327 d=0.13451329 abserr=1.49012e-08 relerr=6.4024e-08
a=0.7 b=0.25486726 c=0.19026548 d=0.19026548 abserr=0 relerr=0
a=0.8 b=0.27699116 c=0.24601772 d=0.24601769 abserr=-2.98023e-08 relerr=-1.07593e-07 FAIL
a=0.9 b=0.29911503 c=0.0026548505 d=0.0026548803 abserr=2.98023e-08 relerr=9.9635e-08
```
```
c = _Z8_cl_fmodff(a, b) # from pocl
d = fmodf(a, b) # from libc, as reference
```
Please get the files from https://bugs.debian.org/1031500, github refused any attachment type I tried.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzslk9vpDgTxj-N-1Jq5D9gw6EPeRO1NNK8mj3MaS-RgaLxjjEIm8nk268MuDtZzUzPnvawG0WEwtTPT5VT3Y_23lwc4okU_yPF00EvoR_nk3Y15vxQj-3r6cHDB8LVV4QZp3EO2IJx8IS10Y6IB-hDmDwRD4SfCT_Xy8Vn7bqYjfOF8DOjghWUEvpE6MN23Xn4Lcy6iUAN3eKaYEYHhJdE0uffy-fGPnfD2HYdkZTwCrp5HGAaGwsXdDjrmFi_BmzGFve0uJryMmvXxEeY9Bxg7CD0uOV_mtA9fgQzTBYHdEGvO48dEEk7O-oAEUB4uQaEP-5_q11J6HWAaR7bpUEPrek6nNEFcMuAs2lgRr_Y4OGlRwfNOEzGYgsvJvRgvw5HloN2Ldj1vshSe3Xbrq3wg7YWHmHQxkEYocVhdD7Egredt1rjctbsJRJJ_6-_YGcsbhqzrdOfe_SYdGl71Rp1X_t5FBkj_LzrgUYvHiGgD9BpY5cZfTzx6XWc0DU2bmdNfZkWPc_6NXt7sJ9746HX04Rur34_Ku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