sh.md (udivsi3): Don't put udivsi3_i4_media instructions into a libcall block.
authorRichard Sandiford <rsandifo@redhat.com>
Wed, 20 Nov 2002 09:59:28 +0000 (09:59 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 20 Nov 2002 09:59:28 +0000 (09:59 +0000)
* config/sh/sh.md (udivsi3): Don't put udivsi3_i4_media instructions
into a libcall block.
(divsi3): Likewise divsi3_i4_media.

From-SVN: r59299

gcc/ChangeLog
gcc/config/sh/sh.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20021120-2.c [new file with mode: 0644]

index e3ddb43bf83a7d3c550c766d63d389f1f2068b99..414a9475858f1d7c86530ba273adf994829ac8ac 100644 (file)
@@ -1,3 +1,9 @@
+2002-11-20  Richard Sandiford  <rsandifo@redhat.com>
+
+       * config/sh/sh.md (udivsi3): Don't put udivsi3_i4_media instructions
+       into a libcall block.
+       (divsi3): Likewise divsi3_i4_media.
+
 2002-11-20  Richard Sandiford  <rsandifo@redhat.com>
 
        * global.c (find_reg): Check HARD_REGNO_NREGS before kicking
index ed14fbd4e33d0546478af1405e43be1034a9d7e2..956c2253b9bb198ddb0df7ff3a88042a538fac5c 100644 (file)
   ""
   "
 {
-  rtx first = 0, last;
+  rtx first, last;
 
   operands[3] = gen_reg_rtx (Pmode);
   /* Emit the move of the address to a pseudo outside of the libcall.  */
     {
       operands[1] = force_reg (SImode, operands[1]);
       operands[2] = force_reg (SImode, operands[2]);
-      last = gen_udivsi3_i4_media (operands[0], operands[1], operands[2]);
-      first = last;
+      emit_insn (gen_udivsi3_i4_media (operands[0], operands[1], operands[2]));
+      DONE;
     }
   else if (TARGET_SH5)
     {
                      gen_rtx_SYMBOL_REF (SImode, \"__udivsi3\"));
       last = gen_udivsi3_i1 (operands[0], operands[3]);
     }
-  if (! first)
-    {
-      first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
-      emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
-    }
+  first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
+  emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
   last = emit_insn (last);
   /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
      invariant code motion can move it.  */
   ""
   "
 {
-  rtx first = 0, last;
+  rtx first, last;
 
   operands[3] = gen_reg_rtx (Pmode);
   /* Emit the move of the address to a pseudo outside of the libcall.  */
     {
       operands[1] = force_reg (SImode, operands[1]);
       operands[2] = force_reg (SImode, operands[2]);
-      last = gen_divsi3_i4_media (operands[0], operands[1], operands[2]);
-      first = last;
+      emit_insn (gen_divsi3_i4_media (operands[0], operands[1], operands[2]));
+      DONE;
     }
   else if (TARGET_SH5)
     {
       emit_move_insn (operands[3], gen_rtx_SYMBOL_REF (SImode, \"__sdivsi3\"));
       last = gen_divsi3_i1 (operands[0], operands[3]);
     }
-  if (! first)
-    {
-      first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
-      emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
-    }
+  first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
+  emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
   last = emit_insn (last);
   /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
      invariant code motion can move it.  */
index 1ba905f524ab50c8c7b4ecf632b320561da0dde8..01d9f4148adb4cdde744c3ab6bfcc705c9e5f101 100644 (file)
@@ -1,3 +1,7 @@
+2002-11-20  Richard Sandiford  <rsandifo@redhat.com>
+
+       * gcc.c-torture/execute/20021120-2.c: New test.
+
 2002-11-20  Richard Sandiford  <rsandifo@redhat.com>
 
        * gcc.c-torture/execute/20021120-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20021120-2.c b/gcc/testsuite/gcc.c-torture/execute/20021120-2.c
new file mode 100644 (file)
index 0000000..d8876c0
--- /dev/null
@@ -0,0 +1,21 @@
+int g1, g2;
+
+void foo (int x)
+{
+  int y;
+
+  if (x)
+    y = 793;
+  else
+    y = 793;
+  g1 = 7930 / y;
+  g2 = 7930 / x;
+}
+
+int main ()
+{
+  foo (793);
+  if (g1 != 10 || g2 != 10)
+    abort ();
+  exit (0);
+}