public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tamar Christina <Tamar.Christina@arm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: James Greenhalgh <James.Greenhalgh@arm.com>,
	Richard Earnshaw	<Richard.Earnshaw@arm.com>,
	Marcus Shawcroft <Marcus.Shawcroft@arm.com>, nd	<nd@arm.com>
Subject: [PATCH] Allow FP to be used as a call-saved registe
Date: Mon, 05 Sep 2016 15:00:00 -0000	[thread overview]
Message-ID: <VI1PR0801MB2031CAD1F37FA14F8AA4B6CEFFE60@VI1PR0801MB2031.eurprd08.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

Hi All,

This patch allows the FP register to be used as a call-saved
register when -fomit-frame-pointer is used.

The change is done in such a way that the defaults do not change.
To use the FP register both -fomit-frame-pointer and
-fcall-saved-<hard_fp_reg> need to be used.

Regression ran on aarch64-none-linux-gnu and no regressions.
Bootstrapped and ran regressions on `x86_64` and no regressions.

A new test fp_free_1 was added to test functionality.

Ok for trunk?

Thanks,
Tamar

PS. I don't have commit rights so if OK can someone apply the patch for me.

gcc/
2016-09-01  Tamar Christina  <tamar.christina@arm.com>

	* gcc/reginfo.c (fix_register): Allow FP to be set if
	-fomit-frame-pointer.

gcc/testsuite/
2016-08-17  Tamar Christina  <tamar.christina@arm.com>

	* gcc.target/aarch64/fp_free_1.c: New.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gcc.patch --]
[-- Type: text/x-patch; name=gcc.patch, Size: 1905 bytes --]

diff --git a/gcc/reginfo.c b/gcc/reginfo.c
index 0cda6aa620098c752522add589b42631b382d9fc..ea96e236a5f76fb7ddc2c9406b7b377aa0eb3087 100644
--- a/gcc/reginfo.c
+++ b/gcc/reginfo.c
@@ -692,12 +692,13 @@ fix_register (const char *name, int fixed, int call_used)
       for (i = reg; i < reg + nregs; i++)
 	{
 	  if ((i == STACK_POINTER_REGNUM
+	       || (
 #ifdef HARD_FRAME_POINTER_REGNUM
-	       || i == HARD_FRAME_POINTER_REGNUM
+		   i == HARD_FRAME_POINTER_REGNUM
 #else
-	       || i == FRAME_POINTER_REGNUM
+		   i == FRAME_POINTER_REGNUM
 #endif
-	       )
+		    && !flag_omit_frame_pointer))
 	      && (fixed == 0 || call_used == 0))
 	    {
 	      switch (fixed)
diff --git a/gcc/testsuite/gcc.target/aarch64/fp_free_1.c b/gcc/testsuite/gcc.target/aarch64/fp_free_1.c
new file mode 100644
index 0000000000000000000000000000000000000000..79e23b13d3fb0f801e201c69286d27bac97aa013
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fp_free_1.c
@@ -0,0 +1,32 @@
+/* { dg-do run { target aarch64-*-* } } */
+/* { dg-options "-O2 -fno-inline -fomit-frame-pointer -ffixed-x2 -ffixed-x3 -ffixed-x4 -ffixed-x5 -ffixed-x6 -ffixed-x7 -ffixed-x8 -ffixed-x9 -ffixed-x10 -ffixed-x11 -ffixed-x12 -ffixed-x13 -ffixed-x14 -ffixed-x15 -ffixed-x16 -ffixed-x17 -ffixed-x18 -ffixed-x19 -ffixed-x20 -ffixed-x21 -ffixed-x22 -ffixed-x23 -ffixed-x24 -ffixed-x25 -ffixed-x26 -ffixed-x27 -ffixed-x28 -ffixed-x30 -mgeneral-regs-only -fno-ipa-cp -fno-schedule-fusion -fno-peephole2 -fcall-saved-x29  -fdump-rtl-ira" } */
+
+extern void abort ();
+
+int
+dec (int a, int b)
+{
+  return a + b;
+}
+
+int
+cal (int a, int b)
+{
+  int sum1 = a * b;
+  int sum2 = a / b;
+  int sum = dec (sum1, sum2);
+  return a + b + sum + sum1 + sum2;
+}
+
+int
+main (int argc, char **argv)
+{
+  int ret = cal (2, 1);
+
+  if (ret != 11)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-rtl-dump "assign reg 29" "ira" } } */

             reply	other threads:[~2016-09-05 14:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05 15:00 Tamar Christina [this message]
2016-09-12 10:41 ` James Greenhalgh
2016-09-12 17:22 ` Jeff Law
2016-09-13 11:15   ` Tamar Christina
2016-09-15 16:43     ` Jeff Law
2016-09-19 10:55       ` Richard Earnshaw (lists)
2016-09-19 16:56         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR0801MB2031CAD1F37FA14F8AA4B6CEFFE60@VI1PR0801MB2031.eurprd08.prod.outlook.com \
    --to=tamar.christina@arm.com \
    --cc=James.Greenhalgh@arm.com \
    --cc=Marcus.Shawcroft@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).