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 cfcabd1..be03295 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 0aa96b9..f91e3f6 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 4589808..1239de7 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);
+}