aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorToon Moene <toon@moene.indiv.nluug.nl>2002-07-31 00:23:26 +0200
committerToon Moene <toon@gcc.gnu.org>2002-07-30 22:23:26 +0000
commit2e8f2e8f7dac642b0b369c7f71d6852278d5c2a5 (patch)
treede115f5445a03103a3fc5ea6fddfa87706ee7d4e /gcc
parenta538e5805514bc4728c76b372cf4dc89edd4d968 (diff)
downloadgcc-2e8f2e8f7dac642b0b369c7f71d6852278d5c2a5.zip
gcc-2e8f2e8f7dac642b0b369c7f71d6852278d5c2a5.tar.gz
gcc-2e8f2e8f7dac642b0b369c7f71d6852278d5c2a5.tar.bz2
flags.h: Declare flag_finite_math_only.
2002-07-30 Toon Moene <toon@moene.indiv.nluug.nl> * flags.h: Declare flag_finite_math_only. Use it in definition of HONOR_NANS and HONOR_INFINITIES. * c-common.c (cb_register_builtins): Emit __FINITE_MATH_ONLY__ when flag_finite_math_only is set. * combine.c (simplify_if_then_else): If flag_finite_math_only is set, a == b has a definite value. * toplev.c: Initialize flag_finite_math_only. (set_flags_fast_math): Set it on -ffast-math. (flag_fast_math_set_p): Test it. doc: * invoke.texi: Document -ffinite-math-only. f: * com.c (ffe_init_options): Set flag_finite_math_only. * invoke.texi: Document -fno-finite-math-only. From-SVN: r55887
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/c-common.c2
-rw-r--r--gcc/combine.c4
-rw-r--r--gcc/doc/invoke.texi16
-rw-r--r--gcc/f/ChangeLog6
-rw-r--r--gcc/f/com.c1
-rw-r--r--gcc/f/invoke.texi12
-rw-r--r--gcc/flags.h8
-rw-r--r--gcc/toplev.c8
9 files changed, 66 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c9b9f70..4cb00df 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2002-07-30 Toon Moene <toon@moene.indiv.nluug.nl>
+
+ * flags.h: Declare flag_finite_math_only.
+ Use it in definition of HONOR_NANS and
+ HONOR_INFINITIES.
+ * c-common.c (cb_register_builtins): Emit
+ __FINITE_MATH_ONLY__ when flag_finite_math_only
+ is set.
+ * combine.c (simplify_if_then_else): If
+ flag_finite_math_only is set, a == b has a
+ definite value.
+ * toplev.c: Initialize flag_finite_math_only.
+ (set_flags_fast_math): Set it on -ffast-math.
+ (flag_fast_math_set_p): Test it.
+ * doc/invoke.texi: Document -ffinite-math-only.
+
2002-07-30 Richard Henderson <rth@redhat.com>
* ifcvt.c (noce_get_alt_condition): Use reg_overlap_mentioned_p.
diff --git a/gcc/c-common.c b/gcc/c-common.c
index f7bbc1b..0d81341 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -4385,6 +4385,8 @@ cb_register_builtins (pfile)
cpp_define (pfile, "__NO_INLINE__");
if (flag_signaling_nans)
cpp_define (pfile, "__SUPPORT_SNAN__");
+ if (flag_finite_math_only)
+ cpp_define (pfile, "__FINITE_MATH_ONLY__");
if (flag_iso)
cpp_define (pfile, "__STRICT_ANSI__");
diff --git a/gcc/combine.c b/gcc/combine.c
index cd2e8df..297e6a4 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -4775,12 +4775,12 @@ simplify_if_then_else (x)
/* Convert a == b ? b : a to "a". */
if (true_code == EQ && ! side_effects_p (cond)
- && (! FLOAT_MODE_P (mode) || flag_unsafe_math_optimizations)
+ && (!FLOAT_MODE_P (mode) || !HONOR_NANS (mode))
&& rtx_equal_p (XEXP (cond, 0), false_rtx)
&& rtx_equal_p (XEXP (cond, 1), true_rtx))
return false_rtx;
else if (true_code == NE && ! side_effects_p (cond)
- && (! FLOAT_MODE_P (mode) || flag_unsafe_math_optimizations)
+ && (!FLOAT_MODE_P (mode) || !HONOR_NANS (mode))
&& rtx_equal_p (XEXP (cond, 0), true_rtx)
&& rtx_equal_p (XEXP (cond, 1), false_rtx))
return true_rtx;
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8d5687b..fb91197 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -273,7 +273,7 @@ in the following sections.
-fmove-all-movables -fnew-ra -fno-default-inline -fno-defer-pop @gol
-fno-function-cse -fno-guess-branch-probability @gol
-fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol
--funsafe-math-optimizations -fno-trapping-math @gol
+-funsafe-math-optimizations -ffinite-math-only -fno-trapping-math @gol
-fno-zero-initialized-in-bss @gol
-fomit-frame-pointer -foptimize-register-move @gol
-foptimize-sibling-calls -fprefetch-loop-arrays @gol
@@ -3408,7 +3408,8 @@ performed when this option is not used.
@item -ffast-math
@opindex ffast-math
Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @*
-@option{-fno-trapping-math} and @option{-fno-signaling-nans}.
+@option{-fno-trapping-math}, @option{-ffinite-math-only} and @*
+@option{-fno-signaling-nans}.
This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
@@ -3446,6 +3447,17 @@ math functions.
The default is @option{-fno-unsafe-math-optimizations}.
+@item -ffinite-math-only
+@opindex ffinite-math-only
+Allow optimizations for floating-point arithmetic that assume
+that arguments and results are not NaNs or +-Infs.
+
+This option should never be turned on by any @option{-O} option since
+it can result in incorrect output for programs which depend on
+an exact implementation of IEEE or ISO rules/specifications.
+
+The default is @option{-fno-finite-math-only}.
+
@item -fno-trapping-math
@opindex fno-trapping-math
Compile code assuming that floating-point operations cannot generate
diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog
index 7964fa4..394117a 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -1,3 +1,9 @@
+2002-07-30 Toon Moene <toon@moene.indiv.nluug.nl>
+
+ * com.c (ffe_init_options): Set
+ flag_finite_math_only.
+ * invoke.texi: Document -fno-finite-math-only.
+
Mon Jul 29 22:05:35 2002 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* com.c (read_name_map): Use concat in lieu of xmalloc/strcpy.
diff --git a/gcc/f/com.c b/gcc/f/com.c
index 4757d7e..1c6b05a 100644
--- a/gcc/f/com.c
+++ b/gcc/f/com.c
@@ -14176,6 +14176,7 @@ ffe_init_options ()
flag_reduce_all_givs = 1;
flag_argument_noalias = 2;
flag_merge_constants = 2;
+ flag_finite_math_only = 1;
flag_errno_math = 0;
flag_complex_divide_method = 1;
}
diff --git a/gcc/f/invoke.texi b/gcc/f/invoke.texi
index c8a1d7a..77c1c39b 100644
--- a/gcc/f/invoke.texi
+++ b/gcc/f/invoke.texi
@@ -182,7 +182,7 @@ by type. Explanations are in the following sections.
-malign-double @gol
-ffloat-store -fforce-mem -fforce-addr -fno-inline @gol
-ffast-math -fstrength-reduce -frerun-cse-after-loop @gol
--funsafe-math-optimizations -fno-trapping-math @gol
+-funsafe-math-optimizations -fno-finite-math-only -fno-trapping-math @gol
-fexpensive-optimizations -fdelayed-branch @gol
-fschedule-insns -fschedule-insn2 -fcaller-saves @gol
-funroll-loops -funroll-all-loops @gol
@@ -1551,6 +1551,16 @@ Sets @option{-funsafe-math-optimizations}, and
Allow optimizations that may be give incorrect results
for certain IEEE inputs.
+@cindex -fno-finite-math-only option
+@cindex options, -fno-finite-math-only
+@item -fno-finite-math-only
+Fortran specifies all arithmetic that can result in a NaN or an
+infinity as "giving undefined results", therefore the compiler
+by default operates in a way that assumes no NaNs or +-Inf can
+be generated. If you want to use a NaN or an Inf produced by
+means other than Fortran, use this option to compile your
+Fortran program.
+
@cindex -fno-trapping-math option
@cindex options, -fno-trapping-math
@item -fno-trapping-math
diff --git a/gcc/flags.h b/gcc/flags.h
index 06ebd20..4ff7fcf 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -359,6 +359,10 @@ extern int flag_errno_math;
extern int flag_unsafe_math_optimizations;
+/* Nonzero means that no NaNs or +-Infs are expected. */
+
+extern int flag_finite_math_only;
+
/* Zero means that floating-point math operations cannot generate a
(user-visible) trap. This is the case, for example, in nonstop
IEEE 754 arithmetic. */
@@ -672,7 +676,7 @@ extern int flag_signaling_nans;
disabled for modes with NaNs. The user can ask for them to be
done anyway using the -funsafe-math-optimizations switch. */
#define HONOR_NANS(MODE) \
- (MODE_HAS_NANS (MODE) && !flag_unsafe_math_optimizations)
+ (MODE_HAS_NANS (MODE) && !flag_finite_math_only)
/* Like HONOR_NANs, but true if we honor signaling NaNs (or sNaNs). */
#define HONOR_SNANS(MODE) (flag_signaling_nans && HONOR_NANS (MODE))
@@ -680,7 +684,7 @@ extern int flag_signaling_nans;
/* As for HONOR_NANS, but true if the mode can represent infinity and
the treatment of infinite values is important. */
#define HONOR_INFINITIES(MODE) \
- (MODE_HAS_INFINITIES (MODE) && !flag_unsafe_math_optimizations)
+ (MODE_HAS_INFINITIES (MODE) && !flag_finite_math_only)
/* Like HONOR_NANS, but true if the given mode distinguishes between
postive and negative zero, and the sign of zero is important. */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index e4aeca0..9fe5cad 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -575,6 +575,10 @@ int flag_errno_math = 1;
int flag_unsafe_math_optimizations = 0;
+/* Nonzero means that no NaNs or +-Infs are expected. */
+
+int flag_finite_math_only = 0;
+
/* Zero means that floating-point math operations cannot generate a
(user-visible) trap. This is the case, for example, in nonstop
IEEE 754 arithmetic. Trapping conditions include division by zero,
@@ -1170,6 +1174,8 @@ static const lang_independent_options f_options[] =
N_("Process #ident directives") },
{ "peephole2", &flag_peephole2, 1,
N_("Enables an rtl peephole pass run before sched2") },
+ {"finite-math-only", &flag_finite_math_only, 1,
+ N_("Assume no NaNs or +-Infs are generated") },
{ "guess-branch-probability", &flag_guess_branch_prob, 1,
N_("Enables guessing of branch probabilities") },
{"math-errno", &flag_errno_math, 1,
@@ -1575,6 +1581,7 @@ set_fast_math_flags (set)
{
flag_trapping_math = !set;
flag_unsafe_math_optimizations = set;
+ flag_finite_math_only = set;
flag_errno_math = !set;
if (set)
flag_signaling_nans = 0;
@@ -1586,6 +1593,7 @@ fast_math_flags_set_p ()
{
return (!flag_trapping_math
&& flag_unsafe_math_optimizations
+ && flag_finite_math_only
&& !flag_errno_math);
}