[{"id":1761630,"web_url":"http://patchwork.ozlabs.org/comment/1761630/","msgid":"<20170901120441.GC9735@kam.mff.cuni.cz>","list_archive_url":null,"date":"2017-09-01T12:04:41","subject":"Re: [PATCH] Fix profile update in tree-ssa-isolate-paths.c (PR\n\ttree-optimization/82059).","submitter":{"id":4327,"url":"http://patchwork.ozlabs.org/api/people/4327/","name":"Jan Hubicka","email":"hubicka@ucw.cz"},"content":"> Hello.\n> \n> In order to have valid profile, we should add counts of an edge only when\n> it's really redirected and hasn't been redirected in previous invocation of the function.\n> \n> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.\n> \n> Ready to be installed?\n> Martin\n> \n> gcc/ChangeLog:\n> \n> 2017-08-31  Martin Liska  <mliska@suse.cz>\n> \n> \tPR tree-optimization/82059\n> \t* gimple-ssa-isolate-paths.c (isolate_path): Add profile and\n> \tfrequency only when an edge is redirected.\n\nOK, thanks!\nHonza\n> \n> gcc/testsuite/ChangeLog:\n> \n> 2017-08-31  Martin Liska  <mliska@suse.cz>\n> \n> \tPR tree-optimization/82059\n> \t* gcc.dg/tree-ssa/pr82059.c: New test.\n> ---\n>  gcc/gimple-ssa-isolate-paths.c          |  9 ++++++---\n>  gcc/testsuite/gcc.dg/tree-ssa/pr82059.c | 22 ++++++++++++++++++++++\n>  2 files changed, 28 insertions(+), 3 deletions(-)\n>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr82059.c\n> \n> \n\n> diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c\n> index fbc41057463..807e0032410 100644\n> --- a/gcc/gimple-ssa-isolate-paths.c\n> +++ b/gcc/gimple-ssa-isolate-paths.c\n> @@ -160,14 +160,17 @@ isolate_path (basic_block bb, basic_block duplicate,\n>  \tfor (ei = ei_start (duplicate->succs); (e2 = ei_safe_edge (ei)); )\n>  \t  remove_edge (e2);\n>      }\n> -  bb->frequency += EDGE_FREQUENCY (e);\n> -  bb->count += e->count;\n>  \n>    /* Complete the isolation step by redirecting E to reach DUPLICATE.  */\n>    e2 = redirect_edge_and_branch (e, duplicate);\n>    if (e2)\n> -    flush_pending_stmts (e2);\n> +    {\n> +      flush_pending_stmts (e2);\n>  \n> +      /* Update profile only when redirection is really processed.  */\n> +      bb->frequency += EDGE_FREQUENCY (e);\n> +      bb->count += e->count;\n> +    }\n>  \n>    /* There may be more than one statement in DUPLICATE which exhibits\n>       undefined behavior.  Ultimately we want the first such statement in\n> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82059.c b/gcc/testsuite/gcc.dg/tree-ssa/pr82059.c\n> new file mode 100644\n> index 00000000000..0285b03cc04\n> --- /dev/null\n> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr82059.c\n> @@ -0,0 +1,22 @@\n> +/* PR tree-optimization/82059 */\n> +/* { dg-do compile } */\n> +/* { dg-options \"-O2 -fdump-tree-isolate-paths\" } */\n> +\n> +struct a\n> +{\n> +  char b;\n> +  struct a *c;\n> +} d (), f;\n> +void *e;\n> +long g;\n> +void\n> +h ()\n> +{\n> +  struct a *i = 0;\n> +  if (g)\n> +    i = e;\n> +  if (!i)\n> +    d ();\n> +  i->c = &f;\n> +  i->b = *(char *) h;\n> +}\n>","headers":{"Return-Path":"<gcc-patches-return-461273-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461273-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"bOIY66UH\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkHx41qfYz9sRV\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 22:04:55 +1000 (AEST)","(qmail 56450 invoked by alias); 1 Sep 2017 12:04:48 -0000","(qmail 56399 invoked by uid 89); 1 Sep 2017 12:04:47 -0000","from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz)\n\t(195.113.20.16) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tFri, 01 Sep 2017 12:04:45 +0000","by nikam.ms.mff.cuni.cz (Postfix, from userid 16202)\tid\n\t183C05491E1; Fri,  1 Sep 2017 14:04:41 +0200 (CEST)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=S0x5Ga4+wSsk81oVg\n\tuatgsZsfB/iRGp6i4Z8MmWCGh2MF20RzMod2ugMlWrmmkJNeWCi5zaE72FoN61th\n\tlGHL4I+kyBGi88VpZqgtjdNRvtrOIvP60neqTf9WBqpAQPRD3EjtpGCWrMMRvst5\n\tB3tRo/vPyxvFhEUVTPGBYKmDpw=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=ull6pB7G1FcfAZRvsXuKYjA\n\tMHFo=; b=bOIY66UHsh4woMSN8Z8OHgnmSRPMiY3VydD6toos6/gU0YzhQ9qaGe/\n\t8OjOP40LeJdTraUPLquxT9Cdd4RNFT/JRzPEVnxbba0T+s7K1ZQNlrdp+XmoL1hx\n\tHbcE5l7Y7vf2q6Vq+4hrlJmemi3q7SKX68rBiiKphDTGPgmM2amY=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-23.8 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY,\n\tRP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=","X-HELO":"nikam.ms.mff.cuni.cz","Date":"Fri, 1 Sep 2017 14:04:41 +0200","From":"Jan Hubicka <hubicka@ucw.cz>","To":"Martin =?iso-8859-2?q?Li=B9ka?= <mliska@suse.cz>","Cc":"gcc-patches@gcc.gnu.org","Subject":"Re: [PATCH] Fix profile update in tree-ssa-isolate-paths.c (PR\n\ttree-optimization/82059).","Message-ID":"<20170901120441.GC9735@kam.mff.cuni.cz>","References":"<1a8274d7-4967-a055-90eb-c4d6ba969640@suse.cz>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<1a8274d7-4967-a055-90eb-c4d6ba969640@suse.cz>","User-Agent":"Mutt/1.5.23 (2014-03-12)"}}]