This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Don't fold "+ 0.0" with signaling NaNs
- From: Roger Sayle <roger at www dot eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Feb 2003 13:37:45 -0700 (MST)
- Subject: [PATCH] Don't fold "+ 0.0" with signaling NaNs
The following simple patch to fold_real_zero_addition_p avoids optimizing
"x + 0.0" when the user specifies -fsignaling-nans on the command line.
This patch has been tested on i686-pc-linux-gnu with a full bootstrap,
all languages except Ada and treelang, and a complete "make -k check"
with no new regressions.
Ok for mainline?
2003-02-18 Roger Sayle <roger at eyesopen dot com>
* fold-const.c (fold_real_zero_addition_p): Don't fold a zero
addition in the presence of signaling NaNs.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.236
diff -c -3 -p -r1.236 fold-const.c
*** fold-const.c 18 Feb 2003 19:37:01 -0000 1.236
--- fold-const.c 19 Feb 2003 15:09:37 -0000
*************** fold_real_zero_addition_p (type, addend,
*** 4642,4647 ****
--- 4642,4651 ----
if (!real_zerop (addend))
return false;
+ /* Don't allow the fold with -fsignaling-nans. */
+ if (HONOR_SNANS (TYPE_MODE (type)))
+ return false;
+
/* Allow the fold if zeros aren't signed, or their sign isn't important. */
if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type)))
return true;
Roger
--
Roger Sayle, E-mail: roger at eyesopen dot com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833