From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by sourceware.org (Postfix) with ESMTPS id C80CC3882165 for ; Fri, 14 Jun 2024 13:08:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C80CC3882165 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C80CC3882165 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=198.175.65.19 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718370515; cv=pass; b=Fp2Ai7icwtd0OOzhdYckX7/kXefITzw1emupluK1M86lYnST8y+1CQnbB178KbSCdpFH8B/7qQRMeDY+HKAjmBKs/xfSIw77DpTZ4mUx7Td6d699dGn02wr8BrOoCkd1/WZwDQR+l/1LCTzOZlSuLyPw720gdTkz0QWnMHhPT2k= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718370515; c=relaxed/simple; bh=w3UtOFdofQz37qEgqYSFMX33zwtW454GbwzJU0EqQnA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=S0dYpgkcrSOzUOnGC6vPkEw3wvpFBzPn8diSiTp0jVDOjycT+k6GSMxg5BX2CJK6wU0YsE47vfxHwaGwumKEixEKGBINtrBcYtBvOY2Tn4op9R62woazEGOE7rvfh0bCF43vkVEAKPUUSXNhL0d1vgX+BqxAD0phhr9qdb8RVog= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718370513; x=1749906513; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=w3UtOFdofQz37qEgqYSFMX33zwtW454GbwzJU0EqQnA=; b=ahvvBS/yf/P5BuYwYD+rnVziuHbYcl6IaU6Wdw4Ru93+FblDjzD01Gcp qRGXuYkz3ZL1KKiM7V/Fglnh0XbAc2pbztZuon5fHcFJxMmrnow1virlR OJ0Tx1dpRJWyXgUE46AZ+lKlx1vu6CtMudsXGAwhJtJ0iKLlwGs3ZKgqZ xJ0wIcnroY6YLzTl6VmsVsmYe3ceQ0+yzJFc0KYEnq5lJzfWcMnu2HW+n nSYH4ffnKNPSmrp24F8w4q3S/A2Rvxh410RKN5kLGIGt1QeLxRNs/KYsn hIXvtUn3GIkYJBE2J+UD3t5NRobNn7OZPYcX/ig24SybMids4Jm31QF94 Q==; X-CSE-ConnectionGUID: 3dYbNXWlSySMyvAU1mtS0w== X-CSE-MsgGUID: 0asAsoUzRp601biO+XwItw== X-IronPort-AV: E=McAfee;i="6700,10204,11103"; a="15086191" X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="15086191" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2024 06:08:32 -0700 X-CSE-ConnectionGUID: laTY60+bTvS5wqjzjfBz8g== X-CSE-MsgGUID: ardX8Dm7S4SB+CtrFkchTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="45449804" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 14 Jun 2024 06:08:32 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 14 Jun 2024 06:08:31 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 14 Jun 2024 06:08:31 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Fri, 14 Jun 2024 06:08:31 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.172) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 14 Jun 2024 06:08:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JbviOGl6lVvnWE+D0eqEXRYFf5tH0u4x2Tllg4ZYxEkGaCWfzTg5a0rLIZlaPxiI07GMn+y8sgG0oDdRKIwuaG0/h0yflvTThD8axlfXkgjwV7e4AZUJ1bNJuABEojp7gFTGq4uhyNAMufXG+SDqMYcz9MVbRM/Dfci3OeNH72aVf34tfLb+jD8BKsrQk9pSG/pY0sbZAJ2j5DFvWpaDmY5Hx6VQpvPHFUCkbdgHEDUmYundcUYwOsA2ZeewFbRyvpE5fWL9vVj+QGejs1obp8rXNpB0KncBhsAxCT+UpIsfuDS6lb0eW/T4ODcL0N0CvhSDhmCASm/KmDOx5Kgl0g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a6c5uymqqrCz3vz1834uApI3YzMdrqXir5tZeVsA3mk=; b=HH4nXE3I2ajbhj/GHYGtL+scAomfCGsRZ83EB5WfHZJT0AksaZC69CJYgfsBV637AMJXx/jpa+B+A8QCGFOZ7J5CyW+NvJ9jzEv2x4tbWCCkn0v0DJNsaBJXsYoYdhqXDU/XDYo7QnacdLlnIZnbviC35HCsWiIKe7fFlSzCvHJgG6dcL43bT0kakEuhPrPZZFAa+qNNGzOzrgF8tTbeWQyvVfY7tEiFaDSLvRDJmytcyxxS/D+RSgAbw98RGddhM69Pa0JYiV5T7lYcWkmISD4uOahgPDvJxJxzkAvH3O/cry1rzFNHeNNNDEXHZxAu6kGzVmgDDwysqi5ngR2/lA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MW5PR11MB5908.namprd11.prod.outlook.com (2603:10b6:303:194::10) by SA1PR11MB5946.namprd11.prod.outlook.com (2603:10b6:806:23a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25; Fri, 14 Jun 2024 13:08:28 +0000 Received: from MW5PR11MB5908.namprd11.prod.outlook.com ([fe80::c798:ab3c:1a03:af59]) by MW5PR11MB5908.namprd11.prod.outlook.com ([fe80::c798:ab3c:1a03:af59%3]) with mapi id 15.20.7677.024; Fri, 14 Jun 2024 13:08:28 +0000 From: "Li, Pan2" To: Richard Biener , "gcc-patches@gcc.gnu.org" Subject: RE: [PATCH] tree-optimization/114589 - remove profile based sink heuristics Thread-Topic: [PATCH] tree-optimization/114589 - remove profile based sink heuristics Thread-Index: AQHapqvO3gheruvSlEKhA6sKf0NPSrHHaXQg Date: Fri, 14 Jun 2024 13:08:28 +0000 Message-ID: References: <20240515093858.A83C91372E@imap1.dmz-prg2.suse.org> In-Reply-To: <20240515093858.A83C91372E@imap1.dmz-prg2.suse.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW5PR11MB5908:EE_|SA1PR11MB5946:EE_ x-ms-office365-filtering-correlation-id: 21f4e149-8fea-46ca-66fd-08dc8c73150d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230037|366013|376011|1800799021|38070700015; x-microsoft-antispam-message-info: =?us-ascii?Q?YefoHDnnstgztFvWC0SOFK9cMFwy3U1Fw6Jn4bCKfUCEweHC1OJiv8g5A81+?= =?us-ascii?Q?4t7Ao/W4CbcfiMcS6NMSfHgGpgfvt4SW/grOmK4GImlUkmQn30cv7hKQZlwh?= =?us-ascii?Q?MAOolthrsZF7djfXM7UfmK/e9kKB6Tbr1L9CC9clVsZW7SaaLAbOFCVi7wgX?= =?us-ascii?Q?9frOd5aBhqHpON+cMM/TZdWuB2ZMGLU4KoNjjj/6XrbF+J90GJLMAjpSZC9T?= =?us-ascii?Q?547ozO58QSwCxoVwsidttOmAmQ/+fjJ3movaQ0qUL8vNnp+n9cxXaH8WqVcz?= =?us-ascii?Q?H0xN3RgZbBBm42GR6WkOtgYOBuiMRPmJVkWXyjASD/ZFa+SGY7oriOJ6fRtz?= =?us-ascii?Q?axNboKOO2R/AMIgDRmbCsdzeK7dwEoMkyf+hR8tx8duV68wr/GJUFlLWRrzR?= =?us-ascii?Q?8POolBaauQDA0m9guOsQ0mwut5B0mzIeEp5hVLTQHrGchmuSav31119YxLsc?= =?us-ascii?Q?0u24ZUf1e5UyA1+BwdJh9EklO+Qibp+aoxPocIUyYv9eHXQXxOENBhXGsI/A?= =?us-ascii?Q?jC0lY+MPqN+3fE1l7f6ECbg22uuPPBDKjP3edVOJnOG0qdbAfuj+iMWNdfyw?= =?us-ascii?Q?/G81E5Fd/c6O2m4Get1SSVnHkS5FGCsBnEimZpnhlDsiBK/f+xQl3Puznc+V?= =?us-ascii?Q?20nGgtdLlhinCKDXaLCDmI3ay33Z+aPcRwlfhvff2Qw4u/YvsrEo7dA7mq0a?= =?us-ascii?Q?H0pQiJ4sy5HPiJJj9TpScD3BPWbLdUrFMj7Id3dsoksgTn2KuHwXTEcpAqbv?= =?us-ascii?Q?kx0I9y5/8KEbgU/5ac/Q8/WykoEx2hBxwrKBd0+virRvROdn8+Yv+GbNdJhs?= =?us-ascii?Q?5zbF29w9hygwuSDVjZzhUWB536bxGt6ZbYDvX5b6fuqtniCleAGszn6RYck+?= =?us-ascii?Q?ToTYcAY+6Foi9gSMFF3D8ONWC60p14TpLpL0hu7ln5G5VU3elhpCRm+sLA4O?= =?us-ascii?Q?LulKeo2wPn8VqPdXBfD1oOP1qBmh8TslwCerLjxP3QXyHF0Ae7ySia2b1+lJ?= =?us-ascii?Q?dEfPqib99T8t/vFHxuCjGU+5bvGIsswxDaZwGZlMAO0p5DAp2N732kGXsKWC?= =?us-ascii?Q?WzeT4FFSFgKZGQS8VHwbpP4Ii6U/4sP8vBE3ww2v25U0QpJDqHsgMOI5eU82?= =?us-ascii?Q?HamUUXMMJxFlEB/l6/sdOlczCZfv5BJXIVxijSDXgi9oX0uNCPS/q/FfdT5P?= =?us-ascii?Q?siuwsSBeaI2TysV85FQ5KR2fP8pHKZYUBWLxKP49itnHIz1tQq8i/jZNzfvp?= =?us-ascii?Q?46pBvtmsh5gOEwkP0yqgKB7CBbSsnUmoTgoBCYTa2h76TrIOTQ/YzsZts4+F?= =?us-ascii?Q?qrkhH5TtpWC1lY4y554NYTI7?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW5PR11MB5908.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(376011)(1800799021)(38070700015);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Nb7D846PjhAlEp2OEkx7QbRvcvijTRPGrBR6VQ6/myJe2jKCzzJmWon5ow/y?= =?us-ascii?Q?XcwUyVRtcrwSQm9NZRtXx55HctEYv3xuQa6mc07PWKHAN5DVsL8l28KSOtZc?= =?us-ascii?Q?H77MrXb3Z4UQcN5RKQDJJ2cHJilT36X9zxfHIGvaTb6g+i54fC6aTSBB7Sre?= =?us-ascii?Q?skKvgshv8it0gKFjjNEQhtjku6aOffepago51CBD7FTLK1BA84d7xecuddt/?= =?us-ascii?Q?I2IC5MFbL5UzbX3v+i4iegEJ3AS6wEAiB/Dl8GklwLTwsnt1XTuiheMeZAaq?= =?us-ascii?Q?q4p8Mf+SMFSCyiXBnt4p/O+5DLkvlquBZh7c3INslylMq8vJn2XCRujiWD0n?= =?us-ascii?Q?inbCbr3MAFFAUOmK5GCCtS5LWghtl7nceP5PLA5ycE94wrZUF+z2DKxFF7De?= =?us-ascii?Q?O0pJsbB0O/ss5b7EfBlE/e/SE0utj9sSvrOXXmnNVIcPmuqAj6erANBCys2r?= =?us-ascii?Q?dB0/TCIcyvSxJsTOsoo0B0fVefYM0dwplSofVtix4JRx/dKwHmBabtIM41TM?= =?us-ascii?Q?Ebw+EDnrnaTONu9MGElJP79Z6YJ24xq1VIg3Gr8fYbo8WhXHSVm5Dp2znJ0H?= =?us-ascii?Q?xizYTr5gCiVW6I1vRDuX9JCPDS0TOTepgYIPp1ZZLZ8lVNOypLkgA5of/ann?= =?us-ascii?Q?qBtOAMVsAhnlIJAWU9bjh2W3+jGE1+wgHTZReikupTXSSIPs/6NalI8+vNFm?= =?us-ascii?Q?Kugq/x9B/rcUo3Q80fJzcdaPMgq4cXAIyVf4HotGQFMWDs/ByXEnTYxUpi6L?= =?us-ascii?Q?IH4k/3oU+YC6PiSiocOS0L1kSpJWEMUl1p0L9bPVPrWZewgKt/ewDtWhqjq3?= =?us-ascii?Q?QEjrZhV4VYIJBtXR0D7QLZFf9Ln83Y7n1yNRBVq/KUFp8bCVZ9FuKYGsFgJj?= =?us-ascii?Q?fGAyW6dILi1cz1XebHf+a2uWGmSqjhoR4w4dFuMGi+weqtApu+W+/2DRmCtx?= =?us-ascii?Q?Tzig/uAdSYrnXYNFWprMJz83GlWyOnGQInefbSoHRpOa2BAKKDOdeZrD6p+s?= =?us-ascii?Q?l9YhAIsJg/YhH0O8+ipA8RydlW1KE/JxACgyIWDhcdSf7b+ONbfZxdX58ftT?= =?us-ascii?Q?azImIEf8H9Qf/1KLVeEtyJ542VajDVaYPMlCPScr81Aezj6swjarL7FzaETD?= =?us-ascii?Q?i89kB0/k+jBpwYuLbrIHhBSnaxQHADYMBaJRweY3QP1/QfqA7sXmYmqfBhb0?= =?us-ascii?Q?7CJw36QAFM/gR4jh8hcmNiINYyFgauVjzvgPOKR+6i+/mJhkRCKQY1Eur0zh?= =?us-ascii?Q?VU4Ywdat6VHwvaIiytj1xqtO3fcp9gNWeZK/j+HgcOp24WKmn+2AoBluJ9xT?= =?us-ascii?Q?EtnbktBYh1Q2gQADkgaick3X1waFAUsX7cqn1L+1409rInCpFxnl6Ossh0f/?= =?us-ascii?Q?Z2rrNW8qtvEldE1H27k+JUzG8ADfJIrPvtY4ZZRTeW91UR6pyCN/XCng1wXm?= =?us-ascii?Q?/jVFNDxEFuGzt7k9uUi0dsr2XzgfJp2+9uFGdtlpkwrd/cEdmPD9j6w8yLa0?= =?us-ascii?Q?2Y5ap0+rRGJxHGaVdBxzI3BqxiZB4+GaahLSP4sJ3sRy/VgRgcQ84UoTPBX8?= =?us-ascii?Q?azlDEOA1dcUXst6LLcU=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW5PR11MB5908.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21f4e149-8fea-46ca-66fd-08dc8c73150d X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jun 2024 13:08:28.1589 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: siU/pbbgRfawm8oZgzSrVy7kj6nlCMp5oT2qdCihv/6D/ZalVgQoN+UnDHiD7snUnf1sljxnUa+n2ockTNETqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB5946 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Richard, Here is one PR related to this patch (by git bisect), details as below. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115458 I am still trying to narrow down which change caused this failure or any hi= nts here? Pan -----Original Message----- From: Richard Biener =20 Sent: Wednesday, May 15, 2024 5:39 PM To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/114589 - remove profile based sink heuri= stics The following removes the profile based heuristic limiting sinking and instead uses post-dominators to avoid sinking to places that are executed under the same conditions as the earlier location which the profile based heuristic should have guaranteed as well. To avoid regressing this moves the empty-latch check to cover all sink cases. It also stream-lines the resulting select_best_block a bit but avoids adjusting heuristics more with this change. gfortran.dg/streamio_9.f90 starts execute failing with this on x86_64 with -m32 because the (float)i * 9.9999...e-7 compute is sunk across a STOP causing it to be no longer spilled and thus the compare failing due to excess precision. The patch adds -ffloat-store to avoid this, following other similar testcases. This change doesn't fix the testcase in the PR on itself. Bootstrapped on x86_64-unknown-linux-gnu, re-testing in progress. PR tree-optimization/114589 * tree-ssa-sink.cc (select_best_block): Remove profile-based heuristics. Instead reject sink locations that sink to post-dominators. Move empty latch check here from statement_sink_location. Also consider early_bb for the loop depth check. (statement_sink_location): Remove superfluous check. Remove empty latch check. (pass_sink_code::execute): Compute/release post-dominators. * gfortran.dg/streamio_9.f90: Use -ffloat-store to avoid excess precision when not spilling. --- gcc/testsuite/gfortran.dg/streamio_9.f90 | 1 + gcc/tree-ssa-sink.cc | 62 ++++++++---------------- 2 files changed, 20 insertions(+), 43 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/streamio_9.f90 b/gcc/testsuite/gfort= ran.dg/streamio_9.f90 index b6bddb973f8..f29ded6ba54 100644 --- a/gcc/testsuite/gfortran.dg/streamio_9.f90 +++ b/gcc/testsuite/gfortran.dg/streamio_9.f90 @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-options "-ffloat-store" } ! PR29053 Stream IO test 9. ! Contributed by Jerry DeLisle . ! Test case derived from that given in PR by Steve Kargl. diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc index 2f90acb7ef4..2188b7523c7 100644 --- a/gcc/tree-ssa-sink.cc +++ b/gcc/tree-ssa-sink.cc @@ -178,15 +178,7 @@ nearest_common_dominator_of_uses (def_operand_p def_p,= bool *debug_stmts) =20 We want the most control dependent block in the shallowest loop nest. =20 - If the resulting block is in a shallower loop nest, then use it. Else - only use the resulting block if it has significantly lower execution - frequency than EARLY_BB to avoid gratuitous statement movement. We - consider statements with VOPS more desirable to move. - - This pass would obviously benefit from PDO as it utilizes block - frequencies. It would also benefit from recomputing frequencies - if profile data is not available since frequencies often get out - of sync with reality. */ + If the resulting block is in a shallower loop nest, then use it. */ =20 static basic_block select_best_block (basic_block early_bb, @@ -195,18 +187,17 @@ select_best_block (basic_block early_bb, { basic_block best_bb =3D late_bb; basic_block temp_bb =3D late_bb; - int threshold; =20 while (temp_bb !=3D early_bb) { + /* Walk up the dominator tree, hopefully we'll find a shallower + loop nest. */ + temp_bb =3D get_immediate_dominator (CDI_DOMINATORS, temp_bb); + /* If we've moved into a lower loop nest, then that becomes our best block. */ if (bb_loop_depth (temp_bb) < bb_loop_depth (best_bb)) best_bb =3D temp_bb; - - /* Walk up the dominator tree, hopefully we'll find a shallower - loop nest. */ - temp_bb =3D get_immediate_dominator (CDI_DOMINATORS, temp_bb); } =20 /* Placing a statement before a setjmp-like function would be invalid @@ -221,6 +212,16 @@ select_best_block (basic_block early_bb, if (bb_loop_depth (best_bb) < bb_loop_depth (early_bb)) return best_bb; =20 + /* Do not move stmts to post-dominating places on the same loop depth. = */ + if (dominated_by_p (CDI_POST_DOMINATORS, early_bb, best_bb)) + return early_bb; + + /* If the latch block is empty, don't make it non-empty by sinking + something into it. */ + if (best_bb =3D=3D early_bb->loop_father->latch + && empty_block_p (best_bb)) + return early_bb; + /* Avoid turning an unconditional read into a conditional one when we still might want to perform vectorization. */ if (best_bb->loop_father =3D=3D early_bb->loop_father @@ -233,28 +234,7 @@ select_best_block (basic_block early_bb, && !dominated_by_p (CDI_DOMINATORS, best_bb->loop_father->latch, bes= t_bb)) return early_bb; =20 - /* Get the sinking threshold. If the statement to be moved has memory - operands, then increase the threshold by 7% as those are even more - profitable to avoid, clamping at 100%. */ - threshold =3D param_sink_frequency_threshold; - if (gimple_vuse (stmt) || gimple_vdef (stmt)) - { - threshold +=3D 7; - if (threshold > 100) - threshold =3D 100; - } - - /* If BEST_BB is at the same nesting level, then require it to have - significantly lower execution frequency to avoid gratuitous movement.= */ - if (bb_loop_depth (best_bb) =3D=3D bb_loop_depth (early_bb) - /* If result of comparsion is unknown, prefer EARLY_BB. - Thus use !(...>=3D..) rather than (...<...) */ - && !(best_bb->count * 100 >=3D early_bb->count * threshold)) - return best_bb; - - /* No better block found, so return EARLY_BB, which happens to be the - statement's original block. */ - return early_bb; + return best_bb; } =20 /* Given a statement (STMT) and the basic block it is currently in (FROMBB= ), @@ -452,13 +432,7 @@ statement_sink_location (gimple *stmt, basic_block fro= mbb, return false; =20 sinkbb =3D select_best_block (frombb, sinkbb, stmt); - if (!sinkbb || sinkbb =3D=3D frombb) - return false; - - /* If the latch block is empty, don't make it non-empty by sinking - something into it. */ - if (sinkbb =3D=3D frombb->loop_father->latch - && empty_block_p (sinkbb)) + if (sinkbb =3D=3D frombb) return false; =20 *togsi =3D gsi_after_labels (sinkbb); @@ -822,6 +796,7 @@ pass_sink_code::execute (function *fun) mark_dfs_back_edges (fun); memset (&sink_stats, 0, sizeof (sink_stats)); calculate_dominance_info (CDI_DOMINATORS); + calculate_dominance_info (CDI_POST_DOMINATORS); =20 virtual_operand_live vop_live; =20 @@ -833,6 +808,7 @@ pass_sink_code::execute (function *fun) =20 statistics_counter_event (fun, "Sunk statements", sink_stats.sunk); statistics_counter_event (fun, "Commoned stores", sink_stats.commoned); + free_dominance_info (CDI_POST_DOMINATORS); remove_fake_exit_edges (); loop_optimizer_finalize (); =20 --=20 2.35.3