summaryrefslogtreecommitdiff
path: root/gcc/attribs.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-12-03 11:07:44 +0100
committerJakub Jelinek <jakub@redhat.com>2021-12-03 11:07:44 +0100
commit7e71909af2cf3aeec9bed4f6a3cc42c1d17cd661 (patch)
tree98b6eeac5f6de3c59e6d120b19dd7f858a875500 /gcc/attribs.h
parentfe7c3ecff1f9c0520090a77fa824d8c5d9dbec12 (diff)
downloadgcc-7e71909af2cf3aeec9bed4f6a3cc42c1d17cd661.tar.gz
x86: Speed up target attribute handling by using a cache
The target attribute handling is very expensive and for the common case from x86intrin.h where many functions get implicitly the same target attribute, we can speed up compilation a lot by caching it. The following patches both create a single entry cache, where they cache for a particular target attribute argument list the resulting DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_SPECIFIC_OPTIMIZATION values from ix86_valid_target_attribute_p and use the cache if the args are the same as last time and we start either from NULL values of those, or from the recorded values for those from last time. Compiling a simple: #include <x86intrin.h> int i; testcase with ./cc1 -quiet -O2 -isystem include/ test.c takes on my WS without the patches ~0.392s and with either of the patches ~0.182s, i.e. roughly half the time as before. For ./cc1plus -quiet -O2 -isystem include/ test.c it is slightly worse, the speed up is from ~0.613s to ~0.403s. The difference between the 2 patches is that the first one uses copy_list while the second one uses a vec, so I think the second one has the advantage of creating less GC garbage. I've verified both patches achieve the same content of those DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_SPECIFIC_OPTIMIZATION nodes as before on x86intrin.h by doing debug_tree on those and comparing the stderr from without these patches to with these patches. 2021-12-03 Jakub Jelinek <jakub@redhat.com> * attribs.h (simple_cst_list_equal): Declare. * attribs.c (simple_cst_list_equal): No longer static. * config/i386/i386-options.c (target_attribute_cache): New variable. (ix86_valid_target_attribute_p): Cache DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_SPECIFIC_OPTIMIZATION based on args.
Diffstat (limited to 'gcc/attribs.h')
-rw-r--r--gcc/attribs.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/attribs.h b/gcc/attribs.h
index 73f0ccc24b8..f5899d83c0b 100644
--- a/gcc/attribs.h
+++ b/gcc/attribs.h
@@ -60,6 +60,7 @@ extern tree build_type_attribute_variant (tree, tree);
extern tree build_decl_attribute_variant (tree, tree);
extern tree build_type_attribute_qual_variant (tree, tree, int);
+extern bool simple_cst_list_equal (const_tree, const_tree);
extern bool attribute_value_equal (const_tree, const_tree);
/* Return 0 if the attributes for two types are incompatible, 1 if they