This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [RFC] Fix PR tree-optimization/34036


> Probably as well.  I guess to get all cases here will be work though :/

It seems that there are only 2 affected testcases.  OK for mainline?


2007-11-18  Eric Botcazou  <ebotcazou@libertysurf.fr>

        PR tree-optimization/34036
        * opts.c (set_fast_math_flags): Do not set flag in common
        with set_unsafe_math_optimizations_flags, invoke it directly.
        (set_unsafe_math_optimizations_flags): Unset flag_trapping_math
        and flag_signed_zeros.
        * toplev.c (process_options): Force flag_associative_math to 0 and
	warn, if it is set and either flag_trapping_math or flag_signed_zeros
	are set too.
        * doc/invoke.texi (Optimize Options): Document the new behavior
        of -funsafe-math-optimizations, that -fassociative-math requires
        both -fno-signed-zeros and -fno-trapping-math and make it clear
        that -fno-trapping-math requires -fno-signaling-nans.


2007-11-18  Eric Botcazou  <ebotcazou@libertysurf.fr>

	* gcc.dg/pr33007.c: Expect new warning.
	* gcc.dg/tree-ssa/recip-5.c: Likewise.
        * g++.dg/opt/pr34036.C: New test.


-- 
Eric Botcazou
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 130131)
+++ doc/invoke.texi	(working copy)
@@ -6273,7 +6273,8 @@ it can result in incorrect output for pr
 an exact implementation of IEEE or ISO rules/specifications for
 math functions. It may, however, yield faster code for programs
 that do not require the guarantees of these specifications.
-Enables @option{-freciprocal-math} and @option{-fassociative-math}.
+Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
+@option{-fassociative-math} and @option{-freciprocal-math}.
 
 The default is @option{-fno-unsafe-math-optimizations}.
 
@@ -6287,8 +6288,9 @@ well as ignore NaNs and inhibit or creat
 thus cannot be used on a code which relies on rounding behavior like
 @code{(x + 2**52) - 2**52)}.  May also reorder floating-point comparisons
 and thus may not be used when ordered comparisons are required.
-This flag doesn't make much sense without @option{-fno-signed-zeros}
-or @option{-fno-trapping-math} or with @option{-frounding-math}.
+This option requires that both @option{-fno-signed-zeros} and
+@option{-fno-trapping-math} be in effect.  Moreover, it doesn't make
+much sense with @option{-frounding-math}.
 
 The default is @option{-fno-associative-math}.
 
@@ -6330,9 +6332,9 @@ The default is @option{-fsigned-zeros}.
 @opindex fno-trapping-math
 Compile code assuming that floating-point operations cannot generate
 user-visible traps.  These traps include division by zero, overflow,
-underflow, inexact result and invalid operation.  This option implies
-@option{-fno-signaling-nans}.  Setting this option may allow faster
-code if one relies on ``non-stop'' IEEE arithmetic, for example.
+underflow, inexact result and invalid operation.  This option requires
+that @option{-fno-signaling-nans} be in effect.  Setting this option may
+allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
 
 This option should never be turned on by any @option{-O} option since
 it can result in incorrect output for programs which depend on
Index: opts.c
===================================================================
--- opts.c	(revision 130131)
+++ opts.c	(working copy)
@@ -1868,12 +1868,9 @@ set_Wstrict_aliasing (int onoff)
 void
 set_fast_math_flags (int set)
 {
-  flag_trapping_math = !set;
   flag_unsafe_math_optimizations = set;
-  flag_associative_math = set;
-  flag_reciprocal_math = set;
+  set_unsafe_math_optimizations_flags (set);
   flag_finite_math_only = set;
-  flag_signed_zeros = !set;
   flag_errno_math = !set;
   if (set)
     {
@@ -1888,8 +1885,10 @@ set_fast_math_flags (int set)
 void
 set_unsafe_math_optimizations_flags (int set)
 {
-  flag_reciprocal_math = set;
+  flag_trapping_math = !set;
+  flag_signed_zeros = !set;
   flag_associative_math = set;
+  flag_reciprocal_math = set;
 }
 
 /* Return true iff flags are set as if -ffast-math.  */
Index: toplev.c
===================================================================
--- toplev.c	(revision 130131)
+++ toplev.c	(working copy)
@@ -1988,6 +1988,13 @@ process_options (void)
   if (flag_signaling_nans)
     flag_trapping_math = 1;
 
+  /* We cannot reassociate if we want traps or signed zeros. ?*/
+  if (flag_associative_math && (flag_trapping_math || flag_signed_zeros))
+    {
+      warning (0, "-fassociative-math disabled; other options take precedence");
+      flag_associative_math = 0;
+    }
+
   /* With -fcx-limited-range, we do cheap and quick complex arithmetic.  */
   if (flag_cx_limited_range)
     flag_complex_method = 0;
Index: testsuite/gcc.dg/pr33007.c
===================================================================
--- testsuite/gcc.dg/pr33007.c	(revision 130131)
+++ testsuite/gcc.dg/pr33007.c	(working copy)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O -ffast-math -ftrapping-math" } */
+/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 1 } */
 
 long
 foo (int i)
Index: testsuite/gcc.dg/tree-ssa/recip-5.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/recip-5.c	(revision 130131)
+++ testsuite/gcc.dg/tree-ssa/recip-5.c	(working copy)
@@ -1,5 +1,6 @@
 /* { dg-options "-O1 -funsafe-math-optimizations -ftrapping-math -fdump-tree-recip -fdump-tree-optimized" } */
 /* { dg-do compile } */
+/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 1 } */
 
 /* Test the reciprocal optimizations together with trapping math.  */
 

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