From patchwork Thu Oct 19 12:29:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 155494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp347038vqb; Thu, 19 Oct 2023 05:30:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFftsdU0Z8P0sWWW10afBICUA0SlHS0h7zcHFstbJwgT4mpQbECCLIplZ7PNCVoVprvt8yb X-Received: by 2002:a05:622a:7:b0:418:d14:1cc2 with SMTP id x7-20020a05622a000700b004180d141cc2mr2236723qtw.55.1697718638343; Thu, 19 Oct 2023 05:30:38 -0700 (PDT) Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a9-20020a05622a02c900b004178b478447si1451659qtx.429.2023.10.19.05.30.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:30:38 -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=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=pdDJl9mj; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=pdDJl9mj; arc=fail (previous hop failed); 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1BDD7385783F for ; Thu, 19 Oct 2023 12:30:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2044.outbound.protection.outlook.com [40.107.105.44]) by sourceware.org (Postfix) with ESMTPS id 0E6DE3858D1E for ; Thu, 19 Oct 2023 12:30:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E6DE3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E6DE3858D1E Authentication-Results: server2.sourceware.org; arc=fail smtp.remote-ip=40.107.105.44 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697718613; cv=fail; b=wgoy+0pyWOSPBXJ7RXxNj9AitO/5sIrQI7HeB4G5GllxLRsXpbvvefPUYunx6hQLLf41Neq339y2gD56/gtwzVGk9HKcmbZ7LGyBEFJx32saxgYqOHFCxPvz8uiotSZDCtnSL3oNQGoaPntC2MHpK/N88kbeAT+1lHVknvh54Gs= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697718613; c=relaxed/simple; bh=MJ8mewN+qv2bkZMiJUbDsG6WUMJLP9f9cc1AYOigFus=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=VuQArNzfBnGQ9qIZNFjPEzNgdGdpW91IX6NFDxPy4G1UplBJRmq0FmbKVEw9b1ieuEKzbAsJOvTJfIDYn10lZ5yFIxqk7Hxbi6+UvK3fQGPa3wDG9B2t2X69cjKqUw6i0qRHUdsgpcI5tbn0nmgDXrD+tfk9GeAH/rCtaIVU74k= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1h16VyKLFsVLvH8lpv0zm/809BXGjf3L2VKeZPWMWlA=; b=pdDJl9mjwRKL0HWJ7WFqcVcFycVlkH6iIfQJ2vEp/wjxTCWHA9qBubSCzc/Qf1xReQjBbLKEqN5GU0T+s9iJkTojr8SJ9d2qIDvVO7cL1CKt7mItCkNAiPykzRRBChPrIdcKmFVo3c5opmMFZvyqMUob2UKm1i2jI2dXhdD2mZw= Received: from DU2PR04CA0276.eurprd04.prod.outlook.com (2603:10a6:10:28c::11) by DBBPR08MB10817.eurprd08.prod.outlook.com (2603:10a6:10:539::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Thu, 19 Oct 2023 12:30:07 +0000 Received: from DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28c:cafe::a8) by DU2PR04CA0276.outlook.office365.com (2603:10a6:10:28c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24 via Frontend Transport; Thu, 19 Oct 2023 12:30:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT060.mail.protection.outlook.com (100.127.142.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.22 via Frontend Transport; Thu, 19 Oct 2023 12:30:06 +0000 Received: ("Tessian outbound d9a8e74be042:v215"); Thu, 19 Oct 2023 12:30:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 30e4969216428813 X-CR-MTA-TID: 64aa7808 Received: from e309b503d0f3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4D5BE92B-5A8F-4E6F-B17F-674F2A5D7801.1; Thu, 19 Oct 2023 12:30:00 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e309b503d0f3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 19 Oct 2023 12:30:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oJSzp0aQZXNRP+bTeLFEmfUEyitk4YbnWOycPf1xKbtEb1j0DxxqqQ2+0BMeX8iw37RMT1BXkh03QRMSXlHiXQelzoPMa6iyLyGcF1HMf1pjgXAFeLWWVEWV8pi2FjE3WtDH7KZKy6sn7ZwI5qWrkffJtuLfN/raG4gEzwr/+XD3ioInDkDGC+moAFpsnEYs1kr8al1Z5HV1dG3CC3FT2KgeH+QqOvem2jwLh8mxpYkLa7BrKMNgZt0f3x/fV4rlyNd0nu3ZBDmCQTSkQzm0wZnWtDTzeZWm0B3n33gCeAqLh3Avw+4jNzl8OLSGJGT6+jjJw6Af2NayhGjoMVRIAg== 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=1h16VyKLFsVLvH8lpv0zm/809BXGjf3L2VKeZPWMWlA=; b=C0LYrsXgkzb75P9ZRYCWKNbBw8yU2hE78AQvOgrC3LuUSwY0T2l/bDucMt8L08CZupX42olbPddalH36CR1auyoNKo6LDZETgmaJZ3B70CoO+x/7Ad3HWP7oGfSwbjVU3rgR5uwOk7FyIy/KUsd60YR/vMTpLPe4io9aZIvAFToZSmcVjAzUlls7OauOMfrDGZiubIZvq6QwQBBZvmYToBfTCupdhsDxe3ZkhAQDf+S3OZ7SbZsOQmvUJBrdWpTNvvRuo9zhdycTyaXa4wkvKc/epSPrTZ2lCr0BNGmumsEwZs2e8uo6UkzaNn93bR1nBGPvGeByJ/SqwFYQgSE8rA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1h16VyKLFsVLvH8lpv0zm/809BXGjf3L2VKeZPWMWlA=; b=pdDJl9mjwRKL0HWJ7WFqcVcFycVlkH6iIfQJ2vEp/wjxTCWHA9qBubSCzc/Qf1xReQjBbLKEqN5GU0T+s9iJkTojr8SJ9d2qIDvVO7cL1CKt7mItCkNAiPykzRRBChPrIdcKmFVo3c5opmMFZvyqMUob2UKm1i2jI2dXhdD2mZw= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by VI0PR08MB10558.eurprd08.prod.outlook.com (2603:10a6:800:209::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Thu, 19 Oct 2023 12:29:57 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bba1:2711:6992:468d]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bba1:2711:6992:468d%4]) with mapi id 15.20.6907.022; Thu, 19 Oct 2023 12:29:57 +0000 Date: Thu, 19 Oct 2023 13:29:54 +0100 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH]middle-end: don't create LC-SSA PHI variables for PHI nodes who dominate loop Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P265CA0282.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:37a::14) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|VI0PR08MB10558:EE_|DBAEUR03FT060:EE_|DBBPR08MB10817:EE_ X-MS-Office365-Filtering-Correlation-Id: 886f1f1b-a0ec-409d-58e8-08dbd09f20af x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: LkF8d9x81gI1xrKQScYOHqQN6c60sdTlBMrMRcY9oWAFWi1You3adQeAhoUpsws6OlEagZEdud3dzHGbTfhoq545e61MRDoiCxXyoH4BgbLaJd0Zn1QHszqFBaD94Eq3uJjRQo6kY3B6VleWD2vlrPr+btwjhfqcyV15q9aBv1Rk+0GXq6v1PseKyo3t6w0t4n+UGNE2FYsI+qR9zr5+b4R4iLwMV9bh3H0xJCeiVvw+P+5f7hhOKP5q4ymuOqBBjF3VMo3NCgRx7jzUH4WqrY10eovAA8B82x99DkKS4wIGFfWMpyv86BmYE0+0sX5S7yIjMBg1R9CGdX1qm00WzpPUvk72ufSbNJ/Xr0G9537Pra+vyMKBJh7p49QvMfsdUGgHsHeVcUhrOK18HxIZBSDKV3GcfISMguVWMVQiWg+lbDImlB9zAjW1LkU0Es8QzuqFc48qV9NI9lbLP35M/NQTMD4BnzutL0YJyY4Ums7giOlM/lSYDts2pdKYzvc6TinDwST3dcdaonajESzHfSQMoNux7REW39AKuQCgyjdbpsylkosDpI0S2mRb+oCh0KaootVOZZWoGi46xIHJnCihExZoAR5A6LKKdktLU2SN9iP1GGnPxTAL0QmIc/NL 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:(13230031)(396003)(346002)(136003)(376002)(366004)(39860400002)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(4743002)(26005)(84970400001)(5660300002)(83380400001)(38100700002)(44832011)(41300700001)(8936002)(316002)(8676002)(478600001)(4326008)(235185007)(66476007)(66556008)(6916009)(86362001)(66946007)(6486002)(33964004)(6506007)(2906002)(6666004)(44144004)(2616005)(6512007)(36756003)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR08MB10558 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a5115505-9e9c-4b78-6432-08dbd09f1ac4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E6d5wuwZoqb9FREstuyPPdCBUX2qvAcsIBpJeX2kc+4b+Tlrl2+PPI08efoBtnNyjYofe+2Z0etmKabYRd0kxTlXUKoIebc9d6mhzXcSToVptK6ELUzSWs27OYr3pnmnt5bgG6w4ZUgBXaoUBZEdPGv9tDj/SOnI9Yu6dBeyCiYZbETo7NR03LKSvoODt8SgYO37KJwh4sSdcd/wBu2Lkw8rJFseUNvB38QsSpBWOHxTCOcpXwX/VXTCqfBnXICeZ0U+cgS7jciHwR1dh6wHYc0PV2tZT+NjKUaYTCp06k/hvWbyMq/jlnu2eSd5uDDN+s5Q+JpSeAH7f8UVIj6c5QbCLSL4Gs2HaSkJLmKF5kMyGa41gRZ1jpt/y4y6IuygDCdkq9ut+z+yhzg+mhSpQ9q1eLA1WU7KSrgw8Tfv/CVIwLIX4YLF8M+j41uviu0XbNcCMGWwce3YPd9rxX/patDZ8abGx469dpnHbVaqmLTRelngI/y8H4108AYkql5L/c38UqNHyli/eH0EZp+d5FvFvH0hnGH07ZJ2Xpef3f9Ix+vjuQyz8iJFqrks5TMLqMyzol60JKHPq/HJWSOthuKBNsy/5cEwLbQMajvGydfuN37POUcmFDhSdWgguedtareAAO1qkcp9K1OmdNvQ0EeRYSetr6nFa4LMj0OQCiLVPxE2FQV1WgWUcrphrm+VqwtFXQzr+cf9ebYU66rOnF7u2D19nRNIl2O267Pa8a7ATDZVuRLkRR0I6WmaNSh6NvXyyZcN/CgPiaM5oTSsI4eHq4JoT24eJYiPnCW05kw= 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:(13230031)(4636009)(136003)(39860400002)(376002)(346002)(396003)(230922051799003)(64100799003)(451199024)(82310400011)(186009)(1800799009)(46966006)(36840700001)(40470700004)(47076005)(84970400001)(40460700003)(83380400001)(41300700001)(81166007)(478600001)(6506007)(356005)(26005)(6666004)(70586007)(4326008)(5660300002)(316002)(44832011)(8676002)(6916009)(70206006)(6486002)(8936002)(6512007)(2616005)(33964004)(82740400003)(107886003)(44144004)(40480700001)(36860700001)(336012)(36756003)(86362001)(2906002)(235185007)(4743002)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 12:30:06.9484 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 886f1f1b-a0ec-409d-58e8-08dbd09f20af 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: DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB10817 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780187018725460723 X-GMAIL-MSGID: 1780187018725460723 Hi All, As the testcase shows, when a PHI node dominates the loop there is no new definition inside the loop. As such there would be no PHI nodes to update. When we maintain LCSSA form we create an intermediate node in between the two loops to thread alongt the value. However later on when we update the second loop we don't have any PHI nodes to update and so adjust_phi_and_debug_stmts does nothing. This leaves us with an incorrect phi node. Normally this does nothing and just gets ignored. But in the case of the vUSE chain we end up corrupting the chain. As such whenever a PHI node's argument dominates the loop, we should remove the newly created PHI node after edge redirection. The one exception to this is when the loop has been versioned. In such cases the versioned loop may not use the value but the second loop can. When this happens and we add the loop guard unless the join block has the PHI it can't find the original value for use inside the guard block. The next refactoring in the series moves the formation of the guard block inside peeling itself. Here we have all the information and wouldn't need to re-create it later. Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-linux-gnu and no issues and issues in libgomp fixed. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/111860 * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Remove PHI nodes that dominate loop. gcc/testsuite/ChangeLog: PR tree-optimization/111860 * gcc.dg/vect/pr111860.c: New test. --- inline copy of patch -- diff --git a/gcc/testsuite/gcc.dg/vect/pr111860.c b/gcc/testsuite/gcc.dg/vect/pr111860.c new file mode 100644 index 0000000000000000000000000000000000000000..36f0774601040418bc6b7f27c9425b2bf93b18cb --- diff --git a/gcc/testsuite/gcc.dg/vect/pr111860.c b/gcc/testsuite/gcc.dg/vect/pr111860.c new file mode 100644 index 0000000000000000000000000000000000000000..36f0774601040418bc6b7f27c9425b2bf93b18cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr111860.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +int optimize_path_n, optimize_path_d; +int *optimize_path_d_0; +extern void path_threeOpt( long); +void optimize_path() { + int i; + long length; + i = 0; + for (; i <= optimize_path_n; i++) + optimize_path_d = 0; + i = 0; + for (; i < optimize_path_n; i++) + length += optimize_path_d_0[i]; + path_threeOpt(length); +} diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 1f7779b9834c3aef3c6a993fab916224fab03147..db1d4f867ead5c6079cda3ff0d0870234d11e39d 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -1633,6 +1633,21 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit, { tree new_arg = gimple_phi_arg (phi, 0)->def; new_phi_args.put (new_arg, gimple_phi_result (phi)); + + if (TREE_CODE (new_arg) != SSA_NAME) + continue; + /* If the PHI node dominates the loop then we shouldn't create + a new LC-SSSA PHI for it in the intermediate block. Unless the + the loop has been versioned. If it has then we need the PHI + node such that later when the loop guard is added the original + dominating PHI can be found. */ + basic_block def_bb = gimple_bb (SSA_NAME_DEF_STMT (new_arg)); + if (loop == scalar_loop + && (!def_bb || !flow_bb_inside_loop_p (loop, def_bb))) + { + auto gsi = gsi_for_stmt (phi); + remove_phi_node (&gsi, true); + } } /* Copy the current loop LC PHI nodes between the original loop exit --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr111860.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +int optimize_path_n, optimize_path_d; +int *optimize_path_d_0; +extern void path_threeOpt( long); +void optimize_path() { + int i; + long length; + i = 0; + for (; i <= optimize_path_n; i++) + optimize_path_d = 0; + i = 0; + for (; i < optimize_path_n; i++) + length += optimize_path_d_0[i]; + path_threeOpt(length); +} diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 1f7779b9834c3aef3c6a993fab916224fab03147..db1d4f867ead5c6079cda3ff0d0870234d11e39d 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -1633,6 +1633,21 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit, { tree new_arg = gimple_phi_arg (phi, 0)->def; new_phi_args.put (new_arg, gimple_phi_result (phi)); + + if (TREE_CODE (new_arg) != SSA_NAME) + continue; + /* If the PHI node dominates the loop then we shouldn't create + a new LC-SSSA PHI for it in the intermediate block. Unless the + the loop has been versioned. If it has then we need the PHI + node such that later when the loop guard is added the original + dominating PHI can be found. */ + basic_block def_bb = gimple_bb (SSA_NAME_DEF_STMT (new_arg)); + if (loop == scalar_loop + && (!def_bb || !flow_bb_inside_loop_p (loop, def_bb))) + { + auto gsi = gsi_for_stmt (phi); + remove_phi_node (&gsi, true); + } } /* Copy the current loop LC PHI nodes between the original loop exit