https://gcc.gnu.org/g:32b54d5e5ea99e81641d06e031acf3d823d366cf

commit 32b54d5e5ea99e81641d06e031acf3d823d366cf
Author: Michael Meissner <[email protected]>
Date:   Thu Oct 23 19:16:21 2025 -0400

    Fix thinko in V8BFmode and V8HFmode constants.
    
    2025-10-23  Michael Meissner  <[email protected]>
    
    gcc/
    
            * config/rs6000/rs6000.cc (constant_fp_to_128bit_vector): Get the 
right
            encoding for V8BFmode and V8HFmode constants.

Diff:
---
 gcc/config/rs6000/rs6000.cc | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index b83b9e4f6040..809a27b16c0f 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -29122,19 +29122,13 @@ constant_fp_to_128bit_vector (rtx op,
   const REAL_VALUE_TYPE *rtype = CONST_DOUBLE_REAL_VALUE (op);
   long real_words[VECTOR_128BIT_WORDS];
 
-  /* For IEEE 16-bit, the constant doesn't fill the whole 32-bit word, so
-     deal with it here.  */
+  /* For 16-bit floating point, the constant doesn't fill the whole 32-bit
+     word.  Deal with it here, storing the bytes in big endian fashion.  */
   if (FP16_SCALAR_MODE_P (mode))
     {
       real_to_target (real_words, rtype, mode);
-      unsigned char hi = (unsigned char) (real_words[0] >> 8);
-      unsigned char lo = (unsigned char) real_words[0];
-
-      if (!BYTES_BIG_ENDIAN)
-       std::swap (hi, lo);
-
-      info->bytes[0] = hi;
-      info->bytes[1] = lo;
+      info->bytes[byte_num] = (unsigned char) (real_words[0] >> 8);
+      info->bytes[byte_num+1] = (unsigned char) (real_words[0]);
     }
 
   else

Reply via email to