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