From b4db40bf1d01d70605906d9c6a5274acba677668 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 29 Jun 2004 21:27:07 +0200 Subject: [PATCH] re PR target/16195 ([3.4 only] Miscompilation of GCC 3.3.x by 3.4.x) 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 | 9 ++++++++ gcc/config/rs6000/rs6000.c | 16 ++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/20040625-1.c | 37 +++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/20040625-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cfcabd159b6..be03295f9c6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2004-06-29 Jakub Jelinek + + 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 Fix gcc.dg/builtin-apply2.c failures: diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 0aa96b99ff6..f91e3f67814 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -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)))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4589808a7d3..1239de739fb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-06-29 Jakub Jelinek + + PR target/16195 + * gcc.dg/20040625-1.c: New test. + 2004-06-29 Tobias Schlueter * 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 index 00000000000..e05e87c9124 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20040625-1.c @@ -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); +} -- 2.30.2