This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Gcc floating-point optimizer weird behaviour
- From: Vincent Lefevre <vincent+gcc at vinc17 dot org>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 28 Jan 2015 13:33:42 +0100
- Subject: Re: Gcc floating-point optimizer weird behaviour
- Authentication-results: sourceware.org; auth=none
- References: <1422208292 dot 773977820 at f135 dot i dot mail dot ru>
On 2015-01-25 20:51:33 +0300, Vladimir A. Pavlov wrote:
> I have two files (a.c and f.c, look below). In a.c:main() there are two
> variables, d and e, assigned the same function call result. But the
> optimizer causes their values to be different.
Concerning this particular point, I don't think that there is
a guarantee that you will get the same result, even if you use
-fexcess-precision=standard. At least there is no guarantee
from the C standard. Functions can be inlined, and optimizations
can be done in different ways because the context is different.
If you want reproducible results, make sure that IEEE 754 is
supported and that the FP_CONTRACT pragma is set to OFF
(but impossible with GCC: see PR 37845).
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)