This is the mail archive of the gcc-patches@gcc.gnu.org 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: [PATCH, version 4], Add support for _Float<N> and _Float<N>X sqrt, fma, fmin, fmax built-in functions


On Tue, Oct 24, 2017 at 11:08:15PM +0000, Joseph Myers wrote:
> On Tue, 24 Oct 2017, Michael Meissner wrote:
> 
> > This patch adds a new switch (-fimplicit-math-floatn) that when enabled, it
> > will add implicit declarations for copysign, fabs, fma, fmax, fmin, nan, and
> > sqrt _Float<N> and _Float<N>X variants.  Like the previous patch, it adds fma,
> > fmax, fmin, and sqrt builtins to the machine independent built-in support, and
> > removed the PowerPC specific __builtin_{sqrt,fma}f128 functions.
> 
> I don't see why this new option is needed.  My expectation would be to use 
> DEF_EXT_LIB_BUILTIN, as discussed before (i.e. declare the non-__builtin_* 
> variants by default, but not if flag_iso).
> 
> That they should be declared by default is clear, in line with the normal 
> principle of enabling GNU extensions by default.  That they should not be 
> declared with existing -std=c11 etc. options is also clear.  Sometimes 
> there may be a use for an option to enable particular features of a TS 
> (e.g. -fpermitted-flt-eval-methods=ts-18661-3, 
> -fno-fp-int-builtin-inexact), I just don't see the requirement for it in 
> this particular case.  Of course, if in future TS 18661-3 gets added to 
> C2x, such built-in functions could be enabled for -std=c2x, subject to any 
> questions of the circumstances under which their names are reserved if the 
> relevant feature test macros are not defined.

This patch removes the -fimplicit-math-floatn switch that I put in the previous
patch.  It makes copysign, fabs, fma, fmax, fmin, nan, and sqrt have implicit
_Float<N> and _Float<N>X variants unless we are in strict ANSI/ISO mode.
Huge_val, inf, and nans do not get implicit functions created.

I have checked this on a little endian power8 system and an x86-64 system.
There were no regressions.  Can I check this into the trunk?

[gcc]
2017-10-25  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* builtins.c (CASE_MATHFN_FLOATN): New helper macro to add cases
	for math functions that have _Float<N> and _Float<N>X variants.
	(mathfn_built_in_2): Add support for math functions that have
	_Float<N> and _Float<N>X variants.
	(DEF_INTERNAL_FLT_FLOATN_FN): New helper macro.
	(expand_builtin_mathfn_ternary): Add support for fma with
	_Float<N> and _Float<N>X variants.
	(expand_builtin): Likewise.
	(fold_builtin_3): Likewise.
	* builtins.def (DEF_EXT_LIB_FLOATN_NX_BUILTINS): New macro to
	create math function _Float<N> and _Float<N>X variants as external
	library builtins.
	(BUILT_IN_COPYSIGN _Float<N> and _Float<N>X variants) Use
	DEF_EXT_LIB_FLOATN_NX_BUILTINS to make built-in functions using
	the __builtin_ prefix and if not strict ansi, without the prefix.
	(BUILT_IN_FABS _Float<N> and _Float<N>X variants): Likewise.
	(BUILT_IN_FMA _Float<N> and _Float<N>X variants): Likewise.
	(BUILT_IN_FMAX _Float<N> and _Float<N>X variants): Likewise.
	(BUILT_IN_FMIN _Float<N> and _Float<N>X variants): Likewise.
	(BUILT_IN_NAN _Float<N> and _Float<N>X variants): Likewise.
	(BUILT_IN_SQRT _Float<N> and _Float<N>X variants): Likewise.
	* builtin-types.def (BT_FN_FLOAT16_FLOAT16_FLOAT16_FLOAT16): New
	function signatures for fma _Float<N> and _Float<N>X variants.
	(BT_FN_FLOAT32_FLOAT32_FLOAT32_FLOAT32): Likewise.
	(BT_FN_FLOAT64_FLOAT64_FLOAT64_FLOAT64): Likewise.
	(BT_FN_FLOAT128_FLOAT128_FLOAT128_FLOAT128): Likewise.
	(BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_FLOAT32X): Likewise.
	(BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_FLOAT64X): Likewise.
	(BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_FLOAT128X): Likewise.
	* fold-const.c (tree_call_nonnegative_warnv_p): Add support for
	copysign, fma, fmax, fmin, and sqrt _Float<N> and _Float<N>X
	variants.
	(integer_valued_read_call_p): Likewise.
	* fold-const-call.c (fold_const_call_ss): Likewise.
	(fold_const_call_sss): Add support for copysign, fmin, and fmax
	_Float<N> and _Float<N>X variants.
	(fold_const_call_ssss): Add support for fma _Float<N> and
	_Float<N>X variants.
	* gencfn-macros.c (print_case_cfn): Add support for math functions
	that have _Float<N> and _Float<N>X variants.
	(print_define_operator_list): Likewise.
	(fltfn_suffixes): Likewise.
	(main): Likewise.
	* gimple-ssa-backprop.c (backprop::process_builtin_call_use): Add
	support for copysign and fma _Float<N> and _Float<N>X variants.
	(backprop::process_builtin_call_use): Likewise.
	* internal-fn.def (DEF_INTERNAL_FLT_FLOATN_FN): New helper macro
	for math functions that have _Float<N> and _Float<N>X variants.
	(SQRT): Add support for sqrt, copysign, fmin and fmax _Float<N>
	and _Float<N>X variants.
	(COPYSIGN): Likewise.
	(FMIN): Likewise.
	(FMAX): Likewise.
	* tree-call-cdce.c (can_test_argument_range); Add support for
	sqrt _Float<N> and _Float<N>X variants.
	(edom_only_function): Likewise.
	(get_no_error_domain): Likewise.
	* tree-ssa-math-opts.c (internal_fn_reciprocal): Likewise.
	* tree-ssa-reassoc.c (attempt_builtin_copysign): Add support for
	copysign _Float<N> and _Float<N>X variants.
	* config/rs6000/rs6000-builtin.def (SQRTF128): Delete, this is now
	handled by machine independent code.
	(FMAF128): Likewise.

[gcc/c]
2017-10-25  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* c-decl.c (header_for_builtin_fn): Add support for copysign, fma,
	fmax, fmin, and sqrt _Float<N> and _Float<N>X variants.

[gcc/c-family]
2017-10-25  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* c-cppbuiltin.c (mode_has_fma): Add support for PowerPC KFmode.
	(c_cpp_builtins): If -fimplicit-math-floatn and the machine has a
	fast fma _Float<N> and _Float<N>X variant, define __FP_FAST_FMA<N>
	and __FP_FAST_FMA<N>X.
	* c.opt (-fimplicit-math-floatn): New switch to enable making
	_Float<N> and _Float<N>X variant math functions implicitly
	declared without the __builtin_ prefix.

[gcc/testsuite]
2017-10-25  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* gcc.target/powerpc/float128-hw.c: Add support for all 4 FMA
	variants.  Check various conversions to/from float128.  Check
	negation.  Use {\m...\M} in the tests.
	* gcc.target/powerpc/float128-hw2.c: New test for implicit
	_Float128 math functions.
	* gcc.target/powerpc/float128-hw3.c: New test for strict ansi mode
	not implicitly adding the _Float128 math functions.
	* gcc.target/powerpc/float128-fma2.c: Delete, test is no longer
	valid.
	* gcc.target/powerpc/float128-sqrt2.c: Likewise.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797

Attachment: ieee128-patch45b
Description: Text document


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