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
This commit is contained in:
Toon Moene 2002-07-31 00:23:26 +02:00 committed by Toon Moene
parent a538e58055
commit 2e8f2e8f7d
9 changed files with 66 additions and 7 deletions

View File

@ -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.

View File

@ -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__");

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -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;
}

View File

@ -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

View File

@ -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. */

View File

@ -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);
}