https://gcc.gnu.org/g:ef8a43f0673d15da96290b1d2eb8af987b0c1ee1

commit ef8a43f0673d15da96290b1d2eb8af987b0c1ee1
Author: Michael Meissner <[email protected]>
Date:   Tue Sep 8 19:13:39 2026 -0400

    Add -mbfloat16-convert; Rename -mfloat16-convert to 
-mfloat16-function-convert.
    
    2026-09-08  Michael Meissner  <[email protected]>
    
    gcc/
    
            * config/rs6000/float16.md (FP16_HW): Add support for
            -mbfloat16-convert.
            ("extendbf<mode>2): Likewise.
            (extendbfsf2_sw): Likewise.
            (extendbfsf2_sw_mem): Likewise.
            (extendbfdf2_sw): Likewise.
            (trunc<mode>bf2): Likewise.
            (trunchfbf2): Likewise.
            (trunchfbf2_mem): Likewise.
            (extendbfhf2_mem): Likewise.
            * config/rs6000/rs6000-call.cc (rs6000_promote_function_mode): 
Rename
            -mfloat16-convert to -mfloat16-function-convert.
            (rs6000_promote_function_mode_convert): Likewise.
            * config/rs6000/rs6000.cc (rs6000_opt_vars): Add
            -mfloat16-function-convert and -mbfloat16-convert.
            * config/rs6000/rs6000.opt (-mfloat16-function-convert): Rename from
            -mfloat16-convert.
            (-mbfloat16-convert): New option.

Diff:
---
 gcc/config/rs6000/float16.md     | 24 +++++++++++++-----------
 gcc/config/rs6000/rs6000-call.cc |  5 +++--
 gcc/config/rs6000/rs6000.cc      |  6 ++++++
 gcc/config/rs6000/rs6000.opt     |  8 ++++++--
 4 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/gcc/config/rs6000/float16.md b/gcc/config/rs6000/float16.md
index 6683d97abb25..756106064e27 100644
--- a/gcc/config/rs6000/float16.md
+++ b/gcc/config/rs6000/float16.md
@@ -28,7 +28,7 @@
 
 ;; Mode iterator for 16-bit floating point modes on machines with
 ;; hardware support both as a scalar and as a vector.
-(define_mode_iterator FP16_HW [(BF "TARGET_BFLOAT16_HW")
+(define_mode_iterator FP16_HW [(BF "TARGET_BFLOAT16_HW && 
TARGET_BFLOAT16_CONVERT")
                               (HF "TARGET_FLOAT16_HW")])
 
 (define_mode_iterator VFP16_HW [(V8BF "TARGET_BFLOAT16_HW")
@@ -238,7 +238,7 @@
   [(set (match_operand:SFDF 0 "register_operand")
        (float_extend:SFDF
         (match_operand:BF 1 "register_operand")))]
-  "TARGET_FLOAT16 && TARGET_DIRECT_MOVE_64BIT"
+  "TARGET_FLOAT16 && TARGET_DIRECT_MOVE_64BIT && TARGET_BFLOAT16_CONVERT"
 {
   rtx op0 = operands[0];
   rtx op1 = operands[1];
@@ -265,7 +265,8 @@
         (match_operand:BF 1 "int_reg_operand" "r,r")))
    (match_scratch:DI 2 "=r,X")
 ]
-  "TARGET_FLOAT16 && !TARGET_BFLOAT16_HW && TARGET_DIRECT_MOVE_64BIT"
+  "TARGET_FLOAT16 && !TARGET_BFLOAT16_HW && TARGET_DIRECT_MOVE_64BIT
+   && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& reload_completed"
   [(pc)]
@@ -307,7 +308,7 @@
        (float_extend:SF
         (match_operand:BF 1 "int_reg_operand" "r")))
    (match_scratch:DI 2 "=r")]
-  "TARGET_FLOAT16 && !TARGET_BFLOAT16_HW"
+  "TARGET_FLOAT16 && !TARGET_BFLOAT16_HW && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& reload_completed"
   [(pc)]
@@ -335,7 +336,8 @@
        (float_extend:DF
         (match_operand:BF 1 "int_reg_operand" "r")))
    (match_scratch:DI 2 "=r")]
-  "TARGET_FLOAT16 && !TARGET_BFLOAT16_HW && TARGET_DIRECT_MOVE_64BIT"
+  "TARGET_FLOAT16 && !TARGET_BFLOAT16_HW && TARGET_DIRECT_MOVE_64BIT
+    && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& reload_completed"
   [(pc)]
@@ -367,7 +369,7 @@
        (float_extend:SFDF
         (match_operand:BF 1 "vsx_register_operand" "v")))
    (clobber (match_scratch:V4SF 2 "=wa"))]
-  "TARGET_BFLOAT16_HW"
+  "TARGET_BFLOAT16_HW && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& 1"
   [(pc)]
@@ -458,7 +460,7 @@
        (float_truncate:BF
         (match_operand:SFDF 1 "vsx_register_operand" "wa")))
    (clobber (match_scratch:V4SF 2 "=wa"))]
-  "TARGET_BFLOAT16_HW"
+  "TARGET_BFLOAT16_HW && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& 1"
   [(pc)]
@@ -610,7 +612,7 @@
        (float_truncate:BF
         (match_operand:HF 1 "vsx_register_operand" "wa")))
    (clobber (match_scratch:V4SF 2 "=wa"))]
-  "TARGET_BFLOAT16_HW"
+  "TARGET_BFLOAT16_HW && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& 1"
   [(pc)]
@@ -639,7 +641,7 @@
        (float_truncate:BF
         (match_operand:HF 1 "memory_operand" "Z")))
    (clobber (match_scratch:V4SF 2 "=wa"))]
-  "TARGET_BFLOAT16_HW"
+  "TARGET_BFLOAT16_HW && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& reload_completed"
   [(pc)]
@@ -668,7 +670,7 @@
        (float_extend:HF
         (match_operand:BF 1 "vsx_register_operand" "wa")))
    (clobber (match_scratch:V4SF 2 "=wa"))]
-  "TARGET_BFLOAT16_HW"
+  "TARGET_BFLOAT16_HW && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& 1"
   [(pc)]
@@ -697,7 +699,7 @@
        (float_extend:HF
         (match_operand:BF 1 "memory_operand" "Z")))
    (clobber (match_scratch:V4SF 2 "=wa"))]
-  "TARGET_BFLOAT16_HW"
+  "TARGET_BFLOAT16_HW && TARGET_BFLOAT16_CONVERT"
   "#"
   "&& reload_completed"
   [(pc)]
diff --git a/gcc/config/rs6000/rs6000-call.cc b/gcc/config/rs6000/rs6000-call.cc
index 4b6445cdef14..69212e1a69e5 100644
--- a/gcc/config/rs6000/rs6000-call.cc
+++ b/gcc/config/rs6000/rs6000-call.cc
@@ -723,7 +723,8 @@ rs6000_promote_function_mode (const_tree type 
ATTRIBUTE_UNUSED,
                              int *punsignedp ATTRIBUTE_UNUSED,
                              const_tree, int for_return)
 {
-  if (FP16_SCALAR_MODE_P (mode) && !for_return && TARGET_FLOAT16_CONVERT)
+  if (FP16_SCALAR_MODE_P (mode) && !for_return
+      && TARGET_FLOAT16_FUNCTION_CONVERT)
     return SFmode;
 
   if (GET_MODE_CLASS (mode) == MODE_INT
@@ -741,7 +742,7 @@ rs6000_promote_function_mode_convert (machine_mode new_mode,
                                      rtx decl_rtl,
                                      int unsignedp)
 {
-  if (TARGET_FLOAT16_CONVERT
+  if (TARGET_FLOAT16_FUNCTION_CONVERT
       && (FP16_SCALAR_MODE_P (new_mode) || FP16_SCALAR_MODE_P (old_mode)))
     return convert_to_mode (new_mode, decl_rtl, unsignedp);
 
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 7f2b8b71d159..18945b29c3ae 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -24995,6 +24995,12 @@ static struct rs6000_opt_var const rs6000_opt_vars[] =
   { "speculate-indirect-jumps",
     offsetof (struct gcc_options, x_rs6000_speculate_indirect_jumps),
     offsetof (struct cl_target_option, x_rs6000_speculate_indirect_jumps), },
+  { "float16-function-convert",
+    offsetof (struct gcc_options, x_TARGET_FLOAT16_FUNCTION_CONVERT),
+    offsetof (struct cl_target_option, x_TARGET_FLOAT16_FUNCTION_CONVERT), },
+  { "bfloat16-sw-convert",
+    offsetof (struct gcc_options, x_TARGET_BFLOAT16_CONVERT),
+    offsetof (struct cl_target_option, x_TARGET_BFLOAT16_CONVERT), },
 };
 
 /* Inner function to handle attribute((target("..."))) and #pragma GCC target
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index b25ef6db84b3..a35116c8f606 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -646,10 +646,14 @@ mfloat16
 Target Mask(FLOAT16) Var(rs6000_isa_flags)
 Enable or disable 16-bit floating point.
 
-mfloat16-convert
-Target Undocumented Var(TARGET_FLOAT16_CONVERT) Init(0) Save
+mfloat16-function-convert
+Target Undocumented Var(TARGET_FLOAT16_FUNCTION_CONVERT) Init(0) Save
 Pass and return 16-bit floating point as double.
 
+mbfloat16-convert
+Target Undocumented Var(TARGET_BFLOAT16_CONVERT) Init(1) Save
+Do __bf16 conversions with inline code.
+
 ; Documented parameters
 
 -param=rs6000-vect-unroll-limit=

Reply via email to