public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] builtins: Add __builtin_nextafterf16b builtin
@ 2022-10-21  7:23 Jakub Jelinek
  2022-10-21 15:42 ` [PATCH] builtins: Add various complex builtins for _Float{16,32,64,128,32x,64x,128x} Jakub Jelinek
  2022-10-24 15:24 ` [PATCH] builtins: Add __builtin_nextafterf16b builtin Jeff Law
  0 siblings, 2 replies; 5+ messages in thread
From: Jakub Jelinek @ 2022-10-21  7:23 UTC (permalink / raw)
  To: Joseph S. Myers, Richard Biener, Jeff Law; +Cc: gcc-patches, Jonathan Wakely

Hi!

On top of the pending
https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603665.html
patch, the following patch adds another needed builtin.
The above patch adds among other things __builtin_nextafterf16
builtin which we need in order to constexpr evaluate
std::nextafter(_Float16) overload (patch for that to be posted momentarily).
While there is inline implementation of the overload, it isn't constant
evaluation friendly, and the builtin doesn't need libm implementation
because it will be used only during constant expression evaluation.
We need the same thing also for std::nextafter(__gnu_cxx::__bfloat16_t)
though and this patch does that.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2022-10-21  Jakub Jelinek  <jakub@redhat.com>

	* builtin-types.def (BT_FN_BFLOAT16_BFLOAT16_BFLOAT16): New.
	* builtins.def (BUILT_IN_NEXTAFTERF16B): New builtin.
	* fold-const-call.cc (fold_const_call_sss): Handle
	CFN_BUILT_IN_NEXTAFTERF16B.

--- gcc/builtin-types.def.jj	2022-10-20 16:43:03.031928876 +0200
+++ gcc/builtin-types.def	2022-10-20 16:44:15.768934809 +0200
@@ -461,6 +461,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT64X_FLOA
 		     BT_FLOAT64X, BT_FLOAT64X, BT_FLOAT64X)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT128X_FLOAT128X_FLOAT128X,
 		     BT_FLOAT128X, BT_FLOAT128X, BT_FLOAT128X)
+DEF_FUNCTION_TYPE_2 (BT_FN_BFLOAT16_BFLOAT16_BFLOAT16,
+		     BT_BFLOAT16, BT_BFLOAT16, BT_BFLOAT16)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT_FLOAT_FLOATPTR,
 		     BT_FLOAT, BT_FLOAT, BT_FLOAT_PTR)
 DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_DOUBLEPTR,
--- gcc/builtins.def.jj	2022-10-20 16:43:03.033928849 +0200
+++ gcc/builtins.def	2022-10-20 16:46:27.467135944 +0200
@@ -591,6 +591,7 @@ DEF_C99_BUILTIN        (BUILT_IN_NEXTAFT
 DEF_C99_BUILTIN        (BUILT_IN_NEXTAFTERL, "nextafterl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_ERRNO)
 #define NEXTAFTER_TYPE(F) BT_FN_##F##_##F##_##F
 DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_NEXTAFTER, "nextafter", NEXTAFTER_TYPE, ATTR_MATHFN_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_NEXTAFTERF16B, "nextafterf16b", BT_FN_BFLOAT16_BFLOAT16_BFLOAT16, ATTR_MATHFN_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_NEXTTOWARD, "nexttoward", BT_FN_DOUBLE_DOUBLE_LONGDOUBLE, ATTR_MATHFN_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_NEXTTOWARDF, "nexttowardf", BT_FN_FLOAT_FLOAT_LONGDOUBLE, ATTR_MATHFN_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_NEXTTOWARDL, "nexttowardl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_ERRNO)
--- gcc/fold-const-call.cc.jj	2022-10-20 16:43:03.033928849 +0200
+++ gcc/fold-const-call.cc	2022-10-20 16:50:14.300038009 +0200
@@ -1438,6 +1438,7 @@ fold_const_call_sss (real_value *result,
 
     CASE_CFN_NEXTAFTER:
     CASE_CFN_NEXTAFTER_FN:
+    case CFN_BUILT_IN_NEXTAFTERF16B:
     CASE_CFN_NEXTTOWARD:
       return fold_const_nextafter (result, arg0, arg1, format);
 


	Jakub


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-25  9:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21  7:23 [PATCH] builtins: Add __builtin_nextafterf16b builtin Jakub Jelinek
2022-10-21 15:42 ` [PATCH] builtins: Add various complex builtins for _Float{16,32,64,128,32x,64x,128x} Jakub Jelinek
2022-10-24 16:28   ` Jeff Law
2022-10-25  9:03     ` Patch ping Jakub Jelinek
2022-10-24 15:24 ` [PATCH] builtins: Add __builtin_nextafterf16b builtin Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).