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: GFortran Flush (Denormals) to Zero Flag


Nick K wrote:
Jerry,
Thanks for your reply! I isolated the flags, -ffast-math does the same thing for me like -funsafe-math-optimizations. My test program is:
program main
real a,b,c
a=1e-20
b=a**2
print *,b
a=0
b=0
c=a/b
print *,c
end
And the output shows that without optimization, -funsafe-math-optimizations does what I want it to, while a combination of -funsafe-math-optimizations and -O2 does the exact opposite:
root@nick-desktop:/home#
root@nick-desktop:/home#
root@nick-desktop:/home# gfortran -mfpmath=sse -msse2 -ffpe-trap=invalid,zero,overflow -fbounds-check -funsafe-math-optimizations test.for root@nick-desktop:/home# ./a.out
0.0000000 Floating point exception
root@nick-desktop:/home# rm ./a.out
root@nick-desktop:/home# gfortran -mfpmath=sse -msse2 -ffpe-trap=invalid,zero,overflow -fbounds-check -funsafe-math-optimizations -O2 test.for root@nick-desktop:/home# ./a.out
9.99994610E-41
NaN
root@nick-desktop:/home# rm ./a.out
root@nick-desktop:/home#

You may also want to try some negations like -fno-some-flag.


Jerry


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