This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/40675] Support -fnosign-zero for SIGN intrinsic for Fortran 77 compatibility
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2009 08:00:23 -0000
- Subject: [Bug fortran/40675] Support -fnosign-zero for SIGN intrinsic for Fortran 77 compatibility
- References: <bug-40675-3783@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #10 from burnus at gcc dot gnu dot org 2009-07-08 08:00 -------
I think one can consider supporting non-signed zeros as extension, similar to
ifort which has:
-assume nominus0 The compiler uses Fortran 90/77 standard
semantics in the SIGN intrinsic to treat
-0.0 and +0.0 as 0.0, and writes a value
of 0.0 with no sign on formatted output.
(Default as of ifort 11.1 is the F77/F90 behaviour while gfortran defaults to
the F95/F2003/F2008 behaviour.)
Currently, gfortran only has such a flag for I/O and not for the sign
intrinsic:
-fsign-zero
When writing zero values, show the negative sign if the sign
bit is set. "fno-sign-zero" does not print the negative
sign of zero values for compatibility with F77. Default
behavior is to show the negative sign.
I think one can extends this to the SIGN intrinsic. One needs to modify
("if (gfc_option.flag_sign_zero)") trans-intrinsic.c's gfc_conv_intrinsic_sign.
Currently,
test = sign(x, y)
produces (-fdump-tree-original)
test = __builtin_copysignf (x, y)
that would have to be replaced by
test = (y == 0) ? abs(x) : __builtin_copysignf (x, y)
This can be further optimized by using MODE_HAS_SIGNED_ZEROS (or
HONOR_SIGNED_ZEROS?).
Actually, one also needs to modify simplify.c's gfc_simplify_sign: Either -0.0
is not correctly handled or the comment is wrong.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|x86_64-unknown-linux-gnu |
GCC host triplet|x86_64-unknown-linux-gnu |
GCC target triplet|x86_64-unknown-linux-gnu |
Last reconfirmed|0000-00-00 00:00:00 |2009-07-08 08:00:23
date| |
Summary|sign intrinsic fails for |Support -fnosign-zero for
|value of 0.0 |SIGN intrinsic for Fortran
| |77 compatibility
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40675