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: 137476 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1512023vqo; Tue, 5 Sep 2023 00:17:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7ZxNJB5W1ZTiODvbXOcLEJonEvUT5KT0B5RbQbQhuSQG6zF0SijSGapbc2pcg221Jgepk X-Received: by 2002:aa7:d8cb:0:b0:523:2e23:a0bf with SMTP id k11-20020aa7d8cb000000b005232e23a0bfmr13359729eds.11.1693898257799; Tue, 05 Sep 2023 00:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693898257; cv=none; d=google.com; s=arc-20160816; b=KZiFtqSxGvqOCoyMQRWSwiHk43X9Gfh5VzNyqAuxPDZeiFmKhrjga5XpaES0SpBKtX 0WeoH7w4EW7OoOqjr3D6qwcoP7oXPtEeZz0qX03+HA8SvkDfIubuLQpnbR/DacKImUzc jy/9iqhtPlW2JZbXegnpZt5b7fpvIfU0YzIvtW39/nW+ElUsxWwGu+i1haL72Obkgije 2AIwtENNxVV49uOZHOEwQJlb1DJpayWb/pRPwo4xvXdOofP59GjytOXofMgYf38I0gd/ qTliDtcDL+1foBx8FSyGkZmDKHalFO4f7f6bxBb1aNsgi9T5hXnBftZHKDTzzSevuBBa MN1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:cc:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=CTDwOkg0Fopr9mSXvGa93tXJiABq1/g+6P7m07Vhpdk=; fh=KcpXRtrFRrFdiwpRGC3mmEPXwDGEHXAc9/iqyfMIYJI=; b=nmFWqw7dhzKYyPHtLtCypzH4Opc7/ocSKVRToqF8ECwHq0eKzHGEIpo6T7jZYNZxYu PZZaNlrHFMhfwuTlz53e6guoxi36EK9ewIz9hjoq1fXiYa/3O+qWo9flXkinLy5SOyjc KcN19R5PFa1s0vM/2RkP8Upww7lC2uiuy+fnJdEZskDfWVSxH21gKSK4z7kHm2w2oKsV 5MGAZSg0FbizKuHVv1gSkuM589QloV6UfgGBsGhw9AuLzzyqCsQBt+lE63v0DtufSsul 0wBbcfHFsDEcVKLdHTCQ1P2JbVPTJ/57zOTbKtbFgcDaFE2stJuUDpH7xN7/SIdl1ay+ Qpww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Vh3MBjEZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o14-20020aa7d3ce000000b0052322fbabf9si7383577edr.324.2023.09.05.00.17.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 00:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Vh3MBjEZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E2C0E3858032 for ; Tue, 5 Sep 2023 07:17:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2C0E3858032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693898255; 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=Vh3MBjEZ5FpddaFg4bEOtG8GbVCZ/BuCqgluKoh4RA5SKeeGCPw+fCQbx2V68Fz4B qwx03sg2c1u0LsuGfPEnpvdoFckP8Y/FKwk4b4gSntsiwNumUiPgxrf/tIU3fcvzul EkWI9kmjkOeU7KU6xsuXQCDAVrAEE2wmxBaNa5sQ= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776181059266270414 X-GMAIL-MSGID: 1776181059266270414 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;