From patchwork Fri May 16 17:24:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 349699 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 D4A5E140079 for ; Sat, 17 May 2014 03:25:03 +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 :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=b337rNla7N3wxcRb+P3UqmywCxVWtiYDDDciEAeMLx6 +yMEXrDTVd8F1t6SQJ53+YZR+AH9tgwF+WiBSRyJ1r5RYRj2glHu/g/ZZ5eqtk94 222OI8duyT9FY502sk/d7lP3tniJy8qP5rjUaN8GJltzmwgnv7rR16ZSx4B2BaJM = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=FD79kuWPCSTvGr6kIPl6MhfDJfs=; b=SnqzhUn+CW5LEKmNz 32vMOMVPkxvgePzqIvcziMHG2HnkBMBGUf9zLUXUufa2lw3wRTeHia5RvKfmGZx+ L0vaZFSXEW1vZigEcHSp/Tkse2o0IpIltC2fEAsutInXWpRuxsQ2MHqc1Vsp1hBO Wgc1+Yefjg2h6lNxPximSvLHh0= Received: (qmail 6895 invoked by alias); 16 May 2014 17:24:48 -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 6754 invoked by uid 89); 16 May 2014 17:24:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f175.google.com Received: from mail-ig0-f175.google.com (HELO mail-ig0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 16 May 2014 17:24:45 +0000 Received: by mail-ig0-f175.google.com with SMTP id uq10so1065259igb.2 for ; Fri, 16 May 2014 10:24:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=0tTJPJ0LcPWPvabSLN1w6DwVd8AeG97DIjJcUBk5rjU=; b=gDJpjsOnPXe+i8Tu9yNIC4LUoHR2z4Ca02qmURhyZv5mYF0sNaRouxJ4qWIT+P6zij ZXHvIUWml7Z3OGNVAYZaylnniSka5Wh5u2MWA8NaqFuT6FAuyXhCRPH3i7y19bE9Vv5e CLSdPxtfJ79dIG8OXvq31OBRP0stbaLLbct7DR+aNCXWcEDyIMf509ngoLJG2fddc4Jr OHKEPD8GkOo5e5XBbzwioppobOlZdfVEJbbWX7h0D2VtfSP+C7FT46AW2W7nPyjUS5AN p9itC5Wg0BfFsvZNMGVbJfg7k3yMTtxi75E5JTzEDX1FzHPq7uzEIGalHVACTyVuYuuy DZ+w== X-Gm-Message-State: ALoCoQnJhDDOdWRsxoVdLoaXSsOpzBxSIRon0tkgxEU21hj2msMiILaqiLN1MrwnOGvJeJQDvKXE MIME-Version: 1.0 X-Received: by 10.50.143.107 with SMTP id sd11mr82818059igb.39.1400261083678; Fri, 16 May 2014 10:24:43 -0700 (PDT) Received: by 10.64.18.180 with HTTP; Fri, 16 May 2014 10:24:43 -0700 (PDT) Date: Fri, 16 May 2014 10:24:43 -0700 Message-ID: Subject: [PATCH] Use direct computation to calculate fallthrough edge count. From: Dehao Chen To: GCC Patches Cc: Jan Hubicka , David Li X-IsSubscribed: yes This patch uses direct computation (instead of indirect minus computation) to calculate fallthrough edge's count and frequency. This is less error-prone when the profile is inconsistent (e.g. all succ edge counts sums larger than bb count). Bootstrapped and regression test on-going. OK for trunk if test pass? Thanks, Dehao gcc/ChangeLog: 2014-05-16 Dehao Chen * cfghooks.c (make_forwarder_block): Use direct computation to get fall-through edge's count and frequency. Index: gcc/cfghooks.c =================================================================== --- gcc/cfghooks.c (revision 210518) +++ gcc/cfghooks.c (working copy) @@ -833,6 +833,9 @@ make_forwarder_block (basic_block bb, bool (*redir fallthru = split_block_after_labels (bb); dummy = fallthru->src; + dummy->count = 0; + dummy->frequency = 0; + fallthru->count = 0; bb = fallthru->dest; /* Redirect back edges we want to keep. */ @@ -842,20 +845,13 @@ make_forwarder_block (basic_block bb, bool (*redir if (redirect_edge_p (e)) { + dummy->frequency += EDGE_FREQUENCY (e); + dummy->count += e->count; + fallthru->count += e->count; ei_next (&ei); continue; } - dummy->frequency -= EDGE_FREQUENCY (e); - dummy->count -= e->count; - if (dummy->frequency < 0) - dummy->frequency = 0; - if (dummy->count < 0) - dummy->count = 0; - fallthru->count -= e->count; - if (fallthru->count < 0) - fallthru->count = 0; - e_src = e->src; jump = redirect_edge_and_branch_force (e, bb); if (jump != NULL)