]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Fix PR122097 (2).
authorLulu Cheng <chenglulu@loongson.cn>
Mon, 3 Nov 2025 09:53:52 +0000 (17:53 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Sat, 8 Nov 2025 07:46:51 +0000 (15:46 +0800)
r16-4703 does not completely fix PR122097.  Floating-point vectors
were not processed in the function loongarch_const_vector_same_bytes_p.
This patch will completely resolve this issue.

PR target/122097

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_const_vector_same_bytes_p): Add processing for
floating-point vector data.

gcc/config/loongarch/loongarch.cc

index 462743f83994848c25785017a41f772d2fdec29d..b558efde4c7867485f25437cd07b5283309317cc 100644 (file)
@@ -1835,7 +1835,27 @@ loongarch_const_vector_same_bytes_p (rtx op, machine_mode mode)
 
   first = CONST_VECTOR_ELT (op, 0);
   bytes = GET_MODE_UNIT_SIZE (mode);
-  val = INTVAL (first);
+
+  if (GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT)
+    {
+      rtx val_s = CONST_VECTOR_ELT (op, 0);
+      const REAL_VALUE_TYPE *x = CONST_DOUBLE_REAL_VALUE (val_s);
+      if (GET_MODE (val_s) == DFmode)
+       {
+         long tmp[2];
+         REAL_VALUE_TO_TARGET_DOUBLE (*x, tmp);
+         val = (unsigned HOST_WIDE_INT) tmp[1] << 32 | tmp[0];
+       }
+      else
+       {
+         long tmp;
+         REAL_VALUE_TO_TARGET_SINGLE (*x, tmp);
+         val = (unsigned HOST_WIDE_INT) tmp;
+       }
+    }
+  else
+    val = UINTVAL (first);
+
   first_byte = val & 0xff;
   for (i = 1; i < bytes; i++)
     {