public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][AArch64][14/14] Reuse target_option_current_node when passing pragma string to target attribute
@ 2015-07-16 15:21 Kyrill Tkachov
  2015-07-21 17:42 ` James Greenhalgh
  0 siblings, 1 reply; 2+ messages in thread
From: Kyrill Tkachov @ 2015-07-16 15:21 UTC (permalink / raw)
  To: GCC Patches; +Cc: Marcus Shawcroft, Richard Earnshaw, James Greenhalgh

[-- 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);

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

* Re: [PATCH][AArch64][14/14] Reuse target_option_current_node when passing pragma string to target attribute
  2015-07-16 15:21 [PATCH][AArch64][14/14] Reuse target_option_current_node when passing pragma string to target attribute Kyrill Tkachov
@ 2015-07-21 17:42 ` James Greenhalgh
  0 siblings, 0 replies; 2+ messages in thread
From: James Greenhalgh @ 2015-07-21 17:42 UTC (permalink / raw)
  To: Kyrill Tkachov; +Cc: GCC Patches, Marcus Shawcroft, Richard Earnshaw

On Thu, Jul 16, 2015 at 04:21:22PM +0100, Kyrill Tkachov wrote:
> 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?

OK.

Thanks,
James

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


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

end of thread, other threads:[~2015-07-21 17:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16 15:21 [PATCH][AArch64][14/14] Reuse target_option_current_node when passing pragma string to target attribute Kyrill Tkachov
2015-07-21 17:42 ` 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).