Tested with

make -k check RUNTESTFLAGS="--target_board=sh-sim\{-m2/-ml,-m2/-mb,-m2a/-
mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"

Committed to master.

Best regards,
Oleg Endo

gcc/ChangeLog:

        PR target/116709
        * config/sh/sh.md (movsf_ie): Mark constant-pool load FPUL
        alternative with '*'.


gcc/testsuite/ChangeLog:

        PR target/116709
        * gcc.target.sh/pr116709.c: New test.
From 899588f3cc1afe045904a238cb060d4254497c2f Mon Sep 17 00:00:00 2001
From: Oleg Endo <[email protected]>
Date: Sat, 4 Jul 2026 15:07:48 +0900
Subject: [PATCH] SH: Avoid FPUL for fp-constant loads

For an fp-constant loaded from the constant pool, there is only one
movsf_ie alternative with the multi-class constraint "fy".
Change the FPUL alternative to '*y' so that IRA costs it as FP_REGS.
LRA still accepts the FPUL variant when it is really needed but treats
it as more expensive, which discourages FPUL usage for regular fp-regs.

gcc/ChangeLog:

	PR target/116709
	* config/sh/sh.md (movsf_ie): Mark constant-pool load FPUL
	alternative with '*'.
---
 gcc/config/sh/sh.md                    |  6 +++---
 gcc/testsuite/gcc.target/sh/pr116709.c | 10 ++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/sh/pr116709.c

diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md
index 4a15af7..d5f6c80 100644
--- a/gcc/config/sh/sh.md
+++ b/gcc/config/sh/sh.md
@@ -6196,11 +6196,11 @@
 ;; when the destination changes mode.
 (define_insn "movsf_ie"
   [(set (match_operand:SF 0 "general_movdst_operand"
-			        "=f,r,f,f,fy, f,m, r, r,m,f,y,y,rf,r,y,<,y,y")
+			        "=f,r,f,f,f*y,f,m, r, r,m,f,y,y,rf,r,y,<,y,y")
 	(match_operand:SF 1 "general_movsrc_operand"
-			        " f,r,G,H,FQ,mf,f,FQ,mr,r,y,f,>,fr,y,r,y,>,y"))
+			        " f,r,G,H, FQ,mf,f,FQ,mr,r,y,f,>,fr,y,r,y,>,y"))
    (use (reg:SI FPSCR_MODES_REG))
-   (clobber (match_scratch:SI 2 "=X,X,X,X,&z, X,X, X, X,X,X,X,X, y,X,X,X,X,X"))]
+   (clobber (match_scratch:SI 2 "=X,X,X,X, &z,X,X, X, X,X,X,X,X, y,X,X,X,X,X"))]
   "TARGET_SH2E
    && (arith_reg_operand (operands[0], SFmode)
        || fpul_operand (operands[0], SFmode)
diff --git a/gcc/testsuite/gcc.target/sh/pr116709.c b/gcc/testsuite/gcc.target/sh/pr116709.c
new file mode 100644
index 0000000..e07c196
--- /dev/null
+++ b/gcc/testsuite/gcc.target/sh/pr116709.c
@@ -0,0 +1,10 @@
+/* Verify that SFmode loads into FP registers are not ferried through FPUL.  */
+/* { dg-do compile { target { any_fpu } } }  */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "fpul" } } */
+
+_Complex float
+test_00 (void)
+{
+  return __builtin_complex (12.3f, 15.4f);
+}
--
libgit2 1.9.0

Reply via email to