From patchwork Wed Feb 10 14:32:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1438985 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=PNOB22KY; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DbMjG2tc4z9sWr for ; Thu, 11 Feb 2021 01:34:40 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 141D1385040D; Wed, 10 Feb 2021 14:34:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 141D1385040D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1612967678; bh=REMv1+y4E40T3wmX89G1izd69zEUYdJYWOdYbKZXcGo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=PNOB22KYY+ZEvYwweTtNeZcI4Z/va3gDXsmZjKyp8cRT42yIPn+fHcKyfCdV7Z4rw /opMKSWRY58FmOaaj0aXasKmVdYZ9p5XXoOCCMzW1vW2UyaGKlQWFUN3EPHzHcIebu WKg+88gZBsxUb7dQb43jXoYKGB48Tm7tI0pgTHqI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70041.outbound.protection.outlook.com [40.107.7.41]) by sourceware.org (Postfix) with ESMTPS id 09D2338618BB for ; Wed, 10 Feb 2021 14:34:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 09D2338618BB Received: from AM6P193CA0142.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::47) by VI1PR08MB4192.eurprd08.prod.outlook.com (2603:10a6:803:e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.28; Wed, 10 Feb 2021 14:34:31 +0000 Received: from VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::3e) by AM6P193CA0142.outlook.office365.com (2603:10a6:209:85::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Wed, 10 Feb 2021 14:34:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT032.mail.protection.outlook.com (10.152.18.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 14:34:30 +0000 Received: ("Tessian outbound 28c96a6c9d2e:v71"); Wed, 10 Feb 2021 14:34:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d6d79a1e5d753b52 X-CR-MTA-TID: 64aa7808 Received: from 6694c58840e0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5F4DC3A1-A125-4B91-9428-A0DB32F43CA0.1; Wed, 10 Feb 2021 14:32:27 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6694c58840e0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 10 Feb 2021 14:32:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cijc84ETPJFxUKgUSKRN31ivNR+1HXOxppY5i/NU81WxSR58KThSLIEwKJqdNFQ5cKQB/LjGFsulO1t5yXDfWegqz/9SjrN0WLDvQ5ja/5FgQebPEhfJ9kF8e4yyMOBjpNh0elBbc1qWrhd38jipoij8SvlGwjslgfMYzKUGVIENZ2SKRj0bhdAxezRLvqRfiAkAEU+1pdUHA9D2EYecrPEZemB/l/n0QBBrNSSaPUs6x3sfVtblE0ffx4RThB0dvpeBacPLQfOu5K2hpT1oChBoSY2zo5O6maVdsbyMgx+AbOYJI2nonqFSFO5Islp4FdHsXYzbGWH5XnKE1NxG5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=REMv1+y4E40T3wmX89G1izd69zEUYdJYWOdYbKZXcGo=; b=ZUFsbhrY4GDMQWraofL8a28YxTxN47YunLxNCXqHaLlTNaKakm7eQKvNPUCbAdQwNYvKUF2oSYXXWmgjZwZXzlENuYUKVMA/FuSWmQSyl2LpI8tZXldz8rHyTr4/uEpD4gK/S4pVv7AiGymLKM505UG7b46q/cBL8MC/BX3zw69moXtBm73gjiHAi0AmV/OzG6mcekF/cA7d2aNEPMeMMNRLNgCoeQc8XF0LSjCAkcMyaHjwG0towcYtjEhBO8id49mOAO3KmWQd6qObZh4WxCs7FgJapkwA0IKUawfu26xZSPslDeEbaGuh9t29o1WY1r9VozbF2JaqR8PgPrNiQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by VE1PR08MB5565.eurprd08.prod.outlook.com (2603:10a6:800:1b2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.29; Wed, 10 Feb 2021 14:32:26 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::ed1e:9499:4501:2118]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::ed1e:9499:4501:2118%9]) with mapi id 15.20.3825.030; Wed, 10 Feb 2021 14:32:26 +0000 Date: Wed, 10 Feb 2021 14:32:23 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH][GCC] IPA: Optionally allow double costing, restoring GCC 10 behavior Message-ID: Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [217.140.106.53] X-ClientProxiedBy: LO4P123CA0048.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:152::17) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.53) by LO4P123CA0048.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:152::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Wed, 10 Feb 2021 14:32:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b3b17905-f016-4290-10f6-08d8cdd0fa44 X-MS-TrafficTypeDiagnostic: VE1PR08MB5565:|VI1PR08MB4192: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 28E8S9Qytxb6q+fPlNGcMrxkO0E+4GEZgYY3XKn9l426t63Vhm92zhaGTzBlO3uh64tcUEvCQCa6AOrx2lg+Nm2srrKXZfBx+P6cfiYqfg+vFdUauT77oGXcuFnubr+QO8Ug0xIaSduDlqNzzw76oLFGVeOpnzTaFuUk5Gf4bnsKuJlL4v4RVB84lRAg+i81bC5m/yk795Or3kT17wUGpYB+6jTKF6JuVWM0mFlff4/WQOv30joDoRXKNoRFvAAHHI/V5R70CjbduFlWq9EHQfZHfzJ3TsfOTwRb7aX6yA2yRCnmELg2Si3+8LE+iAjZ0fL+pYhQdagrGmBPy3EJ/Jn3GuLPOl5MiyPt0npJ1yJL7beydAmE5rdF7nd8Q4ff3Kslr25fBHqRawWnAlHcdAHafNWWDXVXmw8noYf0bVqwDMNcBQYFCQ08zsIDU0hOSFwOnqs+zIdiJET8cXgvDUu9ZqXOgsKL5fOxTIAhyN9siGuHmbaNxlPGTsH3mQFXrZnFamOBOy1ozwiCwl9wvodno5IlO0DMP7q0aI+DLe3Lb+KyrsdaGMSTva/x287p+MT56Fuzzk8PTIlihfnQew== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB5325.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(366004)(136003)(39850400004)(396003)(4743002)(4326008)(8676002)(2906002)(44832011)(66556008)(66476007)(66616009)(2616005)(956004)(44144004)(235185007)(33964004)(52116002)(478600001)(7696005)(5660300002)(26005)(86362001)(8936002)(8886007)(6916009)(66946007)(316002)(55016002)(186003)(16526019)(36756003)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?d6PgXdH47qtMow37egzKkDyEviwi/C?= =?utf-8?q?0HTkRJgs1gNze63cxPss1KxfLK5HNTSTg7Q+eVzPS/bKKOpCknH/cHSaFj/fFeye6?= =?utf-8?q?pAD78C+CaQGFbi8LPQ4mvpVNajJbfQwvDbl6XO+SrichlbuIoxMjBqWgvvQL+x+PY?= =?utf-8?q?aDeb5vPaPr1fZVFMk1tJYIFkAByw0+6ILJMvo6QpM+INAdM5/AjduNA5rGiriu/9D?= =?utf-8?q?O04r7OQrMtWlXGAmDFcDrOfL4HH0E2OsD/yo5BDMxpwJMt1rfLfkValYSIuEUvC97?= =?utf-8?q?smAfJcFfeqRWQUnoNYb3X7XZrQfUMwHzyu9f0oVp7lHeKtjmFOsijYPneioNfGQYX?= =?utf-8?q?lQcWQDLQ/Y08+OStEt5kRybETSXCt4M8vF3HXmNraO2fcjMN57IUV0rAAnJV+qplK?= =?utf-8?q?37xstjoQlKC3myv0Yr80+oH02ql1Mz8KpK9EVLNanOUsCdnBA8gZf6a47K6cdtjlf?= =?utf-8?q?vdjrrowAHV9G9fb7R0m8YiNqBph5BDDUfGakzJ4k6wd9ge852z8q995UWgbGrwZ9a?= =?utf-8?q?/4vMOilylxhtyHvC33OtkFFBiELIk/FCvb3S/2VRFkzhsaKqlfAWOCLAXwOM4vDe0?= =?utf-8?q?0xkUSwZ9M1uDU+E6AUFZwF/RzNwfNP+lET8Q/77Viq/HtkyPU/+kOk32Q+Cjnb0QW?= =?utf-8?q?FUS9e6clVWgHNENyx5W+5nJJngWyj2kVQQIGeUNfSoXS2Z+w5yF0UuM6NLKMWJ2kQ?= =?utf-8?q?kTtaFLCeBgogRKQWneG48pSZ3f5eMdRJSt5GidJTDEgfPmoFrvxl1HEqCVANCVTIv?= =?utf-8?q?UNWem5FgD2q7tICtLSUAZORfng4ToYsdNSr37u3rt7W5zHv5RK6v8mqyKvDG5UTDs?= =?utf-8?q?bm8WIvlAt0pd+qfJQfkko2XvsKmFT0JKGYAmxutPp+nLe/SfzujHxEIkB+FzR2xI/?= =?utf-8?q?bupMXUCr0dZjXrXVKpuzUAeNGVBzyf4ycfJvLEj/y6zPWp8Xr5uARuISmdzoZpoFT?= =?utf-8?q?ePHwq7RfbaR/k2jI97y0FiU9I217Y1nk4UtEEhv8SEYwn5VJ3ud/trdQSZ+qb8sRm?= =?utf-8?q?BVJo6djI++ZHRQSruQUvRjiXVF+nAPvuA9AY8xtMV4yag9J+1xdbURQA/OkdSWSCx?= =?utf-8?q?WpMjFzifQKb8UNtj7AvHkGomulLVadKfOWJNtmRAtg1EREZt8qpzkGhKDjGQtVGil?= =?utf-8?q?V9PWxTHsYZMXB62Jl9m3Y+CdmnLcllKxR8Foucav+hTNXQhgNPv5207OpV20TV8iD?= =?utf-8?q?4LKub5MWxycOhHCZq9Jh/ERT6FaS8FnWWGui1/V7xir4zOMf1PDzeuJ7TsRvFMR4i?= =?utf-8?q?lmY0Mxw95BtM73?= X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5565 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 46342810-95e2-496b-f379-08d8cdd0afd6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E524Ze/dAu8XL50iAkZcMMrU5qj+vqux1vNGfcnEtFaC7zPAJndvATRG90H5EPX+UmoT6mui1jDj1aPbAhNUY+jCOuQvnfj2Vmaa7qLittkDwaIuteyTzNGjwOE05REE4y12bYEG+qZfvqIli9O0E5pr4HVthajFCPTSXoy7YRWxdmsOPxW0ymt61/LomBVHro31Y9s6PxpB+7kTiZKiEgmOAtn7F3RTtfnfM01iOGZ40ait+64rJ8PWLvb4EXXr2gXGknRfLxJ0CwKVmFtgQxw2yXkShsYX+V+IZMR/OR3IFTfD8RBR+G5lkEdoRT60lQnapl//zmlydGIKSQ+Ca9xQFrBrJ1eV3UMXGN1swpQoRLv1kEN94/rRN0tecX1frAzyL2AnuZZtXjimMct4/ZsT/Z5/lMSQjGW6kuOTCg7PrlYUderKPWpSjNITx9RgMMffqyoIf2zQ0fGPFs/KjwLSBqckx2xtfU/iQKeg86iq0zhEBd7uwl8QSmwtXkrx1q5nkUzBv1lawP9ZoWvEGV+FaZBduC0fcQhdIeYfh29OBLvUkc5m/Po+3kHBdCkdVer/pE4zjlGvBwYkW6JmVwLLTfH085qI3Z32O08OyqmvTL2aOxthIzO+4lqkc8xYEWFCISQLBZ8iKxl2Rv1f1w8yRfMphisqIFCts1k6FrNc9aovYThXYQ4nWLYkcZKqCpGQgN9zPk8Xf45Y/dhr5g== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(136003)(376002)(39850400004)(396003)(346002)(46966006)(36840700001)(82740400003)(7696005)(956004)(316002)(2616005)(44144004)(86362001)(26005)(82310400003)(186003)(6916009)(33964004)(356005)(70586007)(16526019)(107886003)(478600001)(36756003)(8676002)(47076005)(55016002)(70206006)(5660300002)(81166007)(336012)(36860700001)(235185007)(4326008)(44832011)(8936002)(2906002)(66616009)(4743002)(8886007)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 14:34:30.6932 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3b17905-f016-4290-10f6-08d8cdd0fa44 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4192 X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina Cc: nd@arm.com, hubicka@ucw.cz Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi Honza and Martin, As explained in PR98782 the problem is that the behavior of IRA is quite tightly bound to the frequencies that IPA puts out. With the change introduced in g:1118a3ff9d3ad6a64bba25dc01e7703325e23d92 some, but not all edge predictions changed. This introduces a local problem which is impossible to fix using global flags or using any hooks to IRA. I propose this new parameter ipa-cp-allow-multi-edge-costing as a temporary stop gap as something that is safe for stage4. This allows us to opt in to allow the double edge costing, and buys us some time to properly look at RA in GCC 12 to see if there's a proper solution for this problem. Using --param ipa-cp-allow-multi-edge-costing=1 allows us to regain all the loses compared to GCC 10, but also thanks to Martin's patches we get a tiny extra gain as well. Would this be an acceptable stop-gap measure for the both of you? Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR rtl-optimization/98782 * params.opt (ipa-cp-allow-multi-edge-costing): New. * predict.c (maybe_predict_edge): Use it. --- inline copy of patch -- diff --git a/gcc/params.opt b/gcc/params.opt index dff8a331f82e44c1b90e5b9f88ffc61e84f03d2d..f54eba2836f5d3a9b66489e3766f3d45eeaf5952 100644 diff --git a/gcc/params.opt b/gcc/params.opt index dff8a331f82e44c1b90e5b9f88ffc61e84f03d2d..f54eba2836f5d3a9b66489e3766f3d45eeaf5952 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -277,6 +277,10 @@ The size of translation unit that IPA-CP pass considers large. Common Joined UInteger Var(param_ipa_cp_value_list_size) Init(8) Param Optimization Maximum size of a list of values associated with each parameter for interprocedural constant propagation. +-param=ipa-cp-allow-multi-edge-costing= +Common Joined UInteger Var(param_ipa_cp_allow_multi_edge_costing) Init(0) IntegerRange(0, 1) Param Optimization +Allow double prediction to happen during IPA edge analysis. + -param=ipa-jump-function-lookups= Common Joined UInteger Var(param_ipa_jump_function_lookups) Init(8) Param Optimization Maximum number of statements visited during jump function offset discovery. diff --git a/gcc/predict.c b/gcc/predict.c index d0a8e5f8e04fc3d1ec770602589299b0a30b3b59..c15dd92310dfe77bedc50c027d000833c0a92315 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -3171,16 +3171,22 @@ maybe_predict_edge (edge e, enum br_predictor pred, enum prediction taken) { if (edge_predicted_by_p (e, pred, taken)) return; - if (pred == PRED_LOOP_GUARD - && edge_predicted_by_p (e, PRED_LOOP_GUARD_WITH_RECURSION, taken)) - return; - /* Consider PRED_LOOP_GUARD_WITH_RECURSION superrior to LOOP_GUARD. */ - if (pred == PRED_LOOP_GUARD_WITH_RECURSION) + + /* Allow double prediction in certain circumstances. See PR98782. */ + if (!param_ipa_cp_allow_multi_edge_costing) { - edge_prediction **preds = bb_predictions->get (e->src); - if (preds) - filter_predictions (preds, not_loop_guard_equal_edge_p, e); + if (pred == PRED_LOOP_GUARD + && edge_predicted_by_p (e, PRED_LOOP_GUARD_WITH_RECURSION, taken)) + return; + /* Consider PRED_LOOP_GUARD_WITH_RECURSION superrior to LOOP_GUARD. */ + if (pred == PRED_LOOP_GUARD_WITH_RECURSION) + { + edge_prediction **preds = bb_predictions->get (e->src); + if (preds) + filter_predictions (preds, not_loop_guard_equal_edge_p, e); + } } + predict_edge_def (e, pred, taken); } /* Predict edges to successors of CUR whose sources are not postdominated by