From patchwork Thu Dec 5 10:12:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1204557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515206-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OQA15BbF"; dkim-atps=neutral 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 47TBNL6P06z9sPL for ; Thu, 5 Dec 2019 21:12:17 +1100 (AEDT) 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=uCBHxGZXZdUAQXz5Ucx1NM1spl20yEuGzpf8Ec4nqYAH99SBzzUhv 8ujYWNVIydyVJLcyzgqtIuME2Jl55pKd/G/wLEXzjtL/f4h7QFcZRjFpcNyNhXW/ XqWICFsIgRSYwlPAFx5SHpCV/J+4frJzolsEx2vjJ8qiB67waHyvLI= 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=+X3YVe/+p+tQcIERm4UMBgaHJzM=; b=OQA15BbF/zYMb7bxTvVL EZwtCjJPNk8CWk4THzpW+IZIU4tTeShvI+6tfHFDxHd1XWzA7JrM9PNPtMX4OzMW AmVNCV2cDm8m/fgFAHzB7jE1KL83ZnUHwUdL0Qf9C5rqj06VXuJh7Dt8eapC9Qh6 cSiaaF/rb9FJtW80/bptS9w= Received: (qmail 62160 invoked by alias); 5 Dec 2019 10:12: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 62129 invoked by uid 89); 5 Dec 2019 10:12:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=UD:tree-ssa-threadupdate.c, sk:redirec 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; Thu, 05 Dec 2019 10:12:08 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 9BBB2280D63; Thu, 5 Dec 2019 11:12:04 +0100 (CET) Date: Thu, 5 Dec 2019 11:12:04 +0100 From: Jan Hubicka To: law@redhat.com, gcc-patches@gcc.gnu.org Subject: Fix profile updatin in tree-ssa-threadupdate Message-ID: <20191205101204.2obitkvozbxbtu4l@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch makes tree-ssa-threadupdate to not leave basic blocks with undefined counts in the program. create_block_for_threading sets counts as follows: /* Zero out the profile, since the block is unreachable for now. */ rd->dup_blocks[count]->count = profile_count::uninitialized (); which is usually set to correct count in update_profile. However template_blocks are not seen by it and thus this patch calculates the profile while redirecting edgs to it. Bootstrapped/regtested x86_64-linux and also checked that the profile is correct. Does it make sense? There is no testcase since I plan to commit sanity check that triggers several times during the testsuite and bootstrap w/o this patch. Honza * tree-ssa-threadupdate.c Index: tree-ssa-threadupdate.c =================================================================== --- tree-ssa-threadupdate.c (revision 278959) +++ tree-ssa-threadupdate.c (working copy) @@ -1286,6 +1286,10 @@ ssa_redirect_edges (struct redirection_d /* Redirect the incoming edge (possibly to the joiner block) to the appropriate duplicate block. */ e2 = redirect_edge_and_branch (e, rd->dup_blocks[0]); + if (single_pred_p (rd->dup_blocks[0])) + rd->dup_blocks[0]->count = e2->count (); + else + rd->dup_blocks[0]->count = rd->dup_blocks[0]->count + e2->count (); gcc_assert (e == e2); flush_pending_stmts (e2); }