From 0cd75bd61cd18bea7379c7ef14661ee89eeb38bf Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Mon, 2 Sep 2024 19:39:57 +0200
Subject: [PATCH 06/11] Patch 58883

---
 gcc/config/sh/sh.md | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md
index 506c9a9fd33..ed1586280e9 100644
--- a/gcc/config/sh/sh.md
+++ b/gcc/config/sh/sh.md
@@ -6564,16 +6564,17 @@
    (use (reg:SI FPSCR_MODES_REG))
    (use (reg:SI PIC_REG))
    (clobber (reg:SI PR_REG))
-   (clobber (match_scratch:SI 2 "=&r"))]
+   (clobber (reg:SI R1_REG))]
   "TARGET_SH2"
   "#"
   "reload_completed"
   [(const_int 0)]
 {
   rtx lab = PATTERN (gen_call_site ());
-  
-  sh_expand_sym_label2reg (operands[2], operands[0], lab, false);
-  emit_call_insn (gen_calli_pcrel (operands[2], operands[1], copy_rtx (lab)));
+  rtx scr = gen_rtx_REG (Pmode, R1_REG);
+
+  sh_expand_sym_label2reg (scr, operands[0], lab, false);
+  emit_call_insn (gen_calli_pcrel (scr, operands[1], copy_rtx (lab)));
   DONE;
 }
   [(set_attr "type" "call")
@@ -6676,16 +6677,17 @@
    (use (reg:SI FPSCR_MODES_REG))
    (use (reg:SI PIC_REG))
    (clobber (reg:SI PR_REG))
-   (clobber (match_scratch:SI 3 "=&r"))]
+   (clobber (reg:SI R1_REG))]
   "TARGET_SH2"
   "#"
   "reload_completed"
   [(const_int 0)]
 {
   rtx lab = PATTERN (gen_call_site ());
+  rtx scr = gen_rtx_REG (Pmode, R1_REG);
 
-  sh_expand_sym_label2reg (operands[3], operands[1], lab, false);
-  emit_call_insn (gen_call_valuei_pcrel (operands[0], operands[3],
+  sh_expand_sym_label2reg (scr, operands[1], lab, false);
+  emit_call_insn (gen_call_valuei_pcrel (operands[0], scr,
 					 operands[2], copy_rtx (lab)));
   DONE;
 }
@@ -6874,7 +6876,7 @@
   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
 	 (match_operand 1 "" ""))
    (use (reg:SI FPSCR_MODES_REG))
-   (clobber (match_scratch:SI 2 "=&k"))
+   (clobber (reg:SI R3_REG))
    (return)]
   "TARGET_SH2 && !TARGET_FDPIC"
   "#"
@@ -6882,10 +6884,11 @@
   [(const_int 0)]
 {
   rtx lab = PATTERN (gen_call_site ());
+  rtx scr = gen_rtx_REG (Pmode, R3_REG);
   rtx call_insn;
 
-  sh_expand_sym_label2reg (operands[2], operands[0], lab, true);
-  call_insn = emit_call_insn (gen_sibcalli_pcrel (operands[2], operands[1],
+  sh_expand_sym_label2reg (scr, operands[0], lab, true);
+  call_insn = emit_call_insn (gen_sibcalli_pcrel (scr, operands[1],
 						  copy_rtx (lab)));
   SIBLING_CALL_P (call_insn) = 1;
   DONE;
@@ -6901,7 +6904,7 @@
 	 (match_operand 1))
    (use (reg:SI FPSCR_MODES_REG))
    (use (reg:SI PIC_REG))
-   (clobber (match_scratch:SI 2 "=k"))
+   (clobber (reg:SI R1_REG))
    (return)]
   "TARGET_SH2 && TARGET_FDPIC"
   "#"
@@ -6909,9 +6912,10 @@
   [(const_int 0)]
 {
   rtx lab = PATTERN (gen_call_site ());
+  rtx scr = gen_rtx_REG (Pmode, R1_REG);
 
-  sh_expand_sym_label2reg (operands[2], operands[0], lab, true);
-  rtx i = emit_call_insn (gen_sibcalli_pcrel_fdpic (operands[2], operands[1],
+  sh_expand_sym_label2reg (scr, operands[0], lab, true);
+  rtx i = emit_call_insn (gen_sibcalli_pcrel_fdpic (scr, operands[1],
 						    copy_rtx (lab)));
   SIBLING_CALL_P (i) = 1;
   DONE;
-- 
2.45.2

