This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PING] for 4.3 patches

On 11/14/06, Roger Sayle <> wrote:

The one part I think I would like to see changed though, is the
influence of -ffast-math on the ABI.  I think that for externally
visible global scope functions we either select the x87 API or
the SSE API for parameter passsing, and stick to it.  Now that this
is an attribute, we can even set it on a function by function basis.
The optimization level and the affect flag_unsafe_math_optimizations
should be irrelevant.  Fortunately, for local static functions we
can choose arbitrarily, as we can do for integer register passing
conventions, and this internal change may be passed upon -ffast-math
or -ffancy-math-387 or eventually (in an ideal world) the preferences
selected by the register allocator.

For local static functions I propose that register passing still depend on -funsafe-math, but on the other hand, we currently inline these functions without considering float truncation effects. I think that by depending on -funsafe-math, we won't regress in any way for DFmode and SFmode arguments for -fno-unsafe-math.

I just think its a bit beyond my comfort zone to disallow -ffast-math
executables to be linked to non -ffast-math libraries and vice/versa.
Adding the attribute however is an excellent idea.

Any chance I could ask you to isolate this controversial aspect of
your patch and propose it separately?

Sure, attached is a second version of the patch, where arguments are passed unconditionally for -mx87regparm and when x87regparm attribute is specified to the function. For local static functions, arguments are passed in DFmode and SFmode only when -funsafe-math-optimizations is added, and XFmode arguments are always passed in register.

Not sure if anyone has given it any thought, but in theory it may
eventually be possible to call and link to legacy 32-bit libraries
by suitably marking the API points with a suitable attribute?

I have proposed such a patch for x86_64, and was rejected.

Sorry to be a pain. Was there a strong reason to control this via -funsafe-math-optimizations? If we really need to differentiate an XFmode x87 vs a SF/DF/XFmode x87 then we probably need another attribute, command line option or -mabi option.

The rationale for -funsafe-math dependency was because of inherent float truncation when arguments are passed through memory. But since this is controlled by an attribute (or -mx87regparm switch) dependency on -funsafe-math can be removed on the ground that the user knows what this means for the passed values.

2006-11-15 Uros Bizjak <>

* config/i386/i386.opt: New target option -mx87regparm.

	* config/i386/i386.h (struct ix86_args): Add x87_nregs, x87_regno,
	float_in_x87: Add new variables. mmx_words, sse_words: Remove.
	(X87_REGPARM_MAX): Define.

	* config/i386/i386.c (override_options): Error out for
	-mx87regparm but no 80387 support.
	(ix86_attribute_table): Add x87regparm.
	(ix86_handle_cconv_attribute): Update comments for x87regparm.
	(ix86_comp_type_attributes): Check for mismatched x87regparm types.
	(ix86_function_x87regparm): New function.
	(ix86_function_arg_regno_p): Add X87_REGPARM_MAX 80387 floating
	point registers.
	(init_cumulative_args): Initialize x87_nregs and float_in_x87
	(function_arg_advance): Process x87_nregs and x87_regno when
	floating point argument is to be passed in 80387 register.
	(function_arg): Pass XFmode arguments in 80387 registers for local
	functions.  Pass SFmode and DFmode arguments to local functions
	in 80387 registers when flag_unsafe_math_optimizations is set.

	* reg-stack.c (convert_regs_entry): Disable NaN load for
	stack registers that are used for argument passing.

	* doc/extend.texi: Document x87regparm function attribute.
	* doc/invoke.texi: Document -mx87regparm.


2006-11-15 Uros Bizjak <>

	* New test.
	* New test.
	* New test.
	* New test.

Patch was bootstrapped on i686-pc-linux-gnu and regression tested for
c,c++ and fortran.

Thanks for the review and suggestions,

Attachment: i386-x87regparm-2.diff
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]