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

commit d160ed945429104b8d5810f94ca73af10fdd3000
Author: Michael Meissner <[email protected]>
Date:   Mon Nov 10 13:29:05 2025 -0500

    Add conversions between _Float16 and float/double.
    
    This patch adds support to generate xscvhpdp and xscvdphp on Power9 systems 
and
    later, to convert between _Float16 and float scalar values.
    
    2025-11-10  Michael Meissner  <[email protected]>
    
    gcc/
    
            * config/rs6000/float16.md (FP16_HW): New mode iterator.
            (extendhf<mode>2): Add support converting between HFmode and
            SFmode/DFmoded if we are on power9 or later.
            (trunc<mode>hf2): Likewise.

Diff:
---
 gcc/config/rs6000/float16.md | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gcc/config/rs6000/float16.md b/gcc/config/rs6000/float16.md
index fec4bb87fd09..13f3b32e86c1 100644
--- a/gcc/config/rs6000/float16.md
+++ b/gcc/config/rs6000/float16.md
@@ -25,6 +25,10 @@
 (define_mode_iterator FP16 [(BF "TARGET_FLOAT16")
                            (HF "TARGET_FLOAT16")])
 
+;; 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 [(HF "TARGET_FLOAT16_HW")])
+
 ;; Mode attribute giving the vector mode for a 16-bit floating point
 ;; scalar in both upper and lower case.
 (define_mode_attr FP16_VECTOR8 [(BF "V8BF")
@@ -122,3 +126,21 @@
 }
   [(set_attr "type" "veclogical,vecperm")
    (set_attr "prefixed" "*,yes")])
+
+;; Convert IEEE 16-bit floating point to/from other floating point modes.
+
+(define_insn "extendhf<mode>2"
+  [(set (match_operand:SFDF 0 "vsx_register_operand" "=wa")
+       (float_extend:SFDF
+        (match_operand:HF 1 "vsx_register_operand" "wa")))]
+  "TARGET_FLOAT16_HW"
+  "xscvhpdp %x0,%x1"
+  [(set_attr "type" "fpsimple")])
+
+(define_insn "trunc<mode>hf2"
+  [(set (match_operand:HF 0 "vsx_register_operand" "=wa")
+       (float_truncate:HF
+        (match_operand:SFDF 1 "vsx_register_operand" "wa")))]
+  "TARGET_FLOAT16_HW"
+  "xscvdphp %x0,%x1"
+  [(set_attr "type" "fpsimple")])

Reply via email to