On Tue, Apr 16, 2019 at 1:39 PM Jakub Jelinek <ja...@redhat.com> wrote: > > On Tue, Apr 16, 2019 at 01:25:38PM +0200, Richard Biener wrote: > > So for the parser it's small differences that accumulate, for example > > a lot more comptype calls via null_ptr_cst_p (via char_type_p) via the new > > conversion_null_warnings which is called even without any warning option. > > > > Possible speedup to null_ptr_cst_p is to avoid the expensive char_type_p > > (called 50000 times in GCC 9 vs. only 2000 times in GCC 8): > > If we do this (looks like a good idea to me), perhaps we should do also > following (first part just doing what you've done in yet another spot, > moving the less expensive checks first, because null_node_p strips location > wrappers etc.) and the second not to call conversion_null_warnings at all > if we don't want to warn (though, admittedly while > warn_zero_as_null_pointer_constant defaults to 0, warn_conversion_null > defaults to 1). > > --- gcc/cp/call.c 2019-04-12 21:47:06.301924378 +0200 > +++ gcc/cp/call.c 2019-04-16 13:35:59.779977641 +0200 > @@ -6844,8 +6844,9 @@ static void > conversion_null_warnings (tree totype, tree expr, tree fn, int argnum) > { > /* Issue warnings about peculiar, but valid, uses of NULL. */ > - if (null_node_p (expr) && TREE_CODE (totype) != BOOLEAN_TYPE > - && ARITHMETIC_TYPE_P (totype)) > + if (TREE_CODE (totype) != BOOLEAN_TYPE > + && ARITHMETIC_TYPE_P (totype) > + && null_node_p (expr)) > { > location_t loc = get_location_for_expr_unwinding_for_system_header > (expr); > if (fn) > @@ -7059,7 +7060,9 @@ convert_like_real (conversion *convs, tr > return cp_convert (totype, expr, complain); > } > > - if (issue_conversion_warnings && (complain & tf_warning)) > + if (issue_conversion_warnings > + && (complain & tf_warning) > + && (warn_conversion_null || warn_zero_as_null_pointer_constant)) > conversion_null_warnings (totype, expr, fn, argnum); > > switch (convs->kind)
Yes, that looks good to me as well. Btw, I noticed the C++ FE calls build_qualified_type a _lot_, in 99% picking up an existing variant from the list and those list walks visit ~20 types _on average_! A simple LRU cache (just put the found variant first) manages to improve compile-time to be even better than GCC 8 (~1% improvement). It improves the number of types checked to ~2.5 (from those 20). Also -fsynax-only compile-time from 2.9s to 2.75s (consistently). Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 270387) +++ gcc/tree.c (working copy) @@ -6459,9 +6459,22 @@ get_qualified_type (tree type, int type_ /* Search the chain of variants to see if there is already one there just like the one we need to have. If so, use that existing one. We must preserve the TYPE_NAME, since there is code that depends on this. */ - for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) - if (check_qualified_type (t, type, type_quals)) - return t; + for (tree *t = &TYPE_MAIN_VARIANT (type); *t; t = &TYPE_NEXT_VARIANT (*t)) + { + if (check_qualified_type (*t, type, type_quals)) + { + tree mv = TYPE_MAIN_VARAINT (type); + tree x = *t; + if (x != mv) + { + /* LRU. */ + *t = TYPE_NEXT_VARIANT (*t); + TYPE_NEXT_VARIANT (x) = TYPE_NEXT_VARIANT (mv); + TYPE_NEXT_VARIANT (mv) = x; + } + return x; + } + } return NULL_TREE; } peeling the main-variant case above might make the code a little bit prettier. Richard. > > Jakub