@@ -373,10 +373,17 @@ convert_mode_scalar (rtx to, rtx from, int unsignedp)
}
#ifdef HAVE_SFmode
- if (REAL_MODE_FORMAT (from_mode) == &arm_bfloat_half_format
+ /* Since BFmode isn't a subset nor superset of BFmode, implement
+ HFmode -> BFmode conversion by HFmode -> SFmode -> BFmode
+ conversions. */
+ if ((REAL_MODE_FORMAT (from_mode) == &arm_bfloat_half_format
+ || (REAL_MODE_FORMAT (from_mode) == &ieee_half_format
+ && REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format))
&& REAL_MODE_FORMAT (SFmode) == &ieee_single_format)
{
- if (GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (SFmode))
+ if ((REAL_MODE_FORMAT (from_mode) == &ieee_half_format
+ && REAL_MODE_FORMAT (to_mode) == &arm_bfloat_half_format)
+ || GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (SFmode))
{
/* To cut down on libgcc size, implement
BFmode -> {DF,XF,TF}mode conversions by
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do run } */
+/* { dg-options "-O0" } */
+/* { dg-add-options bfloat16 } */
+/* { dg-require-effective-target bfloat16_runtime } */
+
+__bf16 bf;
+_Float16 f16;
+
+int
+main (void)
+{
+ bf = f16;
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-options "-mavx512fp16 -O2 -save-temps" } */
+
+__bf16 bf;
+_Float16 f16;
+
+int
+main (void)
+{
+ if (!__builtin_cpu_supports ("avx512fp16"))
+ return 0;
+
+ bf = f16;
+ return 0;
+}
+
+/* { dg-final { scan-assembler-times "vcvtsh2ss\[ \\t\]" 1 } } */
+/* { dg-final { scan-assembler-not "__extendhfsf2\[ \\t\]" } } */