Hi,

In common.opt, -ffp-contract=fast is set as the default for GCC.  But
then it gets disabled in c-family/c-opts.c if you are using ISO C
(e.g. with -std=c99).

The reason for this patch is that if you have also specified
-funsafe-math-optimizations (or -Ofast or -ffast-math) then it is
likely your preference to have -ffp-contract=fast on, so you can
generate fused multiply adds (fma standard pattern).

This patch works by blocking the override if you have
-funsafe-math-optimizations (directly or indirectly), causing fused
multiply add to be used in the places where we might hope to see it.
(I had considered forcing -ffp-contract=fast on in opts.c if you have
-funsafe-math-optimizations, but it is already on by default ... and
it didn't work either!  The problem is that it is forced off unless
you have explicitly asked for -ffp-contract=fast at the command-line.)

Standard regressions passed.

OK for trunk or stage 1?

Cheers,
Ian


10-03-2014  Ian Bolton  <ian.bol...@arm.com>

        * gcc/c-family/c-opts.c (c_common_post_options): Don't override
        -ffp-contract=fast if unsafe-math-optimizations is on.
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index b7478f3..92ba481 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -834,7 +834,8 @@ c_common_post_options (const char **pfilename)
   if (flag_iso
       && !c_dialect_cxx ()
       && (global_options_set.x_flag_fp_contract_mode
-         == (enum fp_contract_mode) 0))
+         == (enum fp_contract_mode) 0)
+      && flag_unsafe_math_optimizations == 0)
     flag_fp_contract_mode = FP_CONTRACT_OFF;
 
   /* By default we use C99 inline semantics in GNU99 or C99 mode.  C99

Reply via email to