aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@libertysurf.fr>2007-11-19 07:27:31 +0100
committerEric Botcazou <ebotcazou@gcc.gnu.org>2007-11-19 06:27:31 +0000
commitc5edab650de5e1e148c08d7396bfdbf034c0d5a6 (patch)
tree1e272b2a1434330c1d37940c486411e9cb30b2a8 /gcc
parent88af50ebcd002284ee32bd0a67eccccea1fac47c (diff)
downloadgcc-c5edab650de5e1e148c08d7396bfdbf034c0d5a6.zip
gcc-c5edab650de5e1e148c08d7396bfdbf034c0d5a6.tar.gz
gcc-c5edab650de5e1e148c08d7396bfdbf034c0d5a6.tar.bz2
re PR tree-optimization/34036 (ICE with control flow in the middle of basic block for -fnon-call-exceptions)
PR tree-optimization/34036 * opts.c (set_fast_math_flags): Do not set flags 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 is 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. From-SVN: r130286
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/doc/invoke.texi14
-rw-r--r--gcc/opts.c9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/opt/pr34036.C32
-rw-r--r--gcc/testsuite/gcc.dg/pr33007.c1
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/recip-5.c1
-rw-r--r--gcc/toplev.c7
8 files changed, 74 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cf958d1..b3e98e1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2007-11-19 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ PR tree-optimization/34036
+ * opts.c (set_fast_math_flags): Do not set flags 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
+ is 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 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/34132
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4679ded..adf50ad 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -6274,7 +6274,8 @@ it can result in incorrect output for programs which depend on
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}.
@@ -6288,8 +6289,9 @@ well as ignore NaNs and inhibit or create underflow or overflow (and
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}.
@@ -6331,9 +6333,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
diff --git a/gcc/opts.c b/gcc/opts.c
index 90c9139..8be098f 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 12eb548..bf7d440 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-19 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.
+
2007-11-18 Jakub Jelinek <jakub@redhat.com>
PR c++/30988
diff --git a/gcc/testsuite/g++.dg/opt/pr34036.C b/gcc/testsuite/g++.dg/opt/pr34036.C
new file mode 100644
index 0000000..ecf6cf7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr34036.C
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fnon-call-exceptions -ffast-math -fsignaling-nans" } */
+/* { dg-warning "-fassociative-math disabled" "" { target *-*-* } 1 } */
+
+template <class T>
+class ggStaticArray {
+public:
+ ~ggStaticArray();
+};
+
+template <class T>
+class ggGrid {
+public:
+ ggGrid() : grid() { }
+ ggStaticArray<T> grid;
+};
+
+class mrGrid {
+public:
+ mrGrid(void);
+protected:
+ ggGrid<int*> grid;
+ double multiplier;
+};
+
+mrGrid::mrGrid(void)
+{
+ double xMeasure, yMeasure, zMeasure;
+ double cellDimension;
+
+ cellDimension = multiplier * (xMeasure * yMeasure * zMeasure);
+}
diff --git a/gcc/testsuite/gcc.dg/pr33007.c b/gcc/testsuite/gcc.dg/pr33007.c
index b1fc428..26b22fd 100644
--- a/gcc/testsuite/gcc.dg/pr33007.c
+++ b/gcc/testsuite/gcc.dg/pr33007.c
@@ -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)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/recip-5.c b/gcc/testsuite/gcc.dg/tree-ssa/recip-5.c
index bcbd183..aafa98f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/recip-5.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/recip-5.c
@@ -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. */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index f7f887a..c1520a3 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -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;