diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def
index c97d6bad1de..6980873f2f1 100644
--- a/gcc/builtin-types.def
+++ b/gcc/builtin-types.def
@@ -109,6 +109,10 @@ DEF_PRIMITIVE_TYPE (BT_FLOAT128X, (float128x_type_node
 DEF_PRIMITIVE_TYPE (BT_COMPLEX_FLOAT, complex_float_type_node)
 DEF_PRIMITIVE_TYPE (BT_COMPLEX_DOUBLE, complex_double_type_node)
 DEF_PRIMITIVE_TYPE (BT_COMPLEX_LONGDOUBLE, complex_long_double_type_node)
+DEF_PRIMITIVE_TYPE (BT_COMPLEX_BFLOAT16, (bfloat16_type_node
+					 ? build_complex_type
+						(bfloat16_type_node)
+					 : error_mark_node))
 DEF_PRIMITIVE_TYPE (BT_COMPLEX_FLOAT16, (float16_type_node
 					 ? build_complex_type
 						(float16_type_node)
@@ -163,6 +167,9 @@ DEF_PRIMITIVE_TYPE (BT_CONST_DOUBLE_PTR,
 		     (build_qualified_type (double_type_node,
 		     			    TYPE_QUAL_CONST)))
 DEF_PRIMITIVE_TYPE (BT_LONGDOUBLE_PTR, long_double_ptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_BFLOAT16_PTR, (bfloat16_type_node
+				      ? build_pointer_type (bfloat16_type_node)
+				      : error_mark_node))
 DEF_PRIMITIVE_TYPE (BT_FLOAT16_PTR, (float16_type_node
 				      ? build_pointer_type (float16_type_node)
 				      : error_mark_node))
@@ -239,6 +246,7 @@ DEF_FUNCTION_TYPE_0 (BT_FN_DOUBLE, BT_DOUBLE)
    distinguish it from two types in sequence, "long" followed by
    "double".  */
 DEF_FUNCTION_TYPE_0 (BT_FN_LONGDOUBLE, BT_LONGDOUBLE)
+DEF_FUNCTION_TYPE_0 (BT_FN_BFLOAT16, BT_BFLOAT16)
 DEF_FUNCTION_TYPE_0 (BT_FN_FLOAT16, BT_FLOAT16)
 DEF_FUNCTION_TYPE_0 (BT_FN_FLOAT32, BT_FLOAT32)
 DEF_FUNCTION_TYPE_0 (BT_FN_FLOAT64, BT_FLOAT64)
@@ -257,6 +265,7 @@ DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT_FLOAT, BT_FLOAT, BT_FLOAT)
 DEF_FUNCTION_TYPE_1 (BT_FN_DOUBLE_DOUBLE, BT_DOUBLE, BT_DOUBLE)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGDOUBLE_LONGDOUBLE,
 		     BT_LONGDOUBLE, BT_LONGDOUBLE)
+DEF_FUNCTION_TYPE_1 (BT_FN_BFLOAT16_BFLOAT16, BT_BFLOAT16, BT_BFLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT16_FLOAT16, BT_FLOAT16, BT_FLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT32_FLOAT32, BT_FLOAT32, BT_FLOAT32)
 DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT64_FLOAT64, BT_FLOAT64, BT_FLOAT64)
@@ -270,6 +279,8 @@ DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE,
 		     BT_COMPLEX_DOUBLE, BT_COMPLEX_DOUBLE)
 DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE,
 		     BT_COMPLEX_LONGDOUBLE, BT_COMPLEX_LONGDOUBLE)
+DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_BFLOAT16_COMPLEX_BFLOAT16,
+		     BT_COMPLEX_BFLOAT16, BT_COMPLEX_BFLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_FLOAT16_COMPLEX_FLOAT16,
 		     BT_COMPLEX_FLOAT16, BT_COMPLEX_FLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_FLOAT32_COMPLEX_FLOAT32,
@@ -290,6 +301,8 @@ DEF_FUNCTION_TYPE_1 (BT_FN_DOUBLE_COMPLEX_DOUBLE,
 		     BT_DOUBLE, BT_COMPLEX_DOUBLE)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE,
 		     BT_LONGDOUBLE, BT_COMPLEX_LONGDOUBLE)
+DEF_FUNCTION_TYPE_1 (BT_FN_BFLOAT16_COMPLEX_BFLOAT16,
+		     BT_BFLOAT16, BT_COMPLEX_BFLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT16_COMPLEX_FLOAT16,
 		     BT_FLOAT16, BT_COMPLEX_FLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT32_COMPLEX_FLOAT32,
@@ -324,6 +337,7 @@ DEF_FUNCTION_TYPE_1 (BT_FN_INT_PTR, BT_INT, BT_PTR)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_FLOAT, BT_INT, BT_FLOAT)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_DOUBLE, BT_INT, BT_DOUBLE)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_LONGDOUBLE, BT_INT, BT_LONGDOUBLE)
+DEF_FUNCTION_TYPE_1 (BT_FN_INT_BFLOAT16, BT_INT, BT_BFLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_FLOAT16, BT_INT, BT_FLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_FLOAT32, BT_INT, BT_FLOAT32)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_FLOAT64, BT_INT, BT_FLOAT64)
@@ -337,6 +351,7 @@ DEF_FUNCTION_TYPE_1 (BT_FN_INT_DFLOAT128, BT_INT, BT_DFLOAT128)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_FLOAT, BT_LONG, BT_FLOAT)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_DOUBLE, BT_LONG, BT_DOUBLE)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_LONGDOUBLE, BT_LONG, BT_LONGDOUBLE)
+DEF_FUNCTION_TYPE_1 (BT_FN_LONG_BFLOAT16, BT_LONG, BT_BFLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_FLOAT16, BT_LONG, BT_FLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_FLOAT32, BT_LONG, BT_FLOAT32)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONG_FLOAT64, BT_LONG, BT_FLOAT64)
@@ -347,6 +362,7 @@ DEF_FUNCTION_TYPE_1 (BT_FN_LONG_FLOAT128X, BT_LONG, BT_FLOAT128X)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_FLOAT, BT_LONGLONG, BT_FLOAT)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_DOUBLE, BT_LONGLONG, BT_DOUBLE)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_LONGDOUBLE, BT_LONGLONG, BT_LONGDOUBLE)
+DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_BFLOAT16, BT_LONGLONG, BT_BFLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_FLOAT16, BT_LONGLONG, BT_FLOAT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_FLOAT32, BT_LONGLONG, BT_FLOAT32)
 DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_FLOAT64, BT_LONGLONG, BT_FLOAT64)
@@ -525,6 +541,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_DOUBLEPTR,
 		     BT_DOUBLE, BT_DOUBLE, BT_DOUBLE_PTR)
 DEF_FUNCTION_TYPE_2 (BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLEPTR,
 		     BT_LONGDOUBLE, BT_LONGDOUBLE, BT_LONGDOUBLE_PTR)
+DEF_FUNCTION_TYPE_2 (BT_FN_BFLOAT16_BFLOAT16_BFLOAT16PTR,
+		     BT_BFLOAT16, BT_BFLOAT16, BT_BFLOAT16_PTR)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT16_FLOAT16_FLOAT16PTR,
 		     BT_FLOAT16, BT_FLOAT16, BT_FLOAT16_PTR)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT32_FLOAT32_FLOAT32PTR,
@@ -549,6 +567,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_INT,
 		     BT_DOUBLE, BT_DOUBLE, BT_INT)
 DEF_FUNCTION_TYPE_2 (BT_FN_LONGDOUBLE_LONGDOUBLE_INT,
 		     BT_LONGDOUBLE, BT_LONGDOUBLE, BT_INT)
+DEF_FUNCTION_TYPE_2 (BT_FN_BFLOAT16_BFLOAT16_INT,
+		     BT_BFLOAT16, BT_BFLOAT16, BT_INT)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT16_FLOAT16_INT,
 		     BT_FLOAT16, BT_FLOAT16, BT_INT)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT32_FLOAT32_INT,
@@ -569,6 +589,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_INTPTR,
 		     BT_DOUBLE, BT_DOUBLE, BT_INT_PTR)
 DEF_FUNCTION_TYPE_2 (BT_FN_LONGDOUBLE_LONGDOUBLE_INTPTR,
 		     BT_LONGDOUBLE, BT_LONGDOUBLE, BT_INT_PTR)
+DEF_FUNCTION_TYPE_2 (BT_FN_BFLOAT16_BFLOAT16_INTPTR,
+		     BT_BFLOAT16, BT_BFLOAT16, BT_INT_PTR)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT16_FLOAT16_INTPTR,
 		     BT_FLOAT16, BT_FLOAT16, BT_INT_PTR)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT32_FLOAT32_INTPTR,
@@ -595,6 +617,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_LONG,
 		     BT_DOUBLE, BT_DOUBLE, BT_LONG)
 DEF_FUNCTION_TYPE_2 (BT_FN_LONGDOUBLE_LONGDOUBLE_LONG,
 		     BT_LONGDOUBLE, BT_LONGDOUBLE, BT_LONG)
+DEF_FUNCTION_TYPE_2 (BT_FN_BFLOAT16_BFLOAT16_LONG,
+		     BT_BFLOAT16, BT_BFLOAT16, BT_LONG)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT16_FLOAT16_LONG,
 		     BT_FLOAT16, BT_FLOAT16, BT_LONG)
 DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT32_FLOAT32_LONG,
@@ -621,6 +645,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE_COMPLEX_DOUBLE,
 		     BT_COMPLEX_DOUBLE, BT_COMPLEX_DOUBLE, BT_COMPLEX_DOUBLE)
 DEF_FUNCTION_TYPE_2 (BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE,
 		     BT_COMPLEX_LONGDOUBLE, BT_COMPLEX_LONGDOUBLE, BT_COMPLEX_LONGDOUBLE)
+DEF_FUNCTION_TYPE_2 (BT_FN_COMPLEX_BFLOAT16_COMPLEX_BFLOAT16_COMPLEX_BFLOAT16,
+		     BT_COMPLEX_BFLOAT16, BT_COMPLEX_BFLOAT16, BT_COMPLEX_BFLOAT16)
 DEF_FUNCTION_TYPE_2 (BT_FN_COMPLEX_FLOAT16_COMPLEX_FLOAT16_COMPLEX_FLOAT16,
 		     BT_COMPLEX_FLOAT16, BT_COMPLEX_FLOAT16, BT_COMPLEX_FLOAT16)
 DEF_FUNCTION_TYPE_2 (BT_FN_COMPLEX_FLOAT32_COMPLEX_FLOAT32_COMPLEX_FLOAT32,
@@ -728,6 +754,8 @@ 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_BFLOAT16_BFLOAT16_BFLOAT16_BFLOAT16,
+		     BT_BFLOAT16, BT_BFLOAT16, BT_BFLOAT16, BT_BFLOAT16)
 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,
@@ -748,6 +776,8 @@ DEF_FUNCTION_TYPE_3 (BT_FN_DOUBLE_DOUBLE_DOUBLE_INTPTR,
 		     BT_DOUBLE, BT_DOUBLE, BT_DOUBLE, BT_INT_PTR)
 DEF_FUNCTION_TYPE_3 (BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE_INTPTR,
 		     BT_LONGDOUBLE, BT_LONGDOUBLE, BT_LONGDOUBLE, BT_INT_PTR)
+DEF_FUNCTION_TYPE_3 (BT_FN_BFLOAT16_BFLOAT16_BFLOAT16_INTPTR,
+		     BT_BFLOAT16, BT_BFLOAT16, BT_BFLOAT16, BT_INT_PTR)
 DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT16_FLOAT16_FLOAT16_INTPTR,
 		     BT_FLOAT16, BT_FLOAT16, BT_FLOAT16, BT_INT_PTR)
 DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT32_FLOAT32_FLOAT32_INTPTR,
diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 0b902896ddd..d0fc8e755e8 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -1918,6 +1918,7 @@ expand_builtin_classify_type (tree exp)
   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 ;\
+  fcodef16b = BUILT_IN_##MATHFN##F16B ; \
   break;
 /* Similar to above, but appends _R after any F/L suffix.  */
 #define CASE_MATHFN_REENT(MATHFN) \
@@ -1937,6 +1938,7 @@ mathfn_built_in_2 (tree type, combined_fn fn)
 {
   tree mtype;
   built_in_function fcode, fcodef, fcodel;
+  built_in_function fcodef16b = END_BUILTINS;
   built_in_function fcodef16 = END_BUILTINS;
   built_in_function fcodef32 = END_BUILTINS;
   built_in_function fcodef64 = END_BUILTINS;
@@ -2055,6 +2057,8 @@ mathfn_built_in_2 (tree type, combined_fn fn)
     return fcodef;
   else if (mtype == long_double_type_node)
     return fcodel;
+  else if (mtype == bfloat16_type_node)
+    return fcodef16b;
   else if (mtype == float16_type_node)
     return fcodef16;
   else if (mtype == float32_type_node)
@@ -2137,6 +2141,8 @@ mathfn_built_in_type (combined_fn fn)
 
 #define CASE_MATHFN_FLOATN(MATHFN)		\
   CASE_MATHFN(MATHFN)				\
+  case CFN_BUILT_IN_##MATHFN##F16B:		\
+    return bfloat16_type_node;			\
   case CFN_BUILT_IN_##MATHFN##F16:		\
     return float16_type_node;			\
   case CFN_BUILT_IN_##MATHFN##F32:		\
diff --git a/gcc/builtins.def b/gcc/builtins.def
index f6f3e104f6a..ffd427d7d93 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -77,11 +77,12 @@ along with GCC; see the file COPYING3.  If not see
   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, BT_LAST,	\
 	       false, false, false, ATTRS, true, 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.  */
+/* A set of GCC builtins for __bf16, _FloatN and _FloatNx types.
+   TYPE_MACRO is called with an argument such as FLOAT32 to produce
+   the enum value for the type.  */
 #undef DEF_GCC_FLOATN_NX_BUILTINS
 #define DEF_GCC_FLOATN_NX_BUILTINS(ENUM, NAME, TYPE_MACRO, ATTRS)	\
+  DEF_GCC_BUILTIN (ENUM ## F16B, NAME "f16b", TYPE_MACRO (BFLOAT16), ATTRS) \
   DEF_GCC_BUILTIN (ENUM ## F16, NAME "f16", TYPE_MACRO (FLOAT16), ATTRS) \
   DEF_GCC_BUILTIN (ENUM ## F32, NAME "f32", TYPE_MACRO (FLOAT32), ATTRS) \
   DEF_GCC_BUILTIN (ENUM ## F64, NAME "f64", TYPE_MACRO (FLOAT64), ATTRS) \
@@ -110,12 +111,12 @@ along with GCC; see the file COPYING3.  If not see
   DEF_BUILTIN (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 compiling for the C language with GNU extensions, we enable the name
-   without the __builtin_ prefix as well as the name with the __builtin_
-   prefix.  C++ does not enable these names by default because a class based
-   library should use the __builtin_ names.  */
+/* A set of GCC builtins for __bf16, _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 compiling for the C language with GNU
+   extensions, we enable the name without the __builtin_ prefix as well as the
+   name with the __builtin_ prefix.  C++ does not enable these names by default
+   because a class based library should use the __builtin_ names.  */
 #undef DEF_FLOATN_BUILTIN
 #define DEF_FLOATN_BUILTIN(ENUM, NAME, TYPE, ATTRS)	\
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,	\
@@ -123,6 +124,7 @@ along with GCC; see the file COPYING3.  If not see
 	       false, true)
 #undef DEF_EXT_LIB_FLOATN_NX_BUILTINS
 #define DEF_EXT_LIB_FLOATN_NX_BUILTINS(ENUM, NAME, TYPE_MACRO, ATTRS)	\
+  DEF_FLOATN_BUILTIN (ENUM ## F16B, NAME "f16b", TYPE_MACRO (BFLOAT16), ATTRS) \
   DEF_FLOATN_BUILTIN (ENUM ## F16, NAME "f16", TYPE_MACRO (FLOAT16), ATTRS) \
   DEF_FLOATN_BUILTIN (ENUM ## F32, NAME "f32", TYPE_MACRO (FLOAT32), ATTRS) \
   DEF_FLOATN_BUILTIN (ENUM ## F64, NAME "f64", TYPE_MACRO (FLOAT64), ATTRS) \
@@ -576,7 +578,6 @@ DEF_GCC_BUILTIN        (BUILT_IN_NANSF, "nansf", BT_FN_FLOAT_CONST_STRING, ATTR_
 DEF_GCC_BUILTIN        (BUILT_IN_NANSL, "nansl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
 DEF_GCC_FLOATN_NX_BUILTINS (BUILT_IN_NANS, "nans", NAN_TYPE, ATTR_CONST_NOTHROW_NONNULL)
 #undef NAN_TYPE
-DEF_GCC_BUILTIN        (BUILT_IN_NANSF16B, "nansf16b", BT_FN_BFLOAT16_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
 DEF_GCC_BUILTIN        (BUILT_IN_NANSD32, "nansd32", BT_FN_DFLOAT32_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
 DEF_GCC_BUILTIN        (BUILT_IN_NANSD64, "nansd64", BT_FN_DFLOAT64_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
 DEF_GCC_BUILTIN        (BUILT_IN_NANSD128, "nansd128", BT_FN_DFLOAT128_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
@@ -591,7 +592,6 @@ DEF_C99_BUILTIN        (BUILT_IN_NEXTAFTERF, "nextafterf", BT_FN_FLOAT_FLOAT_FLO
 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)
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index a80372c8991..273bb9cf028 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1422,7 +1422,7 @@ c_cpp_builtins (cpp_reader *pfile)
 	  else if (bfloat16_type_node
 		   && mode == TYPE_MODE (bfloat16_type_node))
 	    {
-	      memcpy (suffix, "bf16", 5);
+	      memcpy (suffix, "f16b", 5);
 	      memcpy (float_h_prefix, "BFLT16", 7);
 	    }
 	  else
diff --git a/gcc/fold-const-call.cc b/gcc/fold-const-call.cc
index 47bf8d64391..ed1ec0ab3ee 100644
--- a/gcc/fold-const-call.cc
+++ b/gcc/fold-const-call.cc
@@ -1354,7 +1354,6 @@ fold_const_call (combined_fn fn, tree type, tree arg)
 
     CASE_CFN_NANS:
     CASE_FLT_FN_FLOATN_NX (CFN_BUILT_IN_NANS):
-    case CFN_BUILT_IN_NANSF16B:
     case CFN_BUILT_IN_NANSD32:
     case CFN_BUILT_IN_NANSD64:
     case CFN_BUILT_IN_NANSD128:
@@ -1462,7 +1461,6 @@ fold_const_call_sss (real_value *result, combined_fn fn,
 
     CASE_CFN_NEXTAFTER:
     CASE_CFN_NEXTAFTER_FN:
-    case CFN_BUILT_IN_NEXTAFTERF16B:
     CASE_CFN_NEXTTOWARD:
       return fold_const_nextafter (result, arg0, arg1, format);
 
diff --git a/gcc/gencfn-macros.cc b/gcc/gencfn-macros.cc
index 2581e758fe6..8c78ef084fe 100644
--- a/gcc/gencfn-macros.cc
+++ b/gcc/gencfn-macros.cc
@@ -156,10 +156,11 @@ 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 };
+					      "F32X", "F64X", "F128X","F16B",
+					      NULL };
 static const char *const fltall_suffixes[] = { "F", "", "L", "F16", "F32",
 					       "F64", "F128", "F32X", "F64X",
-					       "F128X", NULL };
+					       "F128X", "F16B", NULL };
 static const char *const int_suffixes[] = { "", "L", "LL", "IMAX", NULL };
 
 static const char *const *const suffix_lists[] = {
diff --git a/gcc/match.pd b/gcc/match.pd
index c9c8478d286..ca01c6714d8 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -8386,7 +8386,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 #if GIMPLE
 (match float16_value_p
  @0
- (if (TYPE_MAIN_VARIANT (TREE_TYPE (@0)) == float16_type_node)))
+ (if ((TYPE_MAIN_VARIANT (TREE_TYPE (@0)) == float16_type_node) ||
+      (TYPE_MAIN_VARIANT (TREE_TYPE (@0)) == bfloat16_type_node))))
 (for froms (BUILT_IN_TRUNCL BUILT_IN_TRUNC BUILT_IN_TRUNCF
 	    BUILT_IN_FLOORL BUILT_IN_FLOOR BUILT_IN_FLOORF
 	    BUILT_IN_CEILL BUILT_IN_CEIL BUILT_IN_CEILF
@@ -8403,8 +8404,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 	  IFN_NEARBYINT IFN_NEARBYINT IFN_NEARBYINT
 	  IFN_RINT IFN_RINT IFN_RINT
 	  IFN_SQRT IFN_SQRT IFN_SQRT)
- /* (_Float16) round ((doube) x) -> __built_in_roundf16 (x), etc.,
-    if x is a _Float16.  */
+ /* 1 (_Float16) round ((doube) x) -> __built_in_roundf16 (x), etc.,
+    if x is a _Float16.
+    2 (__bf16) round ((doube) x) -> __built_in_roundf16b (x), etc.,
+    if x is a __bf16.  */
  (simplify
    (convert (froms (convert float16_value_p@0)))
      (if (optimize
diff --git a/gcc/tree.h b/gcc/tree.h
index 5dcbb2fb5dd..67fc2a2e614 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -310,7 +310,7 @@ code_helper::is_builtin_fn () const
 #define CASE_FLT_FN(FN) case FN: case FN##F: case FN##L
 #define CASE_FLT_FN_FLOATN_NX(FN)			   \
   case FN##F16: case FN##F32: case FN##F64: case FN##F128: \
-  case FN##F32X: case FN##F64X: case FN##F128X
+  case FN##F32X: case FN##F64X: case FN##F128X: case FN##F16B
 #define CASE_FLT_FN_REENT(FN) case FN##_R: case FN##F_R: case FN##L_R
 #define CASE_INT_FN(FN) case FN: case FN##L: case FN##LL: case FN##IMAX
 
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 0e46e9ef768..b71fd5e2250 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -450,9 +450,9 @@ lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2	   \
 	    _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2  \
 	    _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2	   \
 	    _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2	   \
-	    _mulhc3 _mulsc3 _muldc3 _mulxc3 _multc3 _divhc3 _divsc3	   \
-	    _divdc3 _divxc3 _divtc3 _bswapsi2 _bswapdi2 _clrsbsi2	   \
-	    _clrsbdi2 _mulbitint3
+	    _mulhc3 _mulbc3 _mulsc3 _muldc3 _mulxc3 _multc3 _divhc3	   \
+	    _divbc3 _divsc3 _divdc3 _divxc3 _divtc3 _bswapsi2 _bswapdi2	   \
+	    _clrsbsi2 _clrsbdi2 _mulbitint3
 
 # The floating-point conversion routines that involve a single-word integer.
 # XX stands for the integer mode.
diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c
index 3fcb85c5b92..512ca92bfb9 100644
--- a/libgcc/libgcc2.c
+++ b/libgcc/libgcc2.c
@@ -2591,6 +2591,7 @@ NAME (TYPE x, int m)
 #endif
 
 #if((defined(L_mulhc3) || defined(L_divhc3)) && LIBGCC2_HAS_HF_MODE) \
+    || ((defined(L_mulbc3) || defined(L_divbc3)) && LIBGCC2_HAS_BF_MODE) \
     || ((defined(L_mulsc3) || defined(L_divsc3)) && LIBGCC2_HAS_SF_MODE) \
     || ((defined(L_muldc3) || defined(L_divdc3)) && LIBGCC2_HAS_DF_MODE) \
     || ((defined(L_mulxc3) || defined(L_divxc3)) && LIBGCC2_HAS_XF_MODE) \
@@ -2607,6 +2608,13 @@ NAME (TYPE x, int m)
 # define MODE	hc
 # define CEXT	__LIBGCC_HF_FUNC_EXT__
 # define NOTRUNC (!__LIBGCC_HF_EXCESS_PRECISION__)
+#elif defined(L_mulbc3) || defined(L_divbc3)
+# define MTYPE  BFtype
+# define CTYPE  BCtype
+# define AMTYPE SFtype
+# define MODE   bc
+# define CEXT   __LIBGCC_BF_FUNC_EXT__
+# define NOTRUNC (!__LIBGCC_BF_EXCESS_PRECISION__)
 #elif defined(L_mulsc3) || defined(L_divsc3)
 # define MTYPE	SFtype
 # define CTYPE	SCtype
@@ -2690,8 +2698,8 @@ extern void *compile_type_assert[sizeof(INFINITY) == sizeof(MTYPE) ? 1 : -1];
 # define TRUNC(x)	__asm__ ("" : "=m"(x) : "m"(x))
 #endif
 
-#if defined(L_mulhc3) || defined(L_mulsc3) || defined(L_muldc3) \
-    || defined(L_mulxc3) || defined(L_multc3)
+#if defined(L_mulhc3) || defined(L_mulbc3) || defined(L_mulsc3) \
+    || defined(L_muldc3) || defined(L_mulxc3) || defined(L_multc3)
 
 CTYPE
 CONCAT3(__mul,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d)
@@ -2760,16 +2768,16 @@ CONCAT3(__mul,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d)
 }
 #endif /* complex multiply */
 
-#if defined(L_divhc3) || defined(L_divsc3) || defined(L_divdc3) \
-    || defined(L_divxc3) || defined(L_divtc3)
+#if defined(L_divhc3) || defined(L_divbc3) || defined(L_divsc3) \
+    || defined(L_divdc3) || defined(L_divxc3) || defined(L_divtc3)
 
 CTYPE
 CONCAT3(__div,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d)
 {
-#if defined(L_divhc3)						\
+#if (defined(L_divhc3) || defined(L_divbc3) )			\
   || (defined(L_divsc3) && defined(__LIBGCC_HAVE_HWDBL__) )
 
-  /* Half precision is handled with float precision.
+  /* _Float16 and __bf16 are handled with float precision.
      float is handled with double precision when double precision
      hardware is available.
      Due to the additional precision, the simple complex divide
diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h
index b358b3a2b50..ee99badde86 100644
--- a/libgcc/libgcc2.h
+++ b/libgcc/libgcc2.h
@@ -43,6 +43,12 @@ extern void __eprintf (const char *, const char *, unsigned int, const char *)
 #define LIBGCC2_HAS_HF_MODE 0
 #endif
 
+#ifdef __LIBGCC_HAS_BF_MODE__
+#define LIBGCC2_HAS_BF_MODE 1
+#else
+#define LIBGCC2_HAS_BF_MODE 0
+#endif
+
 #ifdef __LIBGCC_HAS_SF_MODE__
 #define LIBGCC2_HAS_SF_MODE 1
 #else
@@ -146,6 +152,10 @@ typedef unsigned int UTItype	__attribute__ ((mode (TI)));
 typedef		float HFtype	__attribute__ ((mode (HF)));
 typedef _Complex float HCtype	__attribute__ ((mode (HC)));
 #endif
+#if LIBGCC2_HAS_BF_MODE
+typedef		float BFtype	__attribute__ ((mode (BF)));
+typedef _Complex float BCtype	__attribute__ ((mode (BC)));
+#endif
 #if LIBGCC2_HAS_SF_MODE
 typedef 	float SFtype	__attribute__ ((mode (SF)));
 typedef _Complex float SCtype	__attribute__ ((mode (SC)));
@@ -465,6 +475,10 @@ extern SItype __negvsi2 (SItype);
 extern HCtype __divhc3 (HFtype, HFtype, HFtype, HFtype);
 extern HCtype __mulhc3 (HFtype, HFtype, HFtype, HFtype);
 #endif
+#if LIBGCC2_HAS_BF_MODE
+extern BCtype __divbc3 (BFtype, BFtype, BFtype, BFtype);
+extern BCtype __mulbc3 (BFtype, BFtype, BFtype, BFtype);
+#endif
 #if LIBGCC2_HAS_SF_MODE
 extern DWtype __fixsfdi (SFtype);
 extern SFtype __floatdisf (DWtype);
