Support for conversion between scalar INT and scalar FP.
gcc/ChangeLog:
* config/loongarch/loongarch.cc
(loongarch_can_change_mode_class): Support for conversion
between scalar INT and scalar FP.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/extendsidi2-combine.c: New test.
* gcc.target/loongarch/spill-less.c: New test.
loongarch_can_change_mode_class (machine_mode from, machine_mode to,
reg_class_t rclass)
{
+ if ((INTEGRAL_MODE_P (from) && FLOAT_MODE_P (to))
+ || (INTEGRAL_MODE_P (to) && FLOAT_MODE_P (from)))
+ return true;
+
/* Allow conversions between different LSX/LASX vector modes. */
if (LASX_SUPPORTED_MODE_P (from) && LASX_SUPPORTED_MODE_P (to))
return true;
--- /dev/null
+/* { dg-do compile { target { loongarch64*-*-* } } } */
+/* { dg-options "-O3 -fno-strict-aliasing" } */
+
+int
+test (double a)
+{
+ int z;
+
+ *((double *)&z) = a;
+ return z;
+}
+
+/* { dg-final { scan-assembler-not "slli\\.w" } } */
--- /dev/null
+/* { dg-do compile { target { loongarch64*-*-* } } } */
+/* { dg-options "-O3 -fno-strict-aliasing" } */
+
+double
+convert (long long in)
+{
+ double f;
+ *((long long *)&f) = in;
+ return f;
+}
+
+/* { dg-final { scan-assembler-not "st\\.d" } } */
+/* { dg-final { scan-assembler-not "fld\\.d" } } */
+/* { dg-final { scan-assembler "movgr2fr\\.d" } } */