summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-27 18:15:38 +0000
committermeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-27 18:15:38 +0000
commit8c32188e45aaa36cd0c8b7311cf4db383cc5a43d (patch)
treeb4520775062aec903a9f6e5ee44e864f4afa4b97
parente5496d25a3e92fdcbc85318e512525e7ab55aeb0 (diff)
downloadgcc-8c32188e45aaa36cd0c8b7311cf4db383cc5a43d.tar.gz
[gcc]
2017-10-27 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. * 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. * 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. * 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. * 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. * 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. * doc/cpp.texi (Common Predefined Macros): Document defining __FP_FAST_FMAF<N> and __FP_FAST_FMAF<N>X if the backend supports fma _Float<N> and _Float<N>X variants. [gcc/c] 2017-10-27 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-27 Michael Meissner <meissner@linux.vnet.ibm.com> * c-cppbuiltin.c (mode_has_fma): Add support for PowerPC KFmode. (c_cpp_builtins): If a machine has a fast fma _Float<N> and _Float<N>X variant, define __FP_FAST_FMA<N> and/or __FP_FAST_FMA<N>X. [gcc/testsuite] 2017-10-27 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254168 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog69
-rw-r--r--gcc/builtin-types.def14
-rw-r--r--gcc/builtins.c65
-rw-r--r--gcc/builtins.def33
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-cppbuiltin.c7
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-decl.c6
-rw-r--r--gcc/config/rs6000/rs6000-builtin.def6
-rw-r--r--gcc/doc/cpp.texi15
-rw-r--r--gcc/fold-const-call.c5
-rw-r--r--gcc/fold-const.c6
-rw-r--r--gcc/gencfn-macros.c50
-rw-r--r--gcc/gimple-ssa-backprop.c3
-rw-r--r--gcc/internal-fn.def14
-rw-r--r--gcc/testsuite/ChangeLog13
-rw-r--r--gcc/testsuite/gcc.target/powerpc/float128-fma2.c9
-rw-r--r--gcc/testsuite/gcc.target/powerpc/float128-hw.c66
-rw-r--r--gcc/testsuite/gcc.target/powerpc/float128-hw2.c60
-rw-r--r--gcc/testsuite/gcc.target/powerpc/float128-hw3.c56
-rw-r--r--gcc/testsuite/gcc.target/powerpc/float128-sqrt2.c9
-rw-r--r--gcc/tree-call-cdce.c3
-rw-r--r--gcc/tree-ssa-math-opts.c1
-rw-r--r--gcc/tree-ssa-reassoc.c1
24 files changed, 454 insertions, 69 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7c3f1e54590..1286c91b590 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,72 @@
+2017-10-27 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.
+ * 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.
+ * 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.
+ * 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.
+ * 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.
+ * 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.
+ * doc/cpp.texi (Common Predefined Macros): Document defining
+ __FP_FAST_FMAF<N> and __FP_FAST_FMAF<N>X if the backend supports
+ fma _Float<N> and _Float<N>X variants.
+
2017-10-27 Uros Bizjak <ubizjak@gmail.com>
PR target/82692
diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def
index 18946033502..877f2aef424 100644
--- a/gcc/builtin-types.def
+++ b/gcc/builtin-types.def
@@ -544,6 +544,20 @@ DEF_FUNCTION_TYPE_3 (BT_FN_DOUBLE_DOUBLE_DOUBLE_DOUBLE,
BT_DOUBLE, BT_DOUBLE, BT_DOUBLE, BT_DOUBLE)
DEF_FUNCTION_TYPE_3 (BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE,
BT_LONGDOUBLE, BT_LONGDOUBLE, BT_LONGDOUBLE, BT_LONGDOUBLE)
+DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT16_FLOAT16_FLOAT16_FLOAT16,
+ BT_FLOAT16, BT_FLOAT16, BT_FLOAT16, BT_FLOAT16)
+DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT32_FLOAT32_FLOAT32_FLOAT32,
+ BT_FLOAT32, BT_FLOAT32, BT_FLOAT32, BT_FLOAT32)
+DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT64_FLOAT64_FLOAT64_FLOAT64,
+ BT_FLOAT64, BT_FLOAT64, BT_FLOAT64, BT_FLOAT64)
+DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT128_FLOAT128_FLOAT128_FLOAT128,
+ BT_FLOAT128, BT_FLOAT128, BT_FLOAT128, BT_FLOAT128)
+DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_FLOAT32X,
+ BT_FLOAT32X, BT_FLOAT32X, BT_FLOAT32X, BT_FLOAT32X)
+DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_FLOAT64X,
+ BT_FLOAT64X, BT_FLOAT64X, BT_FLOAT64X, BT_FLOAT64X)
+DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_FLOAT128X,
+ BT_FLOAT128X, BT_FLOAT128X, BT_FLOAT128X, BT_FLOAT128X)
DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT_FLOAT_FLOAT_INTPTR,
BT_FLOAT, BT_FLOAT, BT_FLOAT, BT_INT_PTR)
DEF_FUNCTION_TYPE_3 (BT_FN_DOUBLE_DOUBLE_DOUBLE_INTPTR,
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 29778fc50c3..a677705acad 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1816,14 +1816,26 @@ expand_builtin_classify_type (tree exp)
return GEN_INT (no_type_class);
}
-/* This helper macro, meant to be used in mathfn_built_in below,
- determines which among a set of three builtin math functions is
- appropriate for a given type mode. The `F' and `L' cases are
- automatically generated from the `double' case. */
+/* This helper macro, meant to be used in mathfn_built_in below, determines
+ which among a set of builtin math functions is appropriate for a given type
+ mode. The `F' (float) and `L' (long double) are automatically generated
+ from the 'double' case. If a function supports the _Float<N> and _Float<N>X
+ types, there are additional types that are considered with 'F32', 'F64',
+ 'F128', etc. suffixes. */
#define CASE_MATHFN(MATHFN) \
CASE_CFN_##MATHFN: \
fcode = BUILT_IN_##MATHFN; fcodef = BUILT_IN_##MATHFN##F ; \
fcodel = BUILT_IN_##MATHFN##L ; break;
+/* Similar to the above, but also add support for the _Float<N> and _Float<N>X
+ types. */
+#define CASE_MATHFN_FLOATN(MATHFN) \
+ CASE_CFN_##MATHFN: \
+ fcode = BUILT_IN_##MATHFN; fcodef = BUILT_IN_##MATHFN##F ; \
+ fcodel = BUILT_IN_##MATHFN##L ; fcodef16 = BUILT_IN_##MATHFN##F16 ; \
+ fcodef32 = BUILT_IN_##MATHFN##F32; fcodef64 = BUILT_IN_##MATHFN##F64 ; \
+ fcodef128 = BUILT_IN_##MATHFN##F128 ; fcodef32x = BUILT_IN_##MATHFN##F32X ; \
+ fcodef64x = BUILT_IN_##MATHFN##F64X ; fcodef128x = BUILT_IN_##MATHFN##F128X ;\
+ break;
/* Similar to above, but appends _R after any F/L suffix. */
#define CASE_MATHFN_REENT(MATHFN) \
case CFN_BUILT_IN_##MATHFN##_R: \
@@ -1840,7 +1852,15 @@ expand_builtin_classify_type (tree exp)
static built_in_function
mathfn_built_in_2 (tree type, combined_fn fn)
{
+ tree mtype;
built_in_function fcode, fcodef, fcodel;
+ built_in_function fcodef16 = END_BUILTINS;
+ built_in_function fcodef32 = END_BUILTINS;
+ built_in_function fcodef64 = END_BUILTINS;
+ built_in_function fcodef128 = END_BUILTINS;
+ built_in_function fcodef32x = END_BUILTINS;
+ built_in_function fcodef64x = END_BUILTINS;
+ built_in_function fcodef128x = END_BUILTINS;
switch (fn)
{
@@ -1854,7 +1874,7 @@ mathfn_built_in_2 (tree type, combined_fn fn)
CASE_MATHFN (CBRT)
CASE_MATHFN (CEIL)
CASE_MATHFN (CEXPI)
- CASE_MATHFN (COPYSIGN)
+ CASE_MATHFN_FLOATN (COPYSIGN)
CASE_MATHFN (COS)
CASE_MATHFN (COSH)
CASE_MATHFN (DREM)
@@ -1867,9 +1887,9 @@ mathfn_built_in_2 (tree type, combined_fn fn)
CASE_MATHFN (FABS)
CASE_MATHFN (FDIM)
CASE_MATHFN (FLOOR)
- CASE_MATHFN (FMA)
- CASE_MATHFN (FMAX)
- CASE_MATHFN (FMIN)
+ CASE_MATHFN_FLOATN (FMA)
+ CASE_MATHFN_FLOATN (FMAX)
+ CASE_MATHFN_FLOATN (FMIN)
CASE_MATHFN (FMOD)
CASE_MATHFN (FREXP)
CASE_MATHFN (GAMMA)
@@ -1923,7 +1943,7 @@ mathfn_built_in_2 (tree type, combined_fn fn)
CASE_MATHFN (SIN)
CASE_MATHFN (SINCOS)
CASE_MATHFN (SINH)
- CASE_MATHFN (SQRT)
+ CASE_MATHFN_FLOATN (SQRT)
CASE_MATHFN (TAN)
CASE_MATHFN (TANH)
CASE_MATHFN (TGAMMA)
@@ -1936,12 +1956,27 @@ mathfn_built_in_2 (tree type, combined_fn fn)
return END_BUILTINS;
}
- if (TYPE_MAIN_VARIANT (type) == double_type_node)
+ mtype = TYPE_MAIN_VARIANT (type);
+ if (mtype == double_type_node)
return fcode;
- else if (TYPE_MAIN_VARIANT (type) == float_type_node)
+ else if (mtype == float_type_node)
return fcodef;
- else if (TYPE_MAIN_VARIANT (type) == long_double_type_node)
+ else if (mtype == long_double_type_node)
return fcodel;
+ else if (mtype == float16_type_node)
+ return fcodef16;
+ else if (mtype == float32_type_node)
+ return fcodef32;
+ else if (mtype == float64_type_node)
+ return fcodef64;
+ else if (mtype == float128_type_node)
+ return fcodef128;
+ else if (mtype == float32x_type_node)
+ return fcodef32x;
+ else if (mtype == float64x_type_node)
+ return fcodef64x;
+ else if (mtype == float128x_type_node)
+ return fcodef128x;
else
return END_BUILTINS;
}
@@ -1995,6 +2030,9 @@ associated_internal_fn (tree fndecl)
{
#define DEF_INTERNAL_FLT_FN(NAME, FLAGS, OPTAB, TYPE) \
CASE_FLT_FN (BUILT_IN_##NAME): return IFN_##NAME;
+#define DEF_INTERNAL_FLT_FLOATN_FN(NAME, FLAGS, OPTAB, TYPE) \
+ CASE_FLT_FN (BUILT_IN_##NAME): return IFN_##NAME; \
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_##NAME): return IFN_##NAME;
#define DEF_INTERNAL_INT_FN(NAME, FLAGS, OPTAB, TYPE) \
CASE_INT_FN (BUILT_IN_##NAME): return IFN_##NAME;
#include "internal-fn.def"
@@ -2068,6 +2106,7 @@ expand_builtin_mathfn_ternary (tree exp, rtx target, rtx subtarget)
switch (DECL_FUNCTION_CODE (fndecl))
{
CASE_FLT_FN (BUILT_IN_FMA):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
builtin_optab = fma_optab; break;
default:
gcc_unreachable ();
@@ -6567,6 +6606,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode,
break;
CASE_FLT_FN (BUILT_IN_FMA):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
target = expand_builtin_mathfn_ternary (exp, target, subtarget);
if (target)
return target;
@@ -8996,6 +9036,7 @@ fold_builtin_3 (location_t loc, tree fndecl,
return fold_builtin_sincos (loc, arg0, arg1, arg2);
CASE_FLT_FN (BUILT_IN_FMA):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
return fold_builtin_fma (loc, arg0, arg1, arg2, type);
CASE_FLT_FN (BUILT_IN_REMQUO):
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 88025942206..1434f07853c 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -128,6 +128,21 @@ along with GCC; see the file COPYING3. If not see
DEF_BUILTIN_CHKP (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, \
TYPE, true, true, true, ATTRS, false, true)
+/* A set of GCC builtins for _FloatN and _FloatNx types. TYPE_MACRO is called
+ with an argument such as FLOAT32 to produce the enum value for the type. If
+ we are being fully conformant we ignore the version of these builtins that
+ does not being with __builtin_. */
+#undef DEF_EXT_LIB_FLOATN_NX_BUILTINS
+#define DEF_EXT_LIB_FLOATN_NX_BUILTINS(ENUM, NAME, TYPE_MACRO, ATTRS) \
+ DEF_EXT_LIB_BUILTIN (ENUM ## F16, NAME "f16", TYPE_MACRO (FLOAT16), ATTRS) \
+ DEF_EXT_LIB_BUILTIN (ENUM ## F32, NAME "f32", TYPE_MACRO (FLOAT32), ATTRS) \
+ DEF_EXT_LIB_BUILTIN (ENUM ## F64, NAME "f64", TYPE_MACRO (FLOAT64), ATTRS) \
+ DEF_EXT_LIB_BUILTIN (ENUM ## F128, NAME "f128", TYPE_MACRO (FLOAT128), ATTRS)\
+ DEF_EXT_LIB_BUILTIN (ENUM ## F32X, NAME "f32x", TYPE_MACRO (FLOAT32X), ATTRS)\
+ DEF_EXT_LIB_BUILTIN (ENUM ## F64X, NAME "f64x", TYPE_MACRO (FLOAT64X), ATTRS)\
+ DEF_EXT_LIB_BUILTIN (ENUM ## F128X, NAME "f128x", TYPE_MACRO (FLOAT128X), \
+ ATTRS)
+
/* Like DEF_LIB_BUILTIN, except that the function is only a part of
the standard in C94 or above. */
#undef DEF_C94_BUILTIN
@@ -324,7 +339,7 @@ DEF_C99_BUILTIN (BUILT_IN_COPYSIGN, "copysign", BT_FN_DOUBLE_DOUBLE_DOUBL
DEF_C99_BUILTIN (BUILT_IN_COPYSIGNF, "copysignf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_COPYSIGNL, "copysignl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
#define COPYSIGN_TYPE(F) BT_FN_##F##_##F##_##F
-DEF_GCC_FLOATN_NX_BUILTINS (BUILT_IN_COPYSIGN, "copysign", COPYSIGN_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_COPYSIGN, "copysign", COPYSIGN_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
#undef COPYSIGN_TYPE
DEF_LIB_BUILTIN (BUILT_IN_COS, "cos", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
DEF_C99_C90RES_BUILTIN (BUILT_IN_COSF, "cosf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING)
@@ -357,7 +372,7 @@ DEF_LIB_BUILTIN (BUILT_IN_FABS, "fabs", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_N
DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSF, "fabsf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSL, "fabsl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
#define FABS_TYPE(F) BT_FN_##F##_##F
-DEF_GCC_FLOATN_NX_BUILTINS (BUILT_IN_FABS, "fabs", FABS_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_FABS, "fabs", FABS_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
#undef FABS_TYPE
DEF_GCC_BUILTIN (BUILT_IN_FABSD32, "fabsd32", BT_FN_DFLOAT32_DFLOAT32, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_GCC_BUILTIN (BUILT_IN_FABSD64, "fabsd64", BT_FN_DFLOAT64_DFLOAT64, ATTR_CONST_NOTHROW_LEAF_LIST)
@@ -382,12 +397,21 @@ DEF_C99_C90RES_BUILTIN (BUILT_IN_FLOORL, "floorl", BT_FN_LONGDOUBLE_LONGDOUBLE,
DEF_C99_BUILTIN (BUILT_IN_FMA, "fma", BT_FN_DOUBLE_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
DEF_C99_BUILTIN (BUILT_IN_FMAF, "fmaf", BT_FN_FLOAT_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING)
DEF_C99_BUILTIN (BUILT_IN_FMAL, "fmal", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
+#define FMA_TYPE(F) BT_FN_##F##_##F##_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_FMA, "fma", FMA_TYPE, ATTR_MATHFN_FPROUNDING)
+#undef FMA_TYPE
DEF_C99_BUILTIN (BUILT_IN_FMAX, "fmax", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMAXF, "fmaxf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMAXL, "fmaxl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#define FMAX_TYPE(F) BT_FN_##F##_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_FMAX, "fmax", FMAX_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef FMAX_TYPE
DEF_C99_BUILTIN (BUILT_IN_FMIN, "fmin", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMINF, "fminf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_C99_BUILTIN (BUILT_IN_FMINL, "fminl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#define FMIN_TYPE(F) BT_FN_##F##_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_FMIN, "fmin", FMIN_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef FMIN_TYPE
DEF_LIB_BUILTIN (BUILT_IN_FMOD, "fmod", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_C90RES_BUILTIN (BUILT_IN_FMODF, "fmodf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_C90RES_BUILTIN (BUILT_IN_FMODL, "fmodl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
@@ -495,7 +519,7 @@ DEF_C99_BUILTIN (BUILT_IN_NAN, "nan", BT_FN_DOUBLE_CONST_STRING, ATTR_CON
DEF_C99_BUILTIN (BUILT_IN_NANF, "nanf", BT_FN_FLOAT_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
DEF_C99_BUILTIN (BUILT_IN_NANL, "nanl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
#define NAN_TYPE(F) BT_FN_##F##_CONST_STRING
-DEF_GCC_FLOATN_NX_BUILTINS (BUILT_IN_NAN, "nan", NAN_TYPE, ATTR_CONST_NOTHROW_NONNULL)
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_NAN, "nan", NAN_TYPE, ATTR_CONST_NOTHROW_NONNULL)
DEF_GCC_BUILTIN (BUILT_IN_NAND32, "nand32", BT_FN_DFLOAT32_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
DEF_GCC_BUILTIN (BUILT_IN_NAND64, "nand64", BT_FN_DFLOAT64_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
DEF_GCC_BUILTIN (BUILT_IN_NAND128, "nand128", BT_FN_DFLOAT128_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
@@ -564,6 +588,9 @@ DEF_C99_C90RES_BUILTIN (BUILT_IN_SINL, "sinl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR
DEF_LIB_BUILTIN (BUILT_IN_SQRT, "sqrt", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_C90RES_BUILTIN (BUILT_IN_SQRTF, "sqrtf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
DEF_C99_C90RES_BUILTIN (BUILT_IN_SQRTL, "sqrtl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+#define SQRT_TYPE(F) BT_FN_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_SQRT, "sqrt", SQRT_TYPE, ATTR_MATHFN_FPROUNDING_ERRNO)
+#undef SQRT_TYPE
DEF_LIB_BUILTIN (BUILT_IN_TAN, "tan", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
DEF_C99_C90RES_BUILTIN (BUILT_IN_TANF, "tanf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING)
DEF_LIB_BUILTIN (BUILT_IN_TANH, "tanh", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 552c68084d7..e9c62e13495 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,10 @@
+2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ * c-cppbuiltin.c (mode_has_fma): Add support for PowerPC KFmode.
+ (c_cpp_builtins): If a machine has a fast fma _Float<N> and
+ _Float<N>X variant, define __FP_FAST_FMA<N> and/or
+ __FP_FAST_FMA<N>X.
+
2017-10-23 Marek Polacek <polacek@redhat.com>
PR c/82681
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 4330c9102d9..2ac9616b72f 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -82,6 +82,11 @@ mode_has_fma (machine_mode mode)
return !!HAVE_fmadf4;
#endif
+#ifdef HAVE_fmakf4 /* PowerPC if long double != __float128. */
+ case E_KFmode:
+ return !!HAVE_fmakf4;
+#endif
+
#ifdef HAVE_fmaxf4
case E_XFmode:
return !!HAVE_fmaxf4;
@@ -1119,7 +1124,7 @@ c_cpp_builtins (cpp_reader *pfile)
floatn_nx_types[i].extended ? "X" : "");
sprintf (csuffix, "F%d%s", floatn_nx_types[i].n,
floatn_nx_types[i].extended ? "x" : "");
- builtin_define_float_constants (prefix, csuffix, "%s", NULL,
+ builtin_define_float_constants (prefix, csuffix, "%s", csuffix,
FLOATN_NX_TYPE_NODE (i));
}
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 5d028b45490..fe450ec4331 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2017-10-27 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.
+
2017-10-25 David Malcolm <dmalcolm@redhat.com>
PR c/7356
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 90f07297a37..78405c85675 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -3163,6 +3163,7 @@ header_for_builtin_fn (enum built_in_function fcode)
CASE_FLT_FN (BUILT_IN_CBRT):
CASE_FLT_FN (BUILT_IN_CEIL):
CASE_FLT_FN (BUILT_IN_COPYSIGN):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_COPYSIGN):
CASE_FLT_FN (BUILT_IN_COS):
CASE_FLT_FN (BUILT_IN_COSH):
CASE_FLT_FN (BUILT_IN_ERF):
@@ -3171,11 +3172,15 @@ header_for_builtin_fn (enum built_in_function fcode)
CASE_FLT_FN (BUILT_IN_EXP2):
CASE_FLT_FN (BUILT_IN_EXPM1):
CASE_FLT_FN (BUILT_IN_FABS):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS):
CASE_FLT_FN (BUILT_IN_FDIM):
CASE_FLT_FN (BUILT_IN_FLOOR):
CASE_FLT_FN (BUILT_IN_FMA):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
CASE_FLT_FN (BUILT_IN_FMAX):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMAX):
CASE_FLT_FN (BUILT_IN_FMIN):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMIN):
CASE_FLT_FN (BUILT_IN_FMOD):
CASE_FLT_FN (BUILT_IN_FREXP):
CASE_FLT_FN (BUILT_IN_HYPOT):
@@ -3207,6 +3212,7 @@ header_for_builtin_fn (enum built_in_function fcode)
CASE_FLT_FN (BUILT_IN_SINH):
CASE_FLT_FN (BUILT_IN_SINCOS):
CASE_FLT_FN (BUILT_IN_SQRT):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
CASE_FLT_FN (BUILT_IN_TAN):
CASE_FLT_FN (BUILT_IN_TANH):
CASE_FLT_FN (BUILT_IN_TGAMMA):
diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def
index ac9ddae3ef0..98046752292 100644
--- a/gcc/config/rs6000/rs6000-builtin.def
+++ b/gcc/config/rs6000/rs6000-builtin.def
@@ -2374,17 +2374,13 @@ BU_FLOAT128_1 (FABSQ, "fabsq", CONST, abskf2)
BU_FLOAT128_2 (COPYSIGNQ, "copysignq", CONST, copysignkf3)
/* 1, 2, and 3 argument IEEE 128-bit floating point functions that require ISA
- 3.0 hardware. These functions use the new 'f128' suffix. Eventually the
- standard functions should be folded into the common built-in function
- handling. */
-BU_FLOAT128_1_HW (SQRTF128, "sqrtf128", CONST, sqrtkf2)
+ 3.0 hardware. These functions use the new 'f128' suffix. */
BU_FLOAT128_1_HW (SQRTF128_ODD, "sqrtf128_round_to_odd", CONST, sqrtkf2_odd)
BU_FLOAT128_1_HW (TRUNCF128_ODD, "truncf128_round_to_odd", CONST, trunckfdf2_odd)
BU_FLOAT128_2_HW (ADDF128_ODD, "addf128_round_to_odd", CONST, addkf3_odd)
BU_FLOAT128_2_HW (SUBF128_ODD, "subf128_round_to_odd", CONST, subkf3_odd)
BU_FLOAT128_2_HW (MULF128_ODD, "mulf128_round_to_odd", CONST, mulkf3_odd)
BU_FLOAT128_2_HW (DIVF128_ODD, "divf128_round_to_odd", CONST, divkf3_odd)
-BU_FLOAT128_3_HW (FMAF128, "fmaf128", CONST, fmakf4_hw)
BU_FLOAT128_3_HW (FMAF128_ODD, "fmaf128_round_to_odd", CONST, fmakf4_odd)
/* 1 argument crypto functions. */
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index 52f2606eadc..759532d1273 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -2366,6 +2366,21 @@ the include file @file{math.h} can define the macros
@code{FP_FAST_FMA}, @code{FP_FAST_FMAF}, and @code{FP_FAST_FMAL}
for compatibility with the 1999 C standard.
+@item __FP_FAST_FMAF16
+@itemx __FP_FAST_FMAF32
+@itemx __FP_FAST_FMAF64
+@itemx __FP_FAST_FMAF128
+@itemx __FP_FAST_FMAF32X
+@itemx __FP_FAST_FMAF64X
+@itemx __FP_FAST_FMAF128X
+These macros are defined with the value 1 if the backend supports the
+@code{fma} functions using the additional @code{_Float@var{n}} and
+@code{_Float@var{n}x} types that are defined in ISO/IEC TS
+18661-3:2015. The include file @file{math.h} can define the
+@code{FP_FAST_FMAF@var{n}} and @code{FP_FAST_FMAF@var{n}x} macros if
+the user defined @code{__STDC_WANT_IEC_60559_TYPES_EXT__} before
+including @file{math.h}.
+
@item __GCC_IEC_559
This macro is defined to indicate the intended level of support for
IEEE 754 (IEC 60559) floating-point arithmetic. It expands to a
diff --git a/gcc/fold-const-call.c b/gcc/fold-const-call.c
index 98ac0911743..f23b1bf28bd 100644
--- a/gcc/fold-const-call.c
+++ b/gcc/fold-const-call.c
@@ -596,6 +596,7 @@ fold_const_call_ss (real_value *result, combined_fn fn,
switch (fn)
{
CASE_CFN_SQRT:
+ CASE_CFN_SQRT_FN:
return (real_compare (GE_EXPR, arg, &dconst0)
&& do_mpfr_arg1 (result, mpfr_sqrt, arg, format));
@@ -1179,14 +1180,17 @@ fold_const_call_sss (real_value *result, combined_fn fn,
return do_mpfr_arg2 (result, mpfr_hypot, arg0, arg1, format);
CASE_CFN_COPYSIGN:
+ CASE_CFN_COPYSIGN_FN:
*result = *arg0;
real_copysign (result, arg1);
return true;
CASE_CFN_FMIN:
+ CASE_CFN_FMIN_FN:
return do_mpfr_arg2 (result, mpfr_min, arg0, arg1, format);
CASE_CFN_FMAX:
+ CASE_CFN_FMAX_FN:
return do_mpfr_arg2 (result, mpfr_max, arg0, arg1, format);
CASE_CFN_POW:
@@ -1473,6 +1477,7 @@ fold_const_call_ssss (real_value *result, combined_fn fn,
switch (fn)
{
CASE_CFN_FMA:
+ CASE_CFN_FMA_FN:
return do_mpfr_arg3 (result, mpfr_fma, arg0, arg1, arg2, format);
default:
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9db5aeb8425..1109f5e3bc5 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -12773,6 +12773,7 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1,
return true;
CASE_CFN_SQRT:
+ CASE_CFN_SQRT_FN:
/* sqrt(-0.0) is -0.0. */
if (!HONOR_SIGNED_ZEROS (element_mode (type)))
return true;
@@ -12817,14 +12818,17 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1,
return RECURSE (arg0);
CASE_CFN_FMAX:
+ CASE_CFN_FMAX_FN:
/* True if the 1st OR 2nd arguments are nonnegative. */
return RECURSE (arg0) || RECURSE (arg1);
CASE_CFN_FMIN:
+ CASE_CFN_FMIN_FN:
/* True if the 1st AND 2nd arguments are nonnegative. */
return RECURSE (arg0) && RECURSE (arg1);
CASE_CFN_COPYSIGN:
+ CASE_CFN_COPYSIGN_FN:
/* True if the 2nd argument is nonnegative. */
return RECURSE (arg1);
@@ -13323,7 +13327,9 @@ integer_valued_real_call_p (combined_fn fn, tree arg0, tree arg1, int depth)
return true;
CASE_CFN_FMIN:
+ CASE_CFN_FMIN_FN:
CASE_CFN_FMAX:
+ CASE_CFN_FMAX_FN:
return RECURSE (arg0) && RECURSE (arg1);
default:
diff --git a/gcc/gencfn-macros.c b/gcc/gencfn-macros.c
index 269429fabfc..5b38ac20a4d 100644
--- a/gcc/gencfn-macros.c
+++ b/gcc/gencfn-macros.c
@@ -98,11 +98,12 @@ is_group (string_set *builtins, const char *name, const char *const *suffixes)
static void
print_case_cfn (const char *name, bool internal_p,
- const char *const *suffixes)
+ const char *const *suffixes, bool floatn_p)
{
- printf ("#define CASE_CFN_%s", name);
+ const char *floatn = (floatn_p) ? "_FN" : "";
+ printf ("#define CASE_CFN_%s%s", name, floatn);
if (internal_p)
- printf (" \\\n case CFN_%s", name);
+ printf (" \\\n case CFN_%s%s", name, floatn);
for (unsigned int i = 0; suffixes[i]; ++i)
printf ("%s \\\n case CFN_BUILT_IN_%s%s",
internal_p || i > 0 ? ":" : "", name, suffixes[i]);
@@ -115,9 +116,10 @@ print_case_cfn (const char *name, bool internal_p,
static void
print_define_operator_list (const char *name, bool internal_p,
- const char *const *suffixes)
+ const char *const *suffixes, bool floatn_p)
{
- printf ("(define_operator_list %s\n", name);
+ const char *floatn = (floatn_p) ? "_FN" : "";
+ printf ("(define_operator_list %s%s\n", name, floatn);
for (unsigned int i = 0; suffixes[i]; ++i)
printf (" BUILT_IN_%s%s\n", name, suffixes[i]);
if (internal_p)
@@ -148,6 +150,8 @@ const char *const internal_fn_int_names[] = {
};
static const char *const flt_suffixes[] = { "F", "", "L", NULL };
+static const char *const fltfn_suffixes[] = { "F16", "F32", "F64", "F128",
+ "F32X", "F64X", "F128X", NULL };
static const char *const int_suffixes[] = { "", "L", "LL", "IMAX", NULL };
static const char *const *const suffix_lists[] = {
@@ -200,15 +204,33 @@ main (int argc, char **argv)
{
const char *root = name + 9;
for (unsigned int j = 0; suffix_lists[j]; ++j)
- if (is_group (&builtins, root, suffix_lists[j]))
- {
- bool internal_p = internal_fns.contains (root);
- if (type == 'c')
- print_case_cfn (root, internal_p, suffix_lists[j]);
- else
- print_define_operator_list (root, internal_p,
- suffix_lists[j]);
- }
+ {
+ const char *const *const suffix = suffix_lists[j];
+
+ if (is_group (&builtins, root, suffix))
+ {
+ bool internal_p = internal_fns.contains (root);
+
+ if (type == 'c')
+ print_case_cfn (root, internal_p, suffix, false);
+ else
+ print_define_operator_list (root, internal_p,
+ suffix, false);
+
+ /* Support the _Float<N> and _Float<N>X math functions if
+ they exist. We put these out as a separate CFN macro,
+ so code can add support or not as needed. */
+ if (suffix == flt_suffixes
+ && is_group (&builtins, root, fltfn_suffixes))
+ {
+ if (type == 'c')
+ print_case_cfn (root, false, fltfn_suffixes, true);
+ else
+ print_define_operator_list (root, false, fltfn_suffixes,
+ true);
+ }
+ }
+ }
}
}
diff --git a/gcc/gimple-ssa-backprop.c b/gcc/gimple-ssa-backprop.c
index f321ebb3817..1daa0ceef0a 100644
--- a/gcc/gimple-ssa-backprop.c
+++ b/gcc/gimple-ssa-backprop.c
@@ -354,6 +354,7 @@ backprop::process_builtin_call_use (gcall *call, tree rhs, usage_info *info)
break;
CASE_CFN_COPYSIGN:
+ CASE_CFN_COPYSIGN_FN:
/* The sign of the first input is ignored. */
if (rhs != gimple_call_arg (call, 1))
info->flags.ignore_sign = true;
@@ -373,6 +374,7 @@ backprop::process_builtin_call_use (gcall *call, tree rhs, usage_info *info)
}
CASE_CFN_FMA:
+ CASE_CFN_FMA_FN:
/* In X * X + Y, where Y is distinct from X, the sign of X doesn't
matter. */
if (gimple_call_arg (call, 0) == rhs
@@ -689,6 +691,7 @@ strip_sign_op_1 (tree rhs)
switch (gimple_call_combined_fn (call))
{
CASE_CFN_COPYSIGN:
+ CASE_CFN_COPYSIGN_FN:
return gimple_call_arg (call, 0);
default:
diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
index e21e125a339..dcb276e4632 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -80,6 +80,11 @@ along with GCC; see the file COPYING3. If not see
DEF_INTERNAL_OPTAB_FN (NAME, FLAGS, OPTAB, TYPE)
#endif
+#ifndef DEF_INTERNAL_FLT_FLOATN_FN
+#define DEF_INTERNAL_FLT_FLOATN_FN(NAME, FLAGS, OPTAB, TYPE) \
+ DEF_INTERNAL_FLT_FN (NAME, FLAGS, OPTAB, TYPE)
+#endif
+
#ifndef DEF_INTERNAL_INT_FN
#define DEF_INTERNAL_INT_FN(NAME, FLAGS, OPTAB, TYPE) \
DEF_INTERNAL_OPTAB_FN (NAME, FLAGS, OPTAB, TYPE)
@@ -109,7 +114,7 @@ DEF_INTERNAL_FLT_FN (LOG2, ECF_CONST, log2, unary)
DEF_INTERNAL_FLT_FN (LOGB, ECF_CONST, logb, unary)
DEF_INTERNAL_FLT_FN (SIGNIFICAND, ECF_CONST, significand, unary)
DEF_INTERNAL_FLT_FN (SIN, ECF_CONST, sin, unary)
-DEF_INTERNAL_FLT_FN (SQRT, ECF_CONST, sqrt, unary)
+DEF_INTERNAL_FLT_FLOATN_FN (SQRT, ECF_CONST, sqrt, unary)
DEF_INTERNAL_FLT_FN (TAN, ECF_CONST, tan, unary)
/* FP rounding. */
@@ -122,13 +127,13 @@ DEF_INTERNAL_FLT_FN (TRUNC, ECF_CONST, btrunc, unary)
/* Binary math functions. */
DEF_INTERNAL_FLT_FN (ATAN2, ECF_CONST, atan2, binary)
-DEF_INTERNAL_FLT_FN (COPYSIGN, ECF_CONST, copysign, binary)
+DEF_INTERNAL_FLT_FLOATN_FN (COPYSIGN, ECF_CONST, copysign, binary)
DEF_INTERNAL_FLT_FN (FMOD, ECF_CONST, fmod, binary)
DEF_INTERNAL_FLT_FN (POW, ECF_CONST, pow, binary)
DEF_INTERNAL_FLT_FN (REMAINDER, ECF_CONST, remainder, binary)
DEF_INTERNAL_FLT_FN (SCALB, ECF_CONST, scalb, binary)
-DEF_INTERNAL_FLT_FN (FMIN, ECF_CONST, fmin, binary)
-DEF_INTERNAL_FLT_FN (FMAX, ECF_CONST, fmax, binary)
+DEF_INTERNAL_FLT_FLOATN_FN (FMIN, ECF_CONST, fmin, binary)
+DEF_INTERNAL_FLT_FLOATN_FN (FMAX, ECF_CONST, fmax, binary)
DEF_INTERNAL_OPTAB_FN (XORSIGN, ECF_CONST, xorsign, binary)
/* FP scales. */
@@ -230,5 +235,6 @@ DEF_INTERNAL_FN (DIVMOD, ECF_CONST | ECF_LEAF, NULL)
#undef DEF_INTERNAL_INT_FN
#undef DEF_INTERNAL_FLT_FN
+#undef DEF_INTERNAL_FLT_FLOATN_FN
#undef DEF_INTERNAL_OPTAB_FN
#undef DEF_INTERNAL_FN
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f227e7ec36f..a574aeaef30 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2017-10-27 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.
+
2017-10-27 Uros Bizjak <ubizjak@gmail.com>
PR target/82692
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-fma2.c b/gcc/testsuite/gcc.target/powerpc/float128-fma2.c
deleted file mode 100644
index e5f15aa2de9..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/float128-fma2.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
-/* { dg-require-effective-target powerpc_p9vector_ok } */
-/* { dg-options "-mpower9-vector -mno-float128-hardware -O2" } */
-
-__float128
-xfma (__float128 a, __float128 b, __float128 c)
-{
- return __builtin_fmaf128 (a, b, c); /* { dg-error "ISA 3.0 IEEE 128-bit" } */
-}
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-hw.c b/gcc/testsuite/gcc.target/powerpc/float128-hw.c
index 68e4c27aa58..929c6ddabe0 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-hw.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-hw.c
@@ -2,16 +2,58 @@
/* { dg-require-effective-target powerpc_p9vector_ok } */
/* { dg-options "-mpower9-vector -O2" } */
-__float128 f128_add (__float128 a, __float128 b) { return a+b; }
-__float128 f128_sub (__float128 a, __float128 b) { return a-b; }
-__float128 f128_mul (__float128 a, __float128 b) { return a*b; }
-__float128 f128_div (__float128 a, __float128 b) { return a/b; }
-__float128 f128_fma (__float128 a, __float128 b, __float128 c) { return (a*b)+c; }
-long f128_cmove (__float128 a, __float128 b, long c, long d) { return (a == b) ? c : d; }
+#ifndef TYPE
+#define TYPE _Float128
+#endif
+
+/* Test the code generation of the various _Float128 operations. */
+TYPE f128_add (TYPE a, TYPE b) { return a+b; }
+TYPE f128_sub (TYPE a, TYPE b) { return a-b; }
+TYPE f128_mul (TYPE a, TYPE b) { return a*b; }
+TYPE f128_div (TYPE a, TYPE b) { return a/b; }
+TYPE f128_fma (TYPE a, TYPE b, TYPE c) { return (a*b)+c; }
+TYPE f128_fms (TYPE a, TYPE b, TYPE c) { return (a*b)-c; }
+TYPE f128_nfma (TYPE a, TYPE b, TYPE c) { return -((a*b)+c); }
+TYPE f128_nfms (TYPE a, TYPE b, TYPE c) { return -((a*b)-c); }
+TYPE f128_neg (TYPE a) { return -a; }
+
+long f128_cmove (TYPE a, TYPE b, long c, long d) { return (a == b) ? c : d; }
+
+double f128_to_double (TYPE a) { return (double)a; }
+float f128_to_float (TYPE a) { return (float)a; }
+long f128_to_long (TYPE a) { return (long)a; }
+unsigned long f128_to_ulong (TYPE a) { return (unsigned long)a; }
+int f128_to_int (TYPE a) { return (int)a; }
+unsigned int f128_to_uint (TYPE a) { return (unsigned int)a; }
+
+TYPE double_to_f128 (double a) { return (TYPE)a; }
+TYPE float_to_f128 (float a) { return (TYPE)a; }
+TYPE long_to_f128 (long a) { return (TYPE)a; }
+TYPE ulong_to_f128 (unsigned long a) { return (TYPE)a; }
+TYPE int_to_f128 (int a) { return (TYPE)a; }
+TYPE uint_to_f128 (unsigned int a) { return (TYPE)a; }
+
+/* { dg-final { scan-assembler {\mmfvsrd\M} } } */
+/* { dg-final { scan-assembler {\mmfvsrwz\M} } } */
+/* { dg-final { scan-assembler {\mmtvsrd\M} } } */
+/* { dg-final { scan-assembler {\mmtvsrwa\M} } } */
+/* { dg-final { scan-assembler {\mxscmpuqp\M} } } */
+/* { dg-final { scan-assembler {\mxscvdpqp\M} } } */
+/* { dg-final { scan-assembler {\mxscvqpdp\M} } } */
+/* { dg-final { scan-assembler {\mxscvqpdpo\M} } } */
+/* { dg-final { scan-assembler {\mxscvqpsdz\M} } } */
+/* { dg-final { scan-assembler {\mxscvqpswz\M} } } */
+/* { dg-final { scan-assembler {\mxscvqpudz\M} } } */
+/* { dg-final { scan-assembler {\mxscvqpuwz\M} } } */
+/* { dg-final { scan-assembler {\mxscvsdqp\M} } } */
+/* { dg-final { scan-assembler {\mxscvudqp\M} } } */
+/* { dg-final { scan-assembler {\mxsdivqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmaddqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmsubqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmulqp\M} } } */
+/* { dg-final { scan-assembler {\mxsnegqp\M} } } */
+/* { dg-final { scan-assembler {\mxsnmaddqp\M} } } */
+/* { dg-final { scan-assembler {\mxsnmsubqp\M} } } */
+/* { dg-final { scan-assembler {\mxssubqp\M} } } */
+/* { dg-final { scan-assembler-not {\mbl\M} } } */
-/* { dg-final { scan-assembler "xsaddqp" } } */
-/* { dg-final { scan-assembler "xssubqp" } } */
-/* { dg-final { scan-assembler "xsmulqp" } } */
-/* { dg-final { scan-assembler "xsdivqp" } } */
-/* { dg-final { scan-assembler "xsmaddqp" } } */
-/* { dg-final { scan-assembler "xscmpuqp" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-hw2.c b/gcc/testsuite/gcc.target/powerpc/float128-hw2.c
new file mode 100644
index 00000000000..f144360da3c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-hw2.c
@@ -0,0 +1,60 @@
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
+/* { dg-require-effective-target powerpc_p9vector_ok } */
+/* { dg-options "-mpower9-vector -O2 -ffast-math -std=gnu11" } */
+
+/* Test to make sure the compiler handles the standard _Float128 functions that
+ have hardware support in ISA 3.0/power9. */
+
+#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
+
+#ifndef __FP_FAST_FMAF128
+#error "__FP_FAST_FMAF128 should be defined."
+#endif
+
+extern _Float128 copysignf128 (_Float128, _Float128);
+extern _Float128 sqrtf128 (_Float128);
+extern _Float128 fmaf128 (_Float128, _Float128, _Float128);
+
+_Float128
+do_copysign (_Float128 a, _Float128 b)
+{
+ return copysignf128 (a, b);
+}
+
+_Float128
+do_sqrt (_Float128 a)
+{
+ return sqrtf128 (a);
+}
+
+_Float128
+do_fma (_Float128 a, _Float128 b, _Float128 c)
+{
+ return fmaf128 (a, b, c);
+}
+
+_Float128
+do_fms (_Float128 a, _Float128 b, _Float128 c)
+{
+ return fmaf128 (a, b, -c);
+}
+
+_Float128
+do_nfma (_Float128 a, _Float128 b, _Float128 c)
+{
+ return -fmaf128 (a, b, c);
+}
+
+_Float128
+do_nfms (_Float128 a, _Float128 b, _Float128 c)
+{
+ return -fmaf128 (a, b, -c);
+}
+
+/* { dg-final { scan-assembler {\mxscpsgnqp\M} } } */
+/* { dg-final { scan-assembler {\mxssqrtqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmaddqp\M} } } */
+/* { dg-final { scan-assembler {\mxsmsubqp\M} } } */
+/* { dg-final { scan-assembler {\mxsnmaddqp\M} } } */
+/* { dg-final { scan-assembler {\mxsnmsubqp\M} } } */
+/* { dg-final { scan-assembler-not {\mbl\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-hw3.c b/gcc/testsuite/gcc.target/powerpc/float128-hw3.c
new file mode 100644
index 00000000000..e63099dde08
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/float128-hw3.c
@@ -0,0 +1,56 @@
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
+/* { dg-require-effective-target powerpc_p9vector_ok } */
+/* { dg-options "-mpower9-vector -O2 -ffast-math -std=c11" } */
+
+/* Test to make sure the compiler calls the external function instead of doing
+ the built-in processing for _Float128 functions that have hardware support
+ in ISA 3.0/power9 if are in strict standards mode, where the <func>f128 name
+ is not a synonym for __builtin_<func>f128. */
+
+extern _Float128 copysignf128 (_Float128, _Float128);
+extern _Float128 sqrtf128 (_Float128);
+extern _Float128 fmaf128 (_Float128, _Float128, _Float128);
+
+_Float128
+do_copysign (_Float128 a, _Float128 b)
+{
+ return copysignf128 (a, b);
+}
+
+_Float128
+do_sqrt (_Float128 a)
+{
+ return sqrtf128 (a);
+}
+
+_Float128
+do_fma (_Float128 a, _Float128 b, _Float128 c)
+{
+ return fmaf128 (a, b, c);
+}
+
+_Float128
+do_fms (_Float128 a, _Float128 b, _Float128 c)
+{
+ return fmaf128 (a, b, -c);
+}
+
+_Float128
+do_nfma (_Float128 a, _Float128 b, _Float128 c)
+{
+ return -fmaf128 (a, b, c);
+}
+
+_Float128
+do_nfms (_Float128 a, _Float128 b, _Float128 c)
+{
+ return -fmaf128 (a, b, -c);
+}
+
+/* { dg-final { scan-assembler-not {\mxscpsgnqp\M} } } */
+/* { dg-final { scan-assembler-not {\mxssqrtqp\M} } } */
+/* { dg-final { scan-assembler-not {\mxsmaddqp\M} } } */
+/* { dg-final { scan-assembler-not {\mxsmsubqp\M} } } */
+/* { dg-final { scan-assembler-not {\mxsnmaddqp\M} } } */
+/* { dg-final { scan-assembler-not {\mxsnmsubqp\M} } } */
+/* { dg-final { scan-assembler-times {\mbl\M} 6 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-sqrt2.c b/gcc/testsuite/gcc.target/powerpc/float128-sqrt2.c
deleted file mode 100644
index 94527ebbd98..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/float128-sqrt2.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
-/* { dg-require-effective-target powerpc_p9vector_ok } */
-/* { dg-options "-mpower9-vector -mno-float128-hardware -O2" } */
-
-__float128
-xsqrt (__float128 a)
-{
- return __builtin_sqrtf128 (a); /* { dg-error "ISA 3.0 IEEE 128-bit" } */
-}
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index 43987721b25..0c8fcf010b0 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -314,6 +314,7 @@ can_test_argument_range (gcall *call)
CASE_FLT_FN (BUILT_IN_POW10):
/* Sqrt. */
CASE_FLT_FN (BUILT_IN_SQRT):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
return check_builtin_call (call);
/* Special one: two argument pow. */
case BUILT_IN_POW:
@@ -342,6 +343,7 @@ edom_only_function (gcall *call)
CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
CASE_FLT_FN (BUILT_IN_SIN):
CASE_FLT_FN (BUILT_IN_SQRT):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
CASE_FLT_FN (BUILT_IN_FMOD):
CASE_FLT_FN (BUILT_IN_REMAINDER):
return true;
@@ -703,6 +705,7 @@ get_no_error_domain (enum built_in_function fnc)
308, true, false);
/* sqrt: [0, +inf) */
CASE_FLT_FN (BUILT_IN_SQRT):
+ CASE_FLT_FN_FLOATN_NX (BUILT_IN_SQRT):
return get_domain (0, true, true,
0, false, false);
default:
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 17d62a82e8b..a87040a91e1 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -515,6 +515,7 @@ internal_fn_reciprocal (gcall *call)
switch (gimple_call_combined_fn (call))
{
CASE_CFN_SQRT:
+ CASE_CFN_SQRT_FN:
ifn = IFN_RSQRT;
break;
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index cb438c744b7..5e8cac69d5d 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -5625,6 +5625,7 @@ attempt_builtin_copysign (vec<operand_entry *> *ops)
switch (gimple_call_combined_fn (old_call))
{
CASE_CFN_COPYSIGN:
+ CASE_CFN_COPYSIGN_FN:
arg0 = gimple_call_arg (old_call, 0);
arg1 = gimple_call_arg (old_call, 1);
/* The first argument of copysign must be a constant,