[PATCH] Support libcall __float{, un}sibf by SF when it is not supported for _bf16
Jin Ma
jinma@linux.alibaba.com
Wed Dec 20 11:17:48 GMT 2023
We don't have SI -> BF library functions, use SI -> SF -> BF
instead. Although this can also be implemented in a target
machine description, it is more appropriate to move
into target independent code.
gcc/ChangeLog:
* optabs.cc (expand_float): Split SI -> BF into SI -> SF -> BF.
---
gcc/optabs.cc | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/gcc/optabs.cc b/gcc/optabs.cc
index 6a34276c239..c58a0321bbd 100644
--- a/gcc/optabs.cc
+++ b/gcc/optabs.cc
@@ -5727,6 +5727,19 @@ expand_float (rtx to, rtx from, int unsignedp)
if (is_narrower_int_mode (GET_MODE (from), SImode))
from = convert_to_mode (SImode, from, unsignedp);
+#ifdef HAVE_SFmode
+ if (REAL_MODE_FORMAT (GET_MODE (to)) == &arm_bfloat_half_format
+ && REAL_MODE_FORMAT (SFmode) == &ieee_single_format
+ && GET_MODE (from) == SImode)
+ /* We don't have SI -> BF library functions, use SI -> SF -> BF
+ instead. */
+ {
+ target = gen_reg_rtx (SFmode);
+ expand_float (target, from, unsignedp);
+ goto done;
+ }
+#endif
+
libfunc = convert_optab_libfunc (tab, GET_MODE (to), GET_MODE (from));
gcc_assert (libfunc);
--
2.17.1
More information about the Gcc-patches
mailing list