* sched-deps.c (sched_analyze): Check HARD_REGNO_CALL_PART_CLOBBERED.
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Nov 2002 10:03:36 +0000 (10:03 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Nov 2002 10:03:36 +0000 (10:03 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59300 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/sched-deps.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20021120-3.c [new file with mode: 0644]

index 414a947..5961678 100644 (file)
@@ -1,5 +1,9 @@
 2002-11-20  Richard Sandiford  <rsandifo@redhat.com>
 
+       * sched-deps.c (sched_analyze): Check HARD_REGNO_CALL_PART_CLOBBERED.
+
+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.
index cf762cc..98b0732 100644 (file)
@@ -1287,8 +1287,12 @@ sched_analyze (deps, head, tail)
                    SET_REGNO_REG_SET (reg_pending_sets, i);
                    SET_REGNO_REG_SET (reg_pending_uses, i);
                  }
-               /* Other call-clobbered hard regs may be clobbered.  */
-               else if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i))
+               /* Other call-clobbered hard regs may be clobbered.
+                  Since we only have a choice between 'might be clobbered'
+                  and 'definitely not clobbered', we must include all
+                  partly call-clobbered registers here.  */
+               else if (HARD_REGNO_CALL_PART_CLOBBERED (i, reg_raw_mode[i])
+                        || TEST_HARD_REG_BIT (regs_invalidated_by_call, i))
                  SET_REGNO_REG_SET (reg_pending_clobbers, i);
                /* We don't know what set of fixed registers might be used
                   by the function, but it is certain that the stack pointer
index 01d9f41..aef7826 100644 (file)
@@ -1,5 +1,9 @@
 2002-11-20  Richard Sandiford  <rsandifo@redhat.com>
 
+       * gcc.c-torture/execute/20021120-3.c: New test.
+
+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>
diff --git a/gcc/testsuite/gcc.c-torture/execute/20021120-3.c b/gcc/testsuite/gcc.c-torture/execute/20021120-3.c
new file mode 100644 (file)
index 0000000..e875f1f
--- /dev/null
@@ -0,0 +1,26 @@
+/* Test whether a partly call-clobbered register will be moved over a call.
+   Although the original test case didn't use any GNUisms, it proved
+   difficult to reduce without the named register extension.  */
+#if __SH64__ == 32
+#define LOC asm ("r10")
+#else
+#define LOC
+#endif
+
+unsigned int foo (char *c, unsigned int x, unsigned int y)
+{
+  register unsigned int z LOC;
+
+  sprintf (c, "%d", x / y);
+  z = x + 1;
+  return z / (y + 1);
+}
+
+int main ()
+{
+  char c[16];
+
+  if (foo (c, ~1U, 4) != (~0U / 5))
+    abort ();
+  exit (0);
+}