From patchwork Tue Jun 8 07:17:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 54943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 89FF0B7D20 for ; Tue, 8 Jun 2010 17:17:19 +1000 (EST) Received: (qmail 7508 invoked by alias); 8 Jun 2010 07:17:17 -0000 Received: (qmail 7485 invoked by uid 22791); 8 Jun 2010 07:17:14 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Jun 2010 07:17:09 +0000 Received: from localhost (occam.ms.mff.cuni.cz [195.113.18.121]) by nikam.ms.mff.cuni.cz (Postfix) with ESMTP id 4F5D99AC7D5 for ; Tue, 8 Jun 2010 09:17:07 +0200 (CEST) Received: by localhost (Postfix, from userid 16202) id 4954B5641A7; Tue, 8 Jun 2010 09:17:07 +0200 (CEST) Date: Tue, 8 Jun 2010 09:17:07 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Disable bounds checking for edge iterators in release compiler Message-ID: <20100608071707.GB8913@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, oprofile shows as one of highest sample count the following sanity check: :/* Advance the iterator to the next element. */ :static inline void :ei_next (edge_iterator *i) :{ 6578 0.4915 : gcc_assert (i->index < EDGE_COUNT (ei_container (*i))); 201 0.0150 : i->index++; :} I guess it is mostly cache miss that would be later attributed elsewhere, but it also seems to me that this kind of bounds checking is something we want to omit in release compiler (same was as we disable VEC range checking and such). The probability that we will get useful error here is relatively low compared to amount of checks we spread across compiler by inlining the function. I tested the attached patch. It reduce size of stripped cc1 binary (with WHOPR build) from 11944192 to 11939616 bytes (4.5KB) and time needed to build cc1 binary from 10m29s to 10m19s. With non-WHOPR this should be more effective since we are worse on optimizing out unnecesary checks, but I didn't verified. Bootstrapped/regtested x86_64-linux. If this seems to make sense, I will look at the other inline functions sanity checks. I think in gimple.h we also have few quite good candidates for ENABLE_CHECKING. Honza * basic-block.h (single_succ_edge, single_pred_edge, ei_container, ei_next, ei_prev): Do sanity checking with ENABLE_CHECKING only. Index: basic-block.h =================================================================== --- basic-block.h (revision 160382) +++ basic-block.h (working copy) @@ -554,7 +554,9 @@ single_pred_p (const_basic_block bb) static inline edge single_succ_edge (const_basic_block bb) { +#ifdef ENABLE_CHECKING gcc_assert (single_succ_p (bb)); +#endif return EDGE_SUCC (bb, 0); } @@ -564,7 +566,9 @@ single_succ_edge (const_basic_block bb) static inline edge single_pred_edge (const_basic_block bb) { +#ifdef ENABLE_CHECKING gcc_assert (single_pred_p (bb)); +#endif return EDGE_PRED (bb, 0); } @@ -596,7 +600,9 @@ typedef struct { static inline VEC(edge,gc) * ei_container (edge_iterator i) { +#ifdef ENABLE_CHECKING gcc_assert (i.container); +#endif return *i.container; } @@ -647,7 +653,9 @@ ei_one_before_end_p (edge_iterator i) static inline void ei_next (edge_iterator *i) { +#ifdef ENABLE_CHECKING gcc_assert (i->index < EDGE_COUNT (ei_container (*i))); +#endif i->index++; } @@ -655,7 +663,9 @@ ei_next (edge_iterator *i) static inline void ei_prev (edge_iterator *i) { +#ifdef ENABLE_CHECKING gcc_assert (i->index > 0); +#endif i->index--; }