re PR target/16195 ([3.4 only] Miscompilation of GCC 3.3.x by 3.4.x)
authorJakub Jelinek <jakub@redhat.com>
Tue, 29 Jun 2004 19:27:07 +0000 (21:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 29 Jun 2004 19:27:07 +0000 (21:27 +0200)
PR target/16195
* config/rs6000/rs6000.c (rs6000_conditional_register_usage): Make
r30 fixed if TARGET_TOC && TARGET_MINIMAL_TOC.
(first_reg_to_save): Pretend call_used_regs[30] is 0 if
TARGET_TOC && TARGET_MINIMAL_TOC.
(rs6000_emit_prologue, rs6000_emit_epilogue): Likewise.

* gcc.dg/20040625-1.c: New test.

From-SVN: r83872

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20040625-1.c [new file with mode: 0644]

index cfcabd159b62232a9a2ded432d57f5cdac6aeb83..be03295f9c6bda37c9c55dbfc4ddeeff82aed74e 100644 (file)
@@ -1,3 +1,12 @@
+2004-06-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/16195
+       * config/rs6000/rs6000.c (rs6000_conditional_register_usage): Make
+       r30 fixed if TARGET_TOC && TARGET_MINIMAL_TOC.
+       (first_reg_to_save): Pretend call_used_regs[30] is 0 if
+       TARGET_TOC && TARGET_MINIMAL_TOC.
+       (rs6000_emit_prologue, rs6000_emit_epilogue): Likewise.
+
 2004-06-29  J"orn Rennecke <joern.rennecke@superh.com>
 
        Fix gcc.dg/builtin-apply2.c failures:
index 0aa96b99ff66893c836a316f9db3233518cf5cb2..f91e3f67814843a7881fbff88560d41452af0186 100644 (file)
@@ -3480,6 +3480,10 @@ rs6000_conditional_register_usage (void)
       = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
       = call_really_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
 
+  if (TARGET_TOC && TARGET_MINIMAL_TOC)
+    fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]
+      = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;
+
   if (TARGET_ALTIVEC)
     global_regs[VSCR_REGNO] = 1;
 
@@ -10834,7 +10838,8 @@ first_reg_to_save (void)
        && (! call_used_regs[first_reg]
            || (first_reg == RS6000_PIC_OFFSET_TABLE_REGNUM
                && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
-                   || (DEFAULT_ABI == ABI_DARWIN && flag_pic)))))
+                   || (DEFAULT_ABI == ABI_DARWIN && flag_pic)
+                   || (TARGET_TOC && TARGET_MINIMAL_TOC)))))
       break;
 
 #if TARGET_MACHO
@@ -12428,7 +12433,10 @@ rs6000_emit_prologue (void)
       int i;
       for (i = 0; i < 32 - info->first_gp_reg_save; i++)
        if ((regs_ever_live[info->first_gp_reg_save+i] 
-            && ! call_used_regs[info->first_gp_reg_save+i])
+            && (! call_used_regs[info->first_gp_reg_save+i]
+                || (i+info->first_gp_reg_save
+                    == RS6000_PIC_OFFSET_TABLE_REGNUM
+                    && TARGET_TOC && TARGET_MINIMAL_TOC)))
            || (i+info->first_gp_reg_save == RS6000_PIC_OFFSET_TABLE_REGNUM
                && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
                    || (DEFAULT_ABI == ABI_DARWIN && flag_pic))))
@@ -12877,7 +12885,9 @@ rs6000_emit_epilogue (int sibcall)
   else
     for (i = 0; i < 32 - info->first_gp_reg_save; i++)
       if ((regs_ever_live[info->first_gp_reg_save+i] 
-          && ! call_used_regs[info->first_gp_reg_save+i])
+          && (! call_used_regs[info->first_gp_reg_save+i]
+              || (i+info->first_gp_reg_save == RS6000_PIC_OFFSET_TABLE_REGNUM
+                  && TARGET_TOC && TARGET_MINIMAL_TOC)))
          || (i+info->first_gp_reg_save == RS6000_PIC_OFFSET_TABLE_REGNUM
              && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
                  || (DEFAULT_ABI == ABI_DARWIN && flag_pic))))
index 4589808a7d340bd952ab25eacc152ba1f1e60728..1239de739fb80168f8deecf22b6526afaeac051d 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/16195
+       * gcc.dg/20040625-1.c: New test.
+
 2004-06-29  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * gfortran.fortran-torture/execute/parameter_2.f90: New test.
diff --git a/gcc/testsuite/gcc.dg/20040625-1.c b/gcc/testsuite/gcc.dg/20040625-1.c
new file mode 100644 (file)
index 0000000..e05e87c
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-options "-mminimal-toc" { target powerpc64-*-* powerpc-ibm-aix* } } */
+
+extern void abort (void);
+extern void exit (int);
+
+double __attribute__((noinline))
+foo (void)
+{
+  return 16441577472.0;
+}
+
+double __attribute__((noinline))
+bar (double x)
+{
+  return x;
+}
+
+int __attribute__((noinline))
+test (void)
+{
+  double x = foo ();
+  x = bar (x);
+  x /= 1024 * 1024 * 1024;
+  x *= 70;
+  x = x < 70 ? x : 70;
+  x += 30;
+  return x;
+}
+
+int main (void)
+{
+  if (test () != 100)
+    abort ();
+  exit (0);
+}