public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kyrill Tkachov <kyrylo.tkachov@arm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Marcus Shawcroft <marcus.shawcroft@arm.com>,
	 Richard Earnshaw <Richard.Earnshaw@arm.com>,
	James Greenhalgh <james.greenhalgh@arm.com>
Subject: [PATCH][AArch64][14/14] Reuse target_option_current_node when passing pragma string to target attribute
Date: Thu, 16 Jul 2015 15:21:00 -0000	[thread overview]
Message-ID: <55A7CBF2.6070902@arm.com> (raw)

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

Hi all,

This patch improves compilation times for code using the arm_neon.h intrinsics.
The problem there is that since we now wrap all the intrinsics in arm_neon.h inside a pragma,
the midend will apply the pragma string onto every single intrinsic as an attribute, calling
the target attribute parsing code thousands of times on the same string.  I've seen this cause
slowdown on large intrinsics programs in the area of 3-5%.

This patch checks if the ARGS we're supposed to process is the same as the prgma already
processed by the pragma processing code in aarch64-c.c. If it is, then we know that the correct
target node is already set in target_option_current_node, so we can just reuse that, saving us
the trouble of parsing the string.

This gets compilation times for large intrinsic programs to the previous levels.
We still get a compile-time hit on small programs due to grokdeclarator in the frontend
appearing high in the profile due to the pragma use, I presume. But for large programs
we should be good.  The compilation time will be dominated by the other parts of the compiler.
In any case, for small programs, garbage collection is at the top of the profile in either case.

Bootstrapped and tested on aarch64.

Ok for trunk?

Thanks,
Kyrill

2015-07-16  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * config/aarch64/aarch64.c (aarch64_option_valid_attribute_p):
     Exit early and use target_option_current_node if processing current
     pragma.

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

commit 0bbab2ef7fb4be18780b5c87d338d2f9d9116fe4
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Thu May 28 15:33:49 2015 +0100

    [AArch64][14/N] Reuse target_option_current_node when passing pragma string to target attribute

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index f0f3cdc..f8c5aa4 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -8431,6 +8431,18 @@ aarch64_option_valid_attribute_p (tree fndecl, tree, tree args, int)
   tree old_optimize;
   tree new_target, new_optimize;
   tree existing_target = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
+
+  /* If what we're processing is the current pragma string then the
+     target option node is already stored in target_option_current_node
+     by aarch64_pragma_target_parse in aarch64-c.c.  Use that to avoid
+     having to re-parse the string.  This is especially useful to keep
+     arm_neon.h compile times down since that header contains a lot
+     of intrinsics enclosed in pragmas.  */
+  if (!existing_target && args == current_target_pragma)
+    {
+      DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = target_option_current_node;
+      return true;
+    }
   tree func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
 
   old_optimize = build_optimization_node (&global_options);

             reply	other threads:[~2015-07-16 15:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 15:21 Kyrill Tkachov [this message]
2015-07-21 17:42 ` James Greenhalgh

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=55A7CBF2.6070902@arm.com \
    --to=kyrylo.tkachov@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=james.greenhalgh@arm.com \
    --cc=marcus.shawcroft@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).