Hi,
The attached patch fixes PR 64652. Tested with
make -k check-gcc RUNTESTFLAGS="sh-torture.exp --target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
Committed as r219824.
Cheers,
Oleg
gcc/ChangeLog:
PR target/64652
* config/sh/sh.md (udivsi3_i4, divsi3_i4): Make use of sfunc address
reg appear first in the parallel.
gcc/testsuite/ChangeLog:
PR target/64652
* gcc.target/sh/torture/pr64652.c: New.
Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md (revision 219823)
+++ gcc/config/sh/sh.md (working copy)
@@ -2402,8 +2402,8 @@
(clobber (reg:SI R4_REG))
(clobber (reg:SI R5_REG))
(clobber (reg:SI FPSCR_STAT_REG))
- (use (reg:SI FPSCR_MODES_REG))
- (use (match_operand:SI 1 "arith_reg_operand" "r"))]
+ (use (match_operand:SI 1 "arith_reg_operand" "r"))
+ (use (reg:SI FPSCR_MODES_REG))]
"TARGET_FPU_DOUBLE && ! TARGET_FPU_SINGLE"
"jsr @%1%#"
[(set_attr "type" "sfunc")
@@ -2674,8 +2674,8 @@
(clobber (reg:DF DR0_REG))
(clobber (reg:DF DR2_REG))
(clobber (reg:SI FPSCR_STAT_REG))
- (use (reg:SI FPSCR_MODES_REG))
- (use (match_operand:SI 1 "arith_reg_operand" "r"))]
+ (use (match_operand:SI 1 "arith_reg_operand" "r"))
+ (use (reg:SI FPSCR_MODES_REG))]
"TARGET_FPU_DOUBLE && ! TARGET_FPU_SINGLE"
"jsr @%1%#"
[(set_attr "type" "sfunc")
Index: gcc/testsuite/gcc.target/sh/torture/pr64652.c
===================================================================
--- gcc/testsuite/gcc.target/sh/torture/pr64652.c (revision 0)
+++ gcc/testsuite/gcc.target/sh/torture/pr64652.c (revision 0)
@@ -0,0 +1,10 @@
+/* Check that using -mdiv=call-fp compiles without fuzz. */
+/* { dg-do compile } */
+/* { dg-additional-options "-mdiv=call-fp" } */
+/* { dg-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */
+
+int
+test (int a, int b, int c, int d)
+{
+ return (a / b) + c + d;
+}