From 44e13e607f63ef73c75cd64b041f24b0eeafd992 Mon Sep 17 00:00:00 2001 From: Pat Haugen Date: Thu, 14 Sep 2017 18:29:44 +0000 Subject: [PATCH] rs6000.c (rs6000_set_up_by_prologue): Make sure the TOC reg (r2) isn't in the set of registers defined in the prologue. * config/rs6000/rs6000.c (rs6000_set_up_by_prologue): Make sure the TOC reg (r2) isn't in the set of registers defined in the prologue. * gcc.target/powerpc/r2_shrink-wrap.c: New. From-SVN: r252768 --- gcc/ChangeLog | 5 +++++ gcc/config/rs6000/rs6000.c | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ .../gcc.target/powerpc/r2_shrink-wrap.c | 17 +++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/r2_shrink-wrap.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 31c9d0afb2b..b66faebbc15 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-09-14 Pat Haugen + + * config/rs6000/rs6000.c (rs6000_set_up_by_prologue): Make sure the TOC + reg (r2) isn't in the set of registers defined in the prologue. + 2017-09-14 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 3fee22836fe..6dd726e4de4 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -37804,6 +37804,11 @@ rs6000_set_up_by_prologue (struct hard_reg_set_container *set) add_to_hard_reg_set (&set->set, Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM); if (cfun->machine->split_stack_argp_used) add_to_hard_reg_set (&set->set, Pmode, 12); + + /* Make sure the hard reg set doesn't include r2, which was possibly added + via PIC_OFFSET_TABLE_REGNUM. */ + if (TARGET_TOC) + remove_from_hard_reg_set (&set->set, Pmode, TOC_REGNUM); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ad6ef296cbb..005c0b9882c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-09-14 Pat Haugen + + * gcc.target/powerpc/r2_shrink-wrap.c: New. + 2017-09-14 Will Schmidt * gcc.target/powerpc/fold-vec-ld-longlong.c: Add diff --git a/gcc/testsuite/gcc.target/powerpc/r2_shrink-wrap.c b/gcc/testsuite/gcc.target/powerpc/r2_shrink-wrap.c new file mode 100644 index 00000000000..b81b9b1c2ee --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/r2_shrink-wrap.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */ + +/* Verify we move the prologue past the TOC reference of 'j' and shrink-wrap + the function. */ +void bar(); +int j; +void foo(int i) +{ + j = i; + if (i > 0) + { + bar(); + } +} + +/* { dg-final { scan-rtl-dump-times "Performing shrink-wrapping" 1 "pro_and_epilogue" } } */ -- 2.30.2