From patchwork Fri Jun 16 17:46:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 776896 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wq78f4kDkz9s8N for ; Sat, 17 Jun 2017 03:46:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ySgp0ebB"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=M02gw0ECf+H5Ig2Xq2tINjWAe9mCcl2Z6VLo0/gADsQOwjHdy55O8 /cgeePT/ocfY3Zx35OpLQomMAk0/Lvqhek/S3iXmiWCWj4o77+vRG5l0qlPxVOjA BARnCHQ9nR1LuMhcCQB/6Cv/LwvnKqswo5r8lGcCjRaUtOW1YAJMLI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=WwoDdG1ISi1qrBKiBllkCS0ZWfo=; b=ySgp0ebBFtXv03pUFTWS 09mIw0USv4gGQ1cQIMw1WECnB09hTKi4KACJOkZ8jLHS1Lxxomhfst0HhoSEuY+s z6nSGZpU1jsnHKYvqwbDjaq0ONKcjriKayln4ppspwVQlNxz8CNj0WSh+k0rAN4Q 7Tx5PmmMjplHtjT5LxFZ0b8= Received: (qmail 27319 invoked by alias); 16 Jun 2017 17:46:10 -0000 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 Received: (qmail 27141 invoked by uid 89); 16 Jun 2017 17:46:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=adjusting X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Jun 2017 17:46:07 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 55F8F543B63; Fri, 16 Jun 2017 19:46:10 +0200 (CEST) Date: Fri, 16 Jun 2017 19:46:10 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Improve force_edge_cold Message-ID: <20170616174610.GD59896@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Hi, force_edge_cold can be more aggressive about propagating zero counts. Honza Bootstrapped/regtested x86_64-linux, will commit it later today. * predict.c (force_edge_cold): Handle declaring edges impossible more aggresively. Index: predict.c =================================================================== --- predict.c (revision 249244) +++ predict.c (working copy) @@ -3968,6 +3968,7 @@ force_edge_cold (edge e, bool impossible profile_count old_count = e->count; int old_probability = e->probability; int prob_scale = REG_BR_PROB_BASE; + bool uninitialized_exit = false; /* If edge is already improbably or cold, just return. */ if (e->probability <= (impossible ? PROB_VERY_UNLIKELY : 0) @@ -3978,6 +3979,8 @@ force_edge_cold (edge e, bool impossible { if (e2->count.initialized_p ()) count_sum += e2->count; + else + uninitialized_exit = true; prob_sum += e2->probability; } @@ -3989,7 +3992,7 @@ force_edge_cold (edge e, bool impossible = MIN (e->probability, impossible ? 0 : PROB_VERY_UNLIKELY); if (impossible) e->count = profile_count::zero (); - if (old_probability) + else if (old_probability) e->count = e->count.apply_scale (e->probability, old_probability); else e->count = e->count.apply_scale (1, REG_BR_PROB_BASE); @@ -4016,6 +4019,34 @@ force_edge_cold (edge e, bool impossible else { e->probability = REG_BR_PROB_BASE; + if (e->src->count == profile_count::zero ()) + return; + if (count_sum == profile_count::zero () && !uninitialized_exit + && impossible) + { + bool found = false; + for (gimple_stmt_iterator gsi = gsi_start_bb (e->src); + !gsi_end_p (gsi); gsi_next (&gsi)) + { + if (stmt_can_terminate_bb_p (gsi_stmt (gsi))) + { + found = true; + break; + } + } + if (!found) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, + "Making bb %i impossible and dropping count to 0.\n", + e->src->index); + e->count = profile_count::zero (); + e->src->count = profile_count::zero (); + FOR_EACH_EDGE (e2, ei, e->src->preds) + force_edge_cold (e2, impossible); + return; + } + } /* If we did not adjusting, the source basic block has no likely edeges leaving other direction. In that case force that bb cold, too.