From: Roger Sayle Date: Fri, 19 Jan 2007 19:35:22 +0000 (+0000) Subject: common.opt (fsigned-zeros): New command line option. X-Git-Tag: releases/gcc-4.3.0~7363 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=db02da79174dea480aa4217dbe7afd3d3b8364d1;p=thirdparty%2Fgcc.git common.opt (fsigned-zeros): New command line option. * common.opt (fsigned-zeros): New command line option. * flags.h (HONOR_SIGNED_ZEROS): Control via flag_signed_zeros instead of flag_unsafe_math_optimizations. * opts.c (set_fast_math_flags): The -ffast-math command line option implies -fno-signed-zeros. (fast_math_flags_set_p): Likewise. * doc/invoke.texi: Document new -fno-signed-zeros option, and update the documentation of -ffast-math appropriately. Wrap long lines. * gcc.dg/pr30172-1.c: Specify the -fno-signed-zeros command line option instead of -funsafe-math-optimizations. From-SVN: r120978 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e536c404f9db..78513d25ecb1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2007-01-19 Roger Sayle + + * common.opt (fsigned-zeros): New command line option. + * flags.h (HONOR_SIGNED_ZEROS): Control via flag_signed_zeros instead + of flag_unsafe_math_optimizations. + * opts.c (set_fast_math_flags): The -ffast-math command line option + implies -fno-signed-zeros. + (fast_math_flags_set_p): Likewise. + + * doc/invoke.texi: Document new -fno-signed-zeros option, and update + the documentation of -ffast-math appropriately. Wrap long lines. + 2007-01-19 Steve Ellcey * system.h (ASM_MAKE_LABEL_LINKONCE): Poison. diff --git a/gcc/common.opt b/gcc/common.opt index 109de7bf3d42..dfcda946aa21 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -845,6 +845,10 @@ fsignaling-nans Common Report Var(flag_signaling_nans) Disable optimizations observable by IEEE signaling NaNs +fsigned-zeros +Common Report Var(flag_signed_zeros) Init(1) +Disable floating point optimizations that ignore the IEEE signedness of zero + fsingle-precision-constant Common Report Var(flag_single_precision_constant) Convert floating point constants to single precision constants diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3447ff83ac8d..5337288a676d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -323,7 +323,8 @@ Objective-C and Objective-C++ Dialects}. -fno-default-inline -fno-defer-pop -fmove-loop-invariants @gol -fno-function-cse -fno-guess-branch-probability @gol -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol --funsafe-math-optimizations -funsafe-loop-optimizations -ffinite-math-only @gol +-funsafe-math-optimizations -funsafe-loop-optimizations @gol +-ffinite-math-only -fno-signed-zeros @gol -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol -fomit-frame-pointer -foptimize-register-move @gol -foptimize-sibling-calls -fprefetch-loop-arrays @gol @@ -5631,8 +5632,8 @@ them to store all pertinent intermediate computations into variables. @opindex ffast-math Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @* @option{-fno-trapping-math}, @option{-ffinite-math-only}, -@option{-fno-rounding-math}, @option{-fno-signaling-nans} -and @option{fcx-limited-range}. +@option{-fno-rounding-math}, @option{-fno-signaling-nans}, +@option{-fno-signed-zeros} and @option{fcx-limited-range}. This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. @@ -5655,9 +5656,9 @@ math functions. The default is @option{-fmath-errno}. -On Darwin systems, the math library never sets @code{errno}. There is therefore -no reason for the compiler to consider the possibility that it might, -and @option{-fno-math-errno} is the default. +On Darwin systems, the math library never sets @code{errno}. There is +therefore no reason for the compiler to consider the possibility that +it might, and @option{-fno-math-errno} is the default. @item -funsafe-math-optimizations @opindex funsafe-math-optimizations @@ -5685,6 +5686,16 @@ an exact implementation of IEEE or ISO rules/specifications. The default is @option{-fno-finite-math-only}. +@item -fno-signed-zeros +@opindex fno-signed-zeros +Allow optimizations for floating point arithmetic that ignore the +signedness of zero. IEEE arithmetic specifies the behavior of +distinct +0.0 and -0.0 values, which then prohibits simplification +of expressions such as x+0.0 or 0.0*x (even with @option{-ffinte-math-only}). +This option implies that the sign of a zero result isn't significant. + +The default is @option{-fsigned-zeros}. + @item -fno-trapping-math @opindex fno-trapping-math Compile code assuming that floating-point operations cannot generate diff --git a/gcc/flags.h b/gcc/flags.h index f5fdd6b2bf61..ce9d6d7bb907 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -281,7 +281,7 @@ extern const char *flag_random_seed; /* Like HONOR_NANS, but true if the given mode distinguishes between positive and negative zero, and the sign of zero is important. */ #define HONOR_SIGNED_ZEROS(MODE) \ - (MODE_HAS_SIGNED_ZEROS (MODE) && !flag_unsafe_math_optimizations) + (MODE_HAS_SIGNED_ZEROS (MODE) && flag_signed_zeros) /* Like HONOR_NANS, but true if given mode supports sign-dependent rounding, and the rounding mode is important. */ diff --git a/gcc/opts.c b/gcc/opts.c index 788c2cee7c6a..6720af1332a2 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1076,6 +1076,7 @@ set_fast_math_flags (int set) flag_trapping_math = !set; flag_unsafe_math_optimizations = set; flag_finite_math_only = set; + flag_signed_zeros = !set; flag_errno_math = !set; if (set) { @@ -1092,6 +1093,7 @@ fast_math_flags_set_p (void) return (!flag_trapping_math && flag_unsafe_math_optimizations && flag_finite_math_only + && !flag_signed_zeros && !flag_errno_math); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0178ad1a1d6..326a76ab8fff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-01-19 Roger Sayle + + * gcc.dg/pr30172-1.c: Specify the -fno-signed-zeros command line + option instead of -funsafe-math-optimizations. + 2007-01-19 Tomas Bily gcc.dg/tree-prof/indir-call-prof.c: New. diff --git a/gcc/testsuite/gcc.dg/pr30172-1.c b/gcc/testsuite/gcc.dg/pr30172-1.c index 14b5fa515f69..4e029b5fba6d 100644 --- a/gcc/testsuite/gcc.dg/pr30172-1.c +++ b/gcc/testsuite/gcc.dg/pr30172-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-funsafe-math-optimizations -ffinite-math-only -fdump-tree-gimple" } */ +/* { dg-options "-fno-signed-zeros -ffinite-math-only -fdump-tree-gimple" } */ _Complex double test1 (double x) { return x + 1.i; } _Complex double test2 (double x) { return 1 + x * 1.i; }