From patchwork Tue Sep 5 07:16:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 75252 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C160B3858005 for ; Tue, 5 Sep 2023 07:17:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C160B3858005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693898241; bh=CTDwOkg0Fopr9mSXvGa93tXJiABq1/g+6P7m07Vhpdk=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dABZvup522IS5NeDvBAp3ApgMyMTM528K0cNw0iHzJFP4Xmi4rsh0op+qQzpMjBOd okl1Zwq3lkKrUp0BNEFbWpyKzPBn83ZucgH7c7PFjOApJ/dq6wtvR+CwTYiuDQA0Lg Dfcv382B4ti/qnrYW9zF7vRW2oHGprtBxHkBL6O4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CBD40385843A for ; Tue, 5 Sep 2023 07:16:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBD40385843A Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-201-bBOB_dhjMUu9gEFrLlY2MA-1; Tue, 05 Sep 2023 03:16:50 -0400 X-MC-Unique: bBOB_dhjMUu9gEFrLlY2MA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8B9C8015AA; Tue, 5 Sep 2023 07:16:49 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CF37493110; Tue, 5 Sep 2023 07:16:49 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3857GlrA2876942 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 5 Sep 2023 09:16:48 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3857GlsF2876941; Tue, 5 Sep 2023 09:16:47 +0200 Date: Tue, 5 Sep 2023 09:16:47 +0200 To: Jan Hubicka Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 16/12] _BitInt profile fixes [PR102989] Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On Thu, Aug 24, 2023 at 03:14:32PM +0200, Jan Hubicka via Gcc-patches wrote: > this patch extends verifier to check that all probabilities and counts are > initialized if profile is supposed to be present. This is a bit complicated > by the posibility that we inline !flag_guess_branch_probability function > into function with profile defined and in this case we need to stop > verification. For this reason I added flag to cfg structure tracking this. This patch broke a couple of _BitInt tests (in the admittedly still uncommitted series - still waiting for review of the C FE bits). Here is a minimal patch to make it work again, though I'm not sure if in the if_then_else and if_then_if_then_else cases I shouldn't scale count of the other bbs as well. if_then method creates if (COND) new_bb1; in a middle of some pre-existing bb (with PROB that COND is true), if_then_else if (COND) new_bb1; else new_bb2; and if_then_if_then_else if (COND1) { if (COND2) new_bb2; else new_bb1; } with PROB1 and PROB2 probabilities that COND1 and COND2 are true. The lowering happens shortly after IPA. Ok for trunk with rest of the series? 2023-09-05 Jakub Jelinek PR c/102989 * gimple-lower-bitint.cc (bitint_large_huge::if_then_else, bitint_large_huge::if_then_if_then_else): Use make_single_succ_edge rather than make_edge, initialize bb->count. Jakub --- gcc/gimple-lower-bitint.cc.jj 2023-09-04 09:45:37.357004452 +0200 +++ gcc/gimple-lower-bitint.cc 2023-09-04 22:53:30.343756938 +0200 @@ -683,9 +683,10 @@ bitint_large_huge::if_then_else (gimple e1->flags = EDGE_FALSE_VALUE; e3->probability = prob; e1->probability = prob.invert (); + bb->count = e1->src->count.apply_probability (prob); set_immediate_dominator (CDI_DOMINATORS, bb, e1->src); set_immediate_dominator (CDI_DOMINATORS, e2->dest, e1->src); - edge_true = make_edge (bb, e2->dest, EDGE_FALLTHRU); + edge_true = make_single_succ_edge (bb, e2->dest, EDGE_FALLTHRU); edge_false = e2; m_gsi = gsi_after_labels (bb); } @@ -741,7 +742,8 @@ bitint_large_huge::if_then_if_then_else e4->probability = prob2; e2->flags = EDGE_FALSE_VALUE; e2->probability = prob2.invert (); - e4 = make_edge (bb, e3->dest, EDGE_FALLTHRU); + bb->count = e2->src->count.apply_probability (prob2); + e4 = make_single_succ_edge (bb, e3->dest, EDGE_FALLTHRU); e2 = find_edge (e2->dest, e3->dest); edge_true_true = e4; edge_true_false = e2;