This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch RFA: Let languages control -ffast-math
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 6 Feb 2011 12:07:50 +0100
- Subject: Re: Patch RFA: Let languages control -ffast-math
- References: <mcrsjw2xru8.fsf@google.com>
On Sat, Feb 5, 2011 at 7:24 PM, Ian Lance Taylor <iant@google.com> wrote:
> As I pointed out in http://gcc.gnu.org/ml/gcc/2011-01/msg00454.html ,
> now that the default options always include either -ffast-math or
> -fno-fast-math, language specific settings for specific options
> controlled by -ffast-math are overridden. ?This affects at least
> Fortran, Java, and Go. ?In a reply Joseph suggested that -ffast-math
> should not override language dependent defaults. ?This patch implements
> that suggestion.
>
> This patch adds a new language hook apply_combined_option which lets the
> frontend control whether a meta-option like -ffast-math should affect
> another more specific option. ?This is a general mechanism and is named
> accordingly, but in fact at present it seems only appropriate for
> -ffast-math and -funsafe-math-optimizations, so I would be willing to
> give it a more specific name if that seems appropriate.
>
> I did not change the documentation as this patch by itself does not
> cause any change in behaviour. ?If this patch is approved, subsequent
> patches for the affected frontends would be appropriate. ?For the Go
> frontend the patch is to define the new language hook like this:
>
> static bool
> go_langhook_apply_combined_option (size_t combined ATTRIBUTE_UNUSED,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size_t specific)
> {
> ?return specific != OPT_fmath_errno;
> }
>
> This patch creates the infrastructure for fixing a bug we have
> introduced in 4.6 for Fortran and Java, so I think it is appropriate for
> stage 3.
>
> Bootstrapped and tested with all default languages except Java on
> x86_64-unknown-linux-gnu.
>
> OK for mainline?
Can you try to add a testcase? It seems it should be possible to
construct one for Fortran at least, based on the fact it allows
FP association by default.
Richard.
> Ian
>
>
> 2011-02-05 ?Ian Lance Taylor ?<iant@google.com>
>
> ? ? ? ?* langhooks.h (struct lang_hooks): Add apply_combined_option.
> ? ? ? ?* langhooks-def.h (lhd_apply_combined_option): Declare.
> ? ? ? ?(LANG_HOOKS_APPLY_COMBINED_OPTION): Define.
> ? ? ? ?(LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_APPLY_COMBINED_OPTION.
> ? ? ? ?* langhooks.c (lhd_apply_combined_option): New function.
> ? ? ? ?* opts.c: Include "tree.h" and "langhooks.h".
> ? ? ? ?(set_fast_math_flags): Check apply_combined_option before changing
> ? ? ? ?each field.
> ? ? ? ?(set_unsafe_math_optimizations_flags): Likewise. ?Also add code
> ? ? ? ?parameter and change all callers.
> ? ? ? ?* Makefile.in (opts.o): Depend upon $(TREE_H) and langhooks.h.
>
>
>