Commit 2e8f2e8f by Toon Moene Committed by Toon Moene

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
parent a538e580
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> 2002-07-30 Richard Henderson <rth@redhat.com>
* ifcvt.c (noce_get_alt_condition): Use reg_overlap_mentioned_p. * ifcvt.c (noce_get_alt_condition): Use reg_overlap_mentioned_p.
......
...@@ -4385,6 +4385,8 @@ cb_register_builtins (pfile) ...@@ -4385,6 +4385,8 @@ cb_register_builtins (pfile)
cpp_define (pfile, "__NO_INLINE__"); cpp_define (pfile, "__NO_INLINE__");
if (flag_signaling_nans) if (flag_signaling_nans)
cpp_define (pfile, "__SUPPORT_SNAN__"); cpp_define (pfile, "__SUPPORT_SNAN__");
if (flag_finite_math_only)
cpp_define (pfile, "__FINITE_MATH_ONLY__");
if (flag_iso) if (flag_iso)
cpp_define (pfile, "__STRICT_ANSI__"); cpp_define (pfile, "__STRICT_ANSI__");
......
...@@ -4775,12 +4775,12 @@ simplify_if_then_else (x) ...@@ -4775,12 +4775,12 @@ simplify_if_then_else (x)
/* Convert a == b ? b : a to "a". */ /* Convert a == b ? b : a to "a". */
if (true_code == EQ && ! side_effects_p (cond) 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, 0), false_rtx)
&& rtx_equal_p (XEXP (cond, 1), true_rtx)) && rtx_equal_p (XEXP (cond, 1), true_rtx))
return false_rtx; return false_rtx;
else if (true_code == NE && ! side_effects_p (cond) 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, 0), true_rtx)
&& rtx_equal_p (XEXP (cond, 1), false_rtx)) && rtx_equal_p (XEXP (cond, 1), false_rtx))
return true_rtx; return true_rtx;
......
...@@ -273,7 +273,7 @@ in the following sections. ...@@ -273,7 +273,7 @@ in the following sections.
-fmove-all-movables -fnew-ra -fno-default-inline -fno-defer-pop @gol -fmove-all-movables -fnew-ra -fno-default-inline -fno-defer-pop @gol
-fno-function-cse -fno-guess-branch-probability @gol -fno-function-cse -fno-guess-branch-probability @gol
-fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @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 -fno-zero-initialized-in-bss @gol
-fomit-frame-pointer -foptimize-register-move @gol -fomit-frame-pointer -foptimize-register-move @gol
-foptimize-sibling-calls -fprefetch-loop-arrays @gol -foptimize-sibling-calls -fprefetch-loop-arrays @gol
...@@ -3408,7 +3408,8 @@ performed when this option is not used. ...@@ -3408,7 +3408,8 @@ performed when this option is not used.
@item -ffast-math @item -ffast-math
@opindex ffast-math @opindex ffast-math
Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @* 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. This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
...@@ -3446,6 +3447,17 @@ math functions. ...@@ -3446,6 +3447,17 @@ math functions.
The default is @option{-fno-unsafe-math-optimizations}. 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 @item -fno-trapping-math
@opindex fno-trapping-math @opindex fno-trapping-math
Compile code assuming that floating-point operations cannot generate Compile code assuming that floating-point operations cannot generate
......
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> 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. * com.c (read_name_map): Use concat in lieu of xmalloc/strcpy.
......
...@@ -14176,6 +14176,7 @@ ffe_init_options () ...@@ -14176,6 +14176,7 @@ ffe_init_options ()
flag_reduce_all_givs = 1; flag_reduce_all_givs = 1;
flag_argument_noalias = 2; flag_argument_noalias = 2;
flag_merge_constants = 2; flag_merge_constants = 2;
flag_finite_math_only = 1;
flag_errno_math = 0; flag_errno_math = 0;
flag_complex_divide_method = 1; flag_complex_divide_method = 1;
} }
......
...@@ -182,7 +182,7 @@ by type. Explanations are in the following sections. ...@@ -182,7 +182,7 @@ by type. Explanations are in the following sections.
-malign-double @gol -malign-double @gol
-ffloat-store -fforce-mem -fforce-addr -fno-inline @gol -ffloat-store -fforce-mem -fforce-addr -fno-inline @gol
-ffast-math -fstrength-reduce -frerun-cse-after-loop @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 -fexpensive-optimizations -fdelayed-branch @gol
-fschedule-insns -fschedule-insn2 -fcaller-saves @gol -fschedule-insns -fschedule-insn2 -fcaller-saves @gol
-funroll-loops -funroll-all-loops @gol -funroll-loops -funroll-all-loops @gol
...@@ -1551,6 +1551,16 @@ Sets @option{-funsafe-math-optimizations}, and ...@@ -1551,6 +1551,16 @@ Sets @option{-funsafe-math-optimizations}, and
Allow optimizations that may be give incorrect results Allow optimizations that may be give incorrect results
for certain IEEE inputs. 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 -fno-trapping-math option
@cindex options, -fno-trapping-math @cindex options, -fno-trapping-math
@item -fno-trapping-math @item -fno-trapping-math
......
...@@ -359,6 +359,10 @@ extern int flag_errno_math; ...@@ -359,6 +359,10 @@ extern int flag_errno_math;
extern int flag_unsafe_math_optimizations; 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 /* Zero means that floating-point math operations cannot generate a
(user-visible) trap. This is the case, for example, in nonstop (user-visible) trap. This is the case, for example, in nonstop
IEEE 754 arithmetic. */ IEEE 754 arithmetic. */
...@@ -672,7 +676,7 @@ extern int flag_signaling_nans; ...@@ -672,7 +676,7 @@ extern int flag_signaling_nans;
disabled for modes with NaNs. The user can ask for them to be disabled for modes with NaNs. The user can ask for them to be
done anyway using the -funsafe-math-optimizations switch. */ done anyway using the -funsafe-math-optimizations switch. */
#define HONOR_NANS(MODE) \ #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). */ /* Like HONOR_NANs, but true if we honor signaling NaNs (or sNaNs). */
#define HONOR_SNANS(MODE) (flag_signaling_nans && HONOR_NANS (MODE)) #define HONOR_SNANS(MODE) (flag_signaling_nans && HONOR_NANS (MODE))
...@@ -680,7 +684,7 @@ extern int flag_signaling_nans; ...@@ -680,7 +684,7 @@ extern int flag_signaling_nans;
/* As for HONOR_NANS, but true if the mode can represent infinity and /* As for HONOR_NANS, but true if the mode can represent infinity and
the treatment of infinite values is important. */ the treatment of infinite values is important. */
#define HONOR_INFINITIES(MODE) \ #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 /* Like HONOR_NANS, but true if the given mode distinguishes between
postive and negative zero, and the sign of zero is important. */ postive and negative zero, and the sign of zero is important. */
......
...@@ -575,6 +575,10 @@ int flag_errno_math = 1; ...@@ -575,6 +575,10 @@ int flag_errno_math = 1;
int flag_unsafe_math_optimizations = 0; 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 /* Zero means that floating-point math operations cannot generate a
(user-visible) trap. This is the case, for example, in nonstop (user-visible) trap. This is the case, for example, in nonstop
IEEE 754 arithmetic. Trapping conditions include division by zero, IEEE 754 arithmetic. Trapping conditions include division by zero,
...@@ -1170,6 +1174,8 @@ static const lang_independent_options f_options[] = ...@@ -1170,6 +1174,8 @@ static const lang_independent_options f_options[] =
N_("Process #ident directives") }, N_("Process #ident directives") },
{ "peephole2", &flag_peephole2, 1, { "peephole2", &flag_peephole2, 1,
N_("Enables an rtl peephole pass run before sched2") }, 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, { "guess-branch-probability", &flag_guess_branch_prob, 1,
N_("Enables guessing of branch probabilities") }, N_("Enables guessing of branch probabilities") },
{"math-errno", &flag_errno_math, 1, {"math-errno", &flag_errno_math, 1,
...@@ -1575,6 +1581,7 @@ set_fast_math_flags (set) ...@@ -1575,6 +1581,7 @@ set_fast_math_flags (set)
{ {
flag_trapping_math = !set; flag_trapping_math = !set;
flag_unsafe_math_optimizations = set; flag_unsafe_math_optimizations = set;
flag_finite_math_only = set;
flag_errno_math = !set; flag_errno_math = !set;
if (set) if (set)
flag_signaling_nans = 0; flag_signaling_nans = 0;
...@@ -1586,6 +1593,7 @@ fast_math_flags_set_p () ...@@ -1586,6 +1593,7 @@ fast_math_flags_set_p ()
{ {
return (!flag_trapping_math return (!flag_trapping_math
&& flag_unsafe_math_optimizations && flag_unsafe_math_optimizations
&& flag_finite_math_only
&& !flag_errno_math); && !flag_errno_math);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment