From patchwork Sat Aug 31 21:46:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 271557 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B972C2C00C1 for ; Sun, 1 Sep 2013 07:46:26 +1000 (EST) 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:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=S0p0ctMCQff0EpEUL /JoqFZYXr5YNPJPEAZZcfZWMBsyXScDMGRBeT2PN0dXemPcXRJhHF8Qb1jGHHLNs kQ9vsS8Wj+q0r9Byl6ucaaSuOKzebJ+ikcdG83X8dIJe0rsPbZq9ntsTxtEVWeDd zDMblT6kMVLkmQDn2WiKkKcbTw= 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:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=KtQXrxdoVj5TLkL+v3Sq7lQ vP28=; b=CN2Z65xVnVs0y+Vqc2yhJ5bYmbzKhcL5jXbBXqlXwk07QpTmnld09mn yVILiQimnXb6+1pHXcP6GtnsMF+of9dOMwiXxD5hhpSjhyuEE4JV3I20pXHP5tLg afkjw3Md2tY6+A4PklhgXgpaCeXUOklWhS+hPFJ6IOCQ99Lq9BuI= Received: (qmail 8565 invoked by alias); 31 Aug 2013 21:46:20 -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 8556 invoked by uid 89); 31 Aug 2013 21:46:20 -0000 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 (AES256-SHA encrypted) ESMTPS; Sat, 31 Aug 2013 21:46:20 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, NO_RELAYS, T_FRT_BELOW2 autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 22789541DE1; Sat, 31 Aug 2013 23:46:15 +0200 (CEST) Date: Sat, 31 Aug 2013 23:46:15 +0200 From: Jan Hubicka To: Jan Hubicka Cc: Teresa Johnson , Bernhard Reutner-Fischer , "gcc-patches@gcc.gnu.org" , Steven Bosscher , Jeff Law , "marxin.liska" , Sriraman Tallam Subject: Re: [PATCH] Sanitize block partitioning under -freorder-blocks-and-partition Message-ID: <20130831214614.GA12372@kam.mff.cuni.cz> References: <20130809152804.GA6579@kam.mff.cuni.cz> <20130817204408.GA16557@kam.mff.cuni.cz> <20130819150942.GA28264@kam.mff.cuni.cz> <20130831160420.GC7492@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130831160420.GC7492@kam.mff.cuni.cz> User-Agent: Mutt/1.5.20 (2009-06-14) Hi, I run my script on execute testsuite and looked into few testcases. The problem I found was roundoff errors - i.e. when expanding switch we set 50% chage that out of bound value is above or bellow. Both gets rounded to 0, because switch is executed once and the value is bellow. Partly this can be fixed by making probably_never_executed to consider frequencies when counts are too coarse: In other cases it was mostly loop unrolling in combination with jump threading. So I modified my script to separately report when failure happens for test trained once and test trained hundred times. FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20000422-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20000910-2.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20020413-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20030903-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20031204-1.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20031204-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20060420-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20060905-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20120427-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20120427-2.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20120808-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20121108-1.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20121108-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/920501-6.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/920501-6.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/920726-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/981001-1.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/981001-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/990628-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/991216-2.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/991216-2.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/cmpdi-1.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/cmpdi-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/float-floor.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/float-floor.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr33870-1.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr33870-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr33870.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr33870.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr36093.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr37573.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr43784.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/pr43784.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/switch-1.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/switch-1.c FAIL1 /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/va-arg-22.c FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/va-arg-22.c FAIL1 is failure after one run, FIAL is failure after 100 train runs. We should take look at FAILs and see if there are bugs to fix. For FAIL1 I think it is kind of design problem: while implementing counts&frequencies the idea was that small counts do not matter, so integer arithmetic is all right. I wonder if with current C++ wonderland we can't simply switch count to a better representation. Either sreal or fixedpoint with capping (the integer overflow issues are tiring, too). Honza Index: predict.c =================================================================== --- predict.c (revision 202133) +++ predict.c (working copy) @@ -232,8 +232,22 @@ bool probably_never_executed_bb_p (struct function *fun, const_basic_block bb) { gcc_checking_assert (fun); - if (profile_info && flag_branch_probabilities) - return ((bb->count + profile_info->runs / 2) / profile_info->runs) == 0; + if (profile_status_for_function (fun) == PROFILE_READ) + { + if ((bb->count * 4 + profile_info->runs / 2) / profile_info->runs > 0) + return false; + if (!bb->frequency) + return true; + if (!ENTRY_BLOCK_PTR->frequency) + return false; + if (ENTRY_BLOCK_PTR->count && ENTRY_BLOCK_PTR->count < REG_BR_PROB_BASE) + { + return (RDIV (bb->frequency * ENTRY_BLOCK_PTR->count, + ENTRY_BLOCK_PTR->frequency) + < REG_BR_PROB_BASE / 4); + } + return true; + } if ((!profile_info || !flag_branch_probabilities) && (cgraph_get_node (fun->decl)->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))