From patchwork Thu Dec 8 12:55:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 87255 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp828389qgi; Thu, 8 Dec 2016 04:56:07 -0800 (PST) X-Received: by 10.99.166.2 with SMTP id t2mr131353784pge.40.1481201767231; Thu, 08 Dec 2016 04:56:07 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g12si28743676pla.142.2016.12.08.04.56.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Dec 2016 04:56:07 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443779-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443779-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443779-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Fqm7l6c4nK4W3037g9FL8tqY+5ZXmkJLOEXH+eDeFN+dIrUBTk PH5n68Ol8DUVTF7WMYt4N+v4ixLvTRMe2xwzyp/lgc0C0B8l+uMTYoJr3umuel/w tA2ATptj/8dcLFuf4muwXnjv4LDdZ/obVOpC7QxL9TL2PhzOXYj5PDWqM= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=f+fepIwwcYEbJ8eZ+ag4WqeSu1w=; b=oZF0NqCTI98MdrWO2vto SZTlwDA6fnMAh9zNMW9r/r4A8QlY4dnzhF+6G7UWwX4uXCs+XdZbzyJz8m1uUWwU KBuQsuKj1OtkBjEHsuoT1LsPholBtIY8a50fDNlxn6eNA8PkYq6eIntsvtNrQmYM URKAVsbs8wsTsyfGCK/zxSc= Received: (qmail 83228 invoked by alias); 8 Dec 2016 12:55:52 -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 83212 invoked by uid 89); 8 Dec 2016 12:55:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=004, 7217, 94, spc X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Dec 2016 12:55:41 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E43BEAABE; Thu, 8 Dec 2016 12:55:38 +0000 (UTC) To: GCC Patches Cc: Martin Sebor From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Print 2 digits after decimal delimiter for BB frequencies Message-ID: Date: Thu, 8 Dec 2016 13:55:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes With the patch applied, one can distinguish between PROB_VERY_UNLIKELY and real zero probability: f () { int _1; [100.00%]: _1 = __builtin_sprintf (&d2, "%i", 12); if (_1 != 2) goto ; [0.04%] else goto ; [99.96%] [0.04%]: __builtin_abort (); [99.96%]: return; } Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin >From 18f0fa35f91db675f5abf6a0aa8cf3582e79c772 Mon Sep 17 00:00:00 2001 From: marxin Date: Thu, 1 Dec 2016 10:55:55 +0100 Subject: [PATCH] Print 2 digits after decimal delimiter for BB frequencies gcc/ChangeLog: 2016-12-01 Martin Liska * gimple-pretty-print.c (dump_edge_probability): Use newly defined PROBABILITY_FORMAT. (dump_gimple_label): Likewise. (dump_gimple_bb_header): Likewise. gcc/testsuite/ChangeLog: 2016-12-02 Martin Liska * gcc.dg/tree-ssa/20040703-1.c: Update scanned pattern. * gcc.dg/tree-ssa/dump-2.c: Likewise. --- gcc/gimple-pretty-print.c | 12 +++++++++--- gcc/testsuite/gcc.dg/tree-ssa/20040703-1.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/dump-2.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index b5e866d..de57e89 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -72,12 +72,17 @@ debug_gimple_stmt (gimple *gs) print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS); } +/* Print format used for displaying probability of an edge or frequency + of a basic block. */ + +#define PROBABILITY_FORMAT "[%.2f%%]" + /* Dump E probability to BUFFER. */ static void dump_edge_probability (pretty_printer *buffer, edge e) { - pp_scalar (buffer, " [%.1f%%]", + pp_scalar (buffer, " " PROBABILITY_FORMAT, e->probability * 100.0 / REG_BR_PROB_BASE); } @@ -1023,7 +1028,7 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags) dump_generic_node (buffer, label, spc, flags, false); basic_block bb = gimple_bb (gs); if (bb && !(flags & TDF_GIMPLE)) - pp_scalar (buffer, " [%.1f%%]", + pp_scalar (buffer, " " PROBABILITY_FORMAT, bb->frequency * 100.0 / REG_BR_PROB_BASE); pp_colon (buffer); } @@ -2590,7 +2595,8 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) if (flags & TDF_GIMPLE) fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index); else - fprintf (outf, "%*s [%.1f%%]:\n", indent, "", bb->index, + fprintf (outf, "%*s " PROBABILITY_FORMAT ":\n", + indent, "", bb->index, bb->frequency * 100.0 / REG_BR_PROB_BASE); } } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040703-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20040703-1.c index 2980047..eb9fb56 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/20040703-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/20040703-1.c @@ -9,4 +9,4 @@ float foo(float x) } /* We should *not* fold the arithmetic. */ -/* { dg-final { scan-tree-dump-times "0\\.0\[^%\]" 0 "dom2"} } */ +/* { dg-final { scan-tree-dump-times "0\\.0\[^%0\]" 0 "dom2"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c b/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c index 11cde92..8a63af4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c @@ -6,4 +6,4 @@ int f(void) return 0; } -/* { dg-final { scan-tree-dump " \\\[100\\\.0%\\\]:" "optimized" } } */ +/* { dg-final { scan-tree-dump " \\\[100\\\.00%\\\]:" "optimized" } } */ -- 2.10.2