Patch RFA: Let languages control -ffast-math

Ian Lance Taylor iant@google.com
Mon Feb 7 23:14:00 GMT 2011


"Joseph S. Myers" <joseph@codesourcery.com> writes:

> On Sat, 5 Feb 2011, Ian Lance Taylor wrote:
>
>> 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.
>
> opts.c is not meant to use langhooks; I moved anything that would be 
> problematic to share with the driver into opts-global.c so that opts.c can 
> in future be shared with the driver.  So it would be better in that 
> regard, though less general, for the init_options langhook to set 
> something in the gcc_options struct indicating that a particular option 
> should not be controlled by -ffast-math.
>
> (Various targets have linker specs 
> %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} and it would be 
> good if in future they could be based on logical state of 
> flag_unsafe_math_optimizations in the driver, so knowing these 
> implications in the driver is potentially useful.  But certainly such 
> driver processing can only operate with language-independent defaults 
> since it may be linking a multi-language program.)

OK, here is an approach more along those lines.

I am currently bootstrapping and testing this with all default languages
(except Java) on x86_64-unknown-linux-gnu, but I expect no problems as a
bootstrap with Go has succeeded.  Is this patch OK if bootstrap and
testing succeeds?

Ian


2011-02-07  Ian Lance Taylor  <iant@google.com>

	* common.opt (fcx-limited-range): Add SetByCombined flag.
	(ffinite-math-only, fmath-errno, frounding-math): Likewise.
	(fsignaling-nans, fsigned-zeros, ftrapping-math): Likewise.
	(fassociative-math, freciprocal-math): Likewise.
	(funsafe-math-optimizations): Likewise.
	* opth-gen.awk: Handle SetByCombined.
	* optc-gen.awk: Likewise.
	* opts.c (set_fast_math_flags): Don't override flag if set by
	frontend.
	(set_unsafe_math_optimizations_flags): Likewise.
	* doc/options.texi (Option properties): Document SetByCombined.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 8640 bytes
Desc: patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110207/a5aed869/attachment.bin>


More information about the Gcc-patches mailing list