S/390: Allow to use r2 to r4 as literal pool base.
authorDominik Vogt <vogt@linux.vnet.ibm.com>
Fri, 18 Dec 2015 10:36:57 +0000 (10:36 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Fri, 18 Dec 2015 10:36:57 +0000 (10:36 +0000)
gcc/ChangeLog

* config/s390/s390.c (s390_init_frame_layout): Try r4 to r2 for the
literal pool pointer.

gcc/testsuite/ChangeLog

* gcc.target/s390/litpool-r3-1.c: New test.

From-SVN: r231813

gcc/ChangeLog
gcc/config/s390/s390.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/litpool-r3-1.c [new file with mode: 0644]

index aab0e3abb3d24469eacf0331d4d9d5970ca322a4..802c8b8fd761844d11082a42d7e91d0738601de9 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-18  Dominik Vogt  <vogt@linux.vnet.ibm.com>
+
+       * config/s390/s390.c (s390_init_frame_layout): Try r4 to r2 for the
+       literal pool pointer.
+
 2015-12-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
 
        PR tree-optimization/68906
index ed684af1a66d698c1efefd8481052f56184d5a5b..cba88bbb0fccfc4108b78b9471e9596a6c82bc4a 100644 (file)
@@ -9584,10 +9584,17 @@ s390_init_frame_layout (void)
         as base register to avoid save/restore overhead.  */
       if (!base_used)
        cfun->machine->base_reg = NULL_RTX;
-      else if (crtl->is_leaf && !df_regs_ever_live_p (5))
-       cfun->machine->base_reg = gen_rtx_REG (Pmode, 5);
       else
-       cfun->machine->base_reg = gen_rtx_REG (Pmode, BASE_REGNUM);
+       {
+         int br = 0;
+
+         if (crtl->is_leaf)
+           /* Prefer r5 (most likely to be free).  */
+           for (br = 5; br >= 2 && df_regs_ever_live_p (br); br--)
+             ;
+         cfun->machine->base_reg =
+           gen_rtx_REG (Pmode, (br > 0) ? br : BASE_REGNUM);
+       }
 
       s390_register_info ();
       s390_frame_info ();
index eee043417098275b86054cb41122b21a02cef9ab..3053736ace68e61abb71b139647a0d7124f13073 100644 (file)
@@ -1,3 +1,7 @@
+2015-12-18  Dominik Vogt  <vogt@linux.vnet.ibm.com>
+
+       * gcc.target/s390/litpool-r3-1.c: New test.
+
 2015-12-18  Yuri Rumyantsev  <ysrumyan@gmail.com>
 
        PR tree-optimization/68906
diff --git a/gcc/testsuite/gcc.target/s390/litpool-r3-1.c b/gcc/testsuite/gcc.target/s390/litpool-r3-1.c
new file mode 100644 (file)
index 0000000..8ee50cf
--- /dev/null
@@ -0,0 +1,16 @@
+/* Validate that r3 may be used as the literal pool pointer.  Test that only on
+   64-bit for z900 to simplify the test.  It's not really different on 31-bit
+   or other cpus.  */
+
+/* { dg-do compile { target { lp64 } } } */
+/* { dg-options "-march=z900 -O2" } */
+
+__int128 gi;
+const int c = 0x12345678u;
+int foo(void)
+{
+       gi += c;
+       return c;
+}
+
+/* { dg-final { scan-assembler-times "\tlarl\t%r3,.L3" 1 } } */