This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Add PAREN_EXPR, make flag_associative_math the default for Fortran


Dominique Dhumieres wrote:
I have found what's wrong for my test with the patch.
A reduced test case is:

real function anint4(x, a, b, c)
real, parameter :: f = 2.0**23
real x, a, b, c, d, e
anint4 = x
a = abs(x)
if (a < f) then
anint4 = (f+a) - f
b = anint4
c = (anint4 - 0.5) - a
if (c > 0.0) then
anint4 = anint4 - 1.0 end if
end if
end function anint4


If I diff the results of -fdump-tree-optimized with and without
-ffast-math I get:

23c23
<   D.840 = ((__result_anint4)) - D.832;
---
D.840 = ((__result_anint4 - 5.0e-1)) - D.832;

Do you understand why -ffast-math eats the '-0.5'?

Probably it sees that f + 0.5 == f, and from this derives that
(f + a) - f - 0.5 == (f + a) - f. Of course this would require an invalid reassociation, because the correct expression to evaluate would be ((f+a) - f) - 0.5.


Cheers,
- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]