+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.
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__");
/* 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;
-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
@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.
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
+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.
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;
}
-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
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
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. */
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))
/* 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. */
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,
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,
{
flag_trapping_math = !set;
flag_unsafe_math_optimizations = set;
+ flag_finite_math_only = set;
flag_errno_math = !set;
if (set)
flag_signaling_nans = 0;
{
return (!flag_trapping_math
&& flag_unsafe_math_optimizations
+ && flag_finite_math_only
&& !flag_errno_math);
}