public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch AArch64] Set TARGET_OMIT_STRUCT_RETURN_REG to true.
@ 2016-04-26 13:23 Ramana Radhakrishnan
  2016-04-27 14:06 ` James Greenhalgh
  0 siblings, 1 reply; 2+ messages in thread
From: Ramana Radhakrishnan @ 2016-04-26 13:23 UTC (permalink / raw)
  To: gcc-patches

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

As $SUBJECT. The reason this caught my eye on aarch64 is because
the return value register (x0) is not identical to the register in which
the hidden parameter for AArch64 is set (x8). Thus setting this to true
seems to be quite reasonable and shaves off 100 odd mov x0, x8's from
cc1 in a bootstrap build.

I don't expect this to make a huge impact on performance but as they say every little counts. 
The AAPCS64 is quite explicit about not requiring that the contents of x8 be kept live.

Bootstrapped and regression tested on aarch64.

Ok to apply ?

Ramana

gcc/
* config/aarch64/aarch64.c (TARGET_OMIT_STRUCT_RETURN_REG): Set to
true.

gcc/testsuite

* gcc.target/aarch64/struct_return.c: New test.

[-- Attachment #2: omit-struct-return-reg-patch.txt --]
[-- Type: text/plain, Size: 1381 bytes --]

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 335161992572d36144ceecd9bdda5f387f3a1a2b..df908a56ce5b024a56aeb4d6fcf74cbef0ac7132 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -14359,6 +14359,9 @@ aarch64_optab_supported_p (int op, machine_mode, machine_mode,
 #undef TARGET_OPTAB_SUPPORTED_P
 #define TARGET_OPTAB_SUPPORTED_P aarch64_optab_supported_p
 
+#undef TARGET_OMIT_STRUCT_RETURN_REG
+#define TARGET_OMIT_STRUCT_RETURN_REG true
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-aarch64.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/struct_return.c b/gcc/testsuite/gcc.target/aarch64/struct_return.c
new file mode 100644
index 0000000000000000000000000000000000000000..6d90b7e59537ea66ad89e3615a2b11f2838b8779
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/struct_return.c
@@ -0,0 +1,31 @@
+/* Test the absence of a spurious move from x8 to x0 for functions
+   return structures.  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct s
+{
+  long x;
+  long y;
+  long z;
+};
+
+struct s __attribute__((noinline))
+foo (long a, long d, long c)
+{
+  struct s b;
+  b.x = a;
+  b.y = d;
+  b.z = c;
+  return b;
+}
+
+int
+main (void)
+{
+  struct s x;
+  x = foo ( 10, 20, 30);
+  return x.x + x.y + x.z;
+}
+
+/* { dg-final { scan-assembler-not "mov\tx0, x8" } } */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch AArch64] Set TARGET_OMIT_STRUCT_RETURN_REG to true.
  2016-04-26 13:23 [Patch AArch64] Set TARGET_OMIT_STRUCT_RETURN_REG to true Ramana Radhakrishnan
@ 2016-04-27 14:06 ` James Greenhalgh
  0 siblings, 0 replies; 2+ messages in thread
From: James Greenhalgh @ 2016-04-27 14:06 UTC (permalink / raw)
  To: Ramana Radhakrishnan; +Cc: gcc-patches, nd

On Tue, Apr 26, 2016 at 02:22:58PM +0100, Ramana Radhakrishnan wrote:
> As $SUBJECT. The reason this caught my eye on aarch64 is because
> the return value register (x0) is not identical to the register in which
> the hidden parameter for AArch64 is set (x8). Thus setting this to true
> seems to be quite reasonable and shaves off 100 odd mov x0, x8's from
> cc1 in a bootstrap build.
> 
> I don't expect this to make a huge impact on performance but as they say
> every little counts.  The AAPCS64 is quite explicit about not requiring that
> the contents of x8 be kept live.
> 
> Bootstrapped and regression tested on aarch64.
> 
> Ok to apply ?

OK.

Thanks,
James

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-27 14:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-26 13:23 [Patch AArch64] Set TARGET_OMIT_STRUCT_RETURN_REG to true Ramana Radhakrishnan
2016-04-27 14:06 ` James Greenhalgh

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).