From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96820 invoked by alias); 16 Apr 2019 12:26:36 -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 96810 invoked by uid 89); 16 Apr 2019 12:26:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Apr 2019 12:26:34 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B65A6AD94; Tue, 16 Apr 2019 12:26:32 +0000 (UTC) Date: Tue, 16 Apr 2019 12:34:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek Subject: [PATCH][C++] Improve compile-time by ordering expensive checks last Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2019-04/txt/msg00634.txt.bz2 Two cases from a -fsynax-only tramp3d callgrind profile. Bootstrapped / tested on x86_64-unknown-linux-gnu. OK for trunk? Richard. 2019-04-16 Richard Biener cp/ * call.c (null_ptr_cst_p): Order checks according to expensiveness. (conversion_null_warnings): Likewise. Index: gcc/cp/call.c =================================================================== --- gcc/cp/call.c (revision 270387) +++ 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)) @@ -6882,8 +6882,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);