From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78081 invoked by alias); 19 Apr 2019 00:59:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 78070 invoked by uid 89); 19 Apr 2019 00:59:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: mail-ot1-f49.google.com Received: from mail-ot1-f49.google.com (HELO mail-ot1-f49.google.com) (209.85.210.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 Apr 2019 00:59:05 +0000 Received: by mail-ot1-f49.google.com with SMTP id c16so3230418otn.4 for ; Thu, 18 Apr 2019 17:59:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jason Merrill Date: Fri, 19 Apr 2019 05:32:00 -0000 Message-ID: Subject: Re: [PATCH][C++] Improve compile-time by ordering expensive checks last To: Richard Biener Cc: gcc-patches List Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00787.txt.bz2 OK. On Wed, Apr 17, 2019 at 6:44 AM Richard Biener wrote: > > On Tue, 16 Apr 2019, Richard Biener wrote: > > > > > Two cases from a -fsynax-only tramp3d callgrind profile. > > Amended by two others. > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > OK? > > Thanks, > Richard. > > 2019-04-17 Richard Biener > > cp/ > * call.c (null_ptr_cst_p): Order checks according to expensiveness. > (conversion_null_warnings): Likewise. > * typeck.c (same_type_ignoring_top_level_qualifiers_p): Return > early if type1 == type2. > > Index: gcc/cp/call.c > =================================================================== > --- gcc/cp/call.c (revision 270407) > +++ gcc/cp/call.c (working copy) > @@ -541,11 +541,11 @@ null_ptr_cst_p (tree t) > STRIP_ANY_LOCATION_WRAPPER (t); > > /* Core issue 903 says only literal 0 is a null pointer constant. */ > - if (TREE_CODE (type) == INTEGER_TYPE > - && !char_type_p (type) > - && TREE_CODE (t) == INTEGER_CST > + if (TREE_CODE (t) == INTEGER_CST > + && !TREE_OVERFLOW (t) > + && TREE_CODE (type) == INTEGER_TYPE > && integer_zerop (t) > - && !TREE_OVERFLOW (t)) > + && !char_type_p (type)) > return true; > } > else if (CP_INTEGRAL_TYPE_P (type)) > @@ -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) > @@ -6882,8 +6883,8 @@ conversion_null_warnings (tree totype, t > } > /* Handle zero as null pointer warnings for cases other > than EQ_EXPR and NE_EXPR */ > - else if (null_ptr_cst_p (expr) && > - (TYPE_PTR_OR_PTRMEM_P (totype) || NULLPTR_TYPE_P (totype))) > + else if ((TYPE_PTR_OR_PTRMEM_P (totype) || NULLPTR_TYPE_P (totype)) > + && null_ptr_cst_p (expr)) > { > location_t loc = get_location_for_expr_unwinding_for_system_header (expr); > maybe_warn_zero_as_null_pointer_constant (expr, loc); > Index: gcc/cp/typeck.c > =================================================================== > --- gcc/cp/typeck.c (revision 270407) > +++ gcc/cp/typeck.c (working copy) > @@ -1508,6 +1508,8 @@ same_type_ignoring_top_level_qualifiers_ > { > if (type1 == error_mark_node || type2 == error_mark_node) > return false; > + if (type1 == type2) > + return true; > > type1 = cp_build_qualified_type (type1, TYPE_UNQUALIFIED); > type2 = cp_build_qualified_type (type2, TYPE_UNQUALIFIED);