From patchwork Thu Feb 8 10:37:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1896536 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=p5BgblsO; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=p5BgblsO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVtjf00prz23h2 for ; Thu, 8 Feb 2024 21:37:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1C13385829A for ; Thu, 8 Feb 2024 10:37:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2087.outbound.protection.outlook.com [40.107.8.87]) by sourceware.org (Postfix) with ESMTPS id 96AB73858C5F for ; Thu, 8 Feb 2024 10:37:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 96AB73858C5F 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 96AB73858C5F Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.8.87 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707388651; cv=pass; b=eIMgOd35C2UuczBe4+SXwi7MeSsorb8RftdH+W4YMmrcw0IJYzTYbV6o5FpIC9TutD0Yon8GWrUie4CLvs3edhh46wA1aINxnr5zzj1/8roCSk63gqEbN3UCfCvngDUlTCeLzE2DoJQ02qAg1LxyIk9YpEEDVHmAfrUZSL6bY3w= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707388651; c=relaxed/simple; bh=DEoOKqOMzTcqN1NOHokp3McDbnsk7V1DXuei8SFdt6Q=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=EC/OC1lY0bZKNCYlAX/YEA9X4s8Hw4HmFD1oD7+9rCqgqgYyyEwt5rq4voBXSZqj4j6iPOngJH9fZ9wh3uVHV9ubAMf6aDz7xy/tDHHxjIvmF5/vnkZReS5sL+T0g7XdYhzKXHTqVroatsFo7uS3MSRKjxrjl0it1SKYtudOP3w= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=X2rxQc/oCeAQpsSRm673Qb8SPlUM4hKeTlwlJNWpWluSjEgxptP2MFMcHLfw1YZB2HYDgIGPgIr+KoMxQ1NUcbn1M1RuxoAm2pQT/89vxs8AZMyxuro06Pc+5ZmviUFRpguXk+FnpjzGYG0fvMxAD9pEnGDBqiI9bG7DBh4c6BjWW5wh2bClXvbloPzEaKxm/1uowWs6jAtWJo0xTvw95ZDYFKgah9ozfX3meILoYIzK26YBNlevYNViDYVj3f7X/EoMfI2kRqoFxVdHU2oNJIkbvRxot6Mvj8KosDgZPQ84eMU5pmuaPrDKJi4GqykqVslu3DTGtdqtw7FNYYJB+Q== ARC-Message-Signature: i=2; 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=oNctkvJruiqvuaJHObvTSsAz8GolNCnHk0AyPaWesV4=; b=eqorlDCiNEo+y1f1F9m0K+q7MACUquQq+CEtqiblXIIM5qF4wpIWke2PkS2zgEPjHL/5ttA3MlM2yoH6/9o4tzONRlIjFIPOj4+5OIK+mi0aOCK+qSAUq1XzgO0324ArP21mUfD3UTEQCXNxiiV881/SaCw0MifMys0vDyHtisD9XCZhEPIex2LB3d9ZynMz0SYRXww/GUuowUjFxUh187j9BHXiRA5My5KAH+9ithh8UtIG9EXI5ip8ApyhFY8puLPcdgFK4sjkZT5EgrHSrjoLpvN9hcSxHt2Bz9lBfwYneJYgpMHjXZkjHythnVzNyQT1yVkW847wDn9VCVr7xA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) 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=oNctkvJruiqvuaJHObvTSsAz8GolNCnHk0AyPaWesV4=; b=p5BgblsOmQFGiCfncDcfkA4rrTPHBI+JYekTZ+qMT4gg1AMvT4+B4UA/pK83LLe6UMrE3XW01i7F0Wx2jvi0ojEhJE3Fq9wYcxk3uVEicisB2EwNBqrxBgN58dbJJDi0lP7LUyU5GZjEPOB5wZqElc11igbXOzGqJWWe0fIXJGg= Received: from DB9PR05CA0024.eurprd05.prod.outlook.com (2603:10a6:10:1da::29) by DB9PR08MB9467.eurprd08.prod.outlook.com (2603:10a6:10:45b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.39; Thu, 8 Feb 2024 10:37:25 +0000 Received: from DB5PEPF00014B92.eurprd02.prod.outlook.com (2603:10a6:10:1da:cafe::44) by DB9PR05CA0024.outlook.office365.com (2603:10a6:10:1da::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.37 via Frontend Transport; Thu, 8 Feb 2024 10:37:25 +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 DB5PEPF00014B92.mail.protection.outlook.com (10.167.8.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Thu, 8 Feb 2024 10:37:25 +0000 Received: ("Tessian outbound 1076c872ecc6:v228"); Thu, 08 Feb 2024 10:37:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2421065eab6dd448 X-CR-MTA-TID: 64aa7808 Received: from ab101a7525c6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 39E797BB-0409-4C3A-91D9-D4C487C3C1D7.1; Thu, 08 Feb 2024 10:37:18 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ab101a7525c6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 08 Feb 2024 10:37:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fkUwEHo9gcSEXaod4HLPkGRZ3L+w5iGFjeZfwwAVf8R9cTDs3PmvXQw4+xWnsEvFAdgd8DB/6OetKsFLWQ13yfQt6RXmzRc1DDYOg5Ugq74VosFKa8czM5Es7LjG8IaGpDe5aA9MwdOnomjrBbZJr1OD1fmKaulEPIYTe09cSyUINSf+UC5XRNIFgi9O0g1ptpAf6VSeT5NY/5VrGWGQhedlE51HsriA+tWY6arSZoT4A09trGGwRUQMXfQHXVGfKpTvuKmsbayAeT2jfzFjF8X/qWuMYX/qyG0w94BSUce15ONiyX7tVFlVMQpyk45My9O9FIti5Fb1RlOlv0KIvg== 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=oNctkvJruiqvuaJHObvTSsAz8GolNCnHk0AyPaWesV4=; b=ReB4J5J8g1zRmhTjXhA/oTDER0RozdMOpGU/+DQfV7oWjrtYUaajnoNdI8YOHRzqR9Mgr5YFaQmMwE13kJFX3colcpgS1OIU7JEWUels+vsj0zqed+qIVMn7gILxIgXpKsQtXGFVSt57NCHsOGAlgbFvpM9pU3B1KM1jmI1xgpv9kPanZGQfWr6tSUjOfKbbrILdNyD+rIJe1VI12FNUWafmb8cHxD/8z0+Cd4mIVfhwi0Uug4P4HuxFgMRP04ETxPwXCIAsVALJqKdcZCShhBW8qr24kxSsFYBpYjryRaa7Nk79UUUgdhwzBXyhBTGw9l1uQWVf+xxo2cGxyuOSdg== 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=oNctkvJruiqvuaJHObvTSsAz8GolNCnHk0AyPaWesV4=; b=p5BgblsOmQFGiCfncDcfkA4rrTPHBI+JYekTZ+qMT4gg1AMvT4+B4UA/pK83LLe6UMrE3XW01i7F0Wx2jvi0ojEhJE3Fq9wYcxk3uVEicisB2EwNBqrxBgN58dbJJDi0lP7LUyU5GZjEPOB5wZqElc11igbXOzGqJWWe0fIXJGg= 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 DB8PR08MB5369.eurprd08.prod.outlook.com (2603:10a6:10:11c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.24; Thu, 8 Feb 2024 10:37:16 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::810c:8495:3f0a:ef8]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::810c:8495:3f0a:ef8%7]) with mapi id 15.20.7249.039; Thu, 8 Feb 2024 10:37:16 +0000 Date: Thu, 8 Feb 2024 10:37:14 +0000 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 cache restart_loop in vectorizable_live_operations [PR113808] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P123CA0444.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a9::17) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|DB8PR08MB5369:EE_|DB5PEPF00014B92:EE_|DB9PR08MB9467:EE_ X-MS-Office365-Filtering-Correlation-Id: ef177355-2c11-4028-41e1-08dc2891f0dd 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: XolIxycfCfuINUBurHCtwvdmCp3p1bTPQZQ+uOOU9eZeq6D/fRKrjF/uXBy6ZWgQb5W0frsYM6sA1NfXZDOzPAyByE16WBnarZhI/JqjhgA+QF67bW5r6APPHV2h0yRq+DFkcJ4Rp8ZmceSgKNlFDHoXL/SWXv6CJyZtz67SXDcTA1VPyDdTRg79UlY517FhRCOvcZkREg7mb/ZmYbVi39Bz76BakJEfbm0vOfaCBcO2osyGi1ju+bMzhDFdpKmR6w5z1ouXxrLEHHrVnGwEVSoF3Tk+qS/G60b+KAzzBFYhQwxzs6DYi4QSG+wKS67xVtI9Ly2Tg279MD1KOOy02v9qLQhR7Rrqigj8f6+fBf1ZqlXEnUtLQiTQcZd9dwZrGaYAT+lERXlz6t9KigyYn4HwnT2Fti+UsbYAYl1gIKZF1HsGq0TOMieMP/zkkpi4XkaV44q7pykcute6Q7hyvbKREByw2aBJLX23BH5NAOsW+rW+qK7ISPeMN1yFAvkbnK0QHMU9vrrenNrCEJ6xXoruM96sCEQMdjLpFDd2NnQ= 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)(136003)(346002)(376002)(396003)(366004)(39860400002)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(44144004)(33964004)(84970400001)(2906002)(44832011)(5660300002)(235185007)(316002)(41300700001)(66556008)(66476007)(66946007)(6486002)(6506007)(6512007)(478600001)(8676002)(8936002)(4326008)(6916009)(4743002)(2616005)(83380400001)(86362001)(38100700002)(36756003)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5369 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: DB5PEPF00014B92.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 19df0ee7-2fe9-4919-7a1a-08dc2891eb8b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y/vLIKNLHZ4ZKEmj89a8jmZfbC7HJrL5Lf1SRBx7QykjZ10zO3AI4bLFLJ9n1kPjYv9TMEoFu6VU5Lc1QElJDz/rX4gfkuiiQ6qeLWmhEyK0s8SuTDGqqc5c51547CGYMQQkRqRDsai6/nVBRRwIcaA7dLs9zXBHS4jSa0trUsxUuTcnT3ZgS1xVea1GRV405bP4ohoOqSsmIHix+rHNLj54rw8mvPkIle/vmT2cXrI1T/j6Xqah1ieZ8lOfN2ynBEcReMntn+OYKFTULMnnDhJVPm3YKRfdz2gp0ltj9ObyLE6EYffBHQ3mrfr2v4r2QEgaNDnG0ufIigvWxUq2ZTSoGSNO4OM0NfsXU2kaDhar5CQfv46/5pXY/mGbqaZfeCvDLcjreniZ98ZvdQc4Ds/WiEQ2ec0FE7WQ4KplzHuW7ttMxiNnWnQTKlFDDcneIEiAm6wlfKnkOZZGHiTtPj0eZ3Y/wdQ4nDSroWxt8dLrP58yrftyrk09r9+Po1hc3lMi8UQSXbvvl0dOgR3cbcKqsExF9q+QKG5zBqesTYvcmzmSuXo+o7GxBC1ms3U11uArdTCOpgkluMhNqRRXjQ== 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)(346002)(376002)(136003)(396003)(39860400002)(230922051799003)(186009)(82310400011)(451199024)(64100799003)(1800799012)(46966006)(40470700004)(36840700001)(41300700001)(6512007)(36756003)(6486002)(70586007)(70206006)(33964004)(6506007)(44144004)(6916009)(478600001)(8936002)(8676002)(4743002)(4326008)(316002)(82740400003)(81166007)(356005)(2616005)(336012)(26005)(107886003)(83380400001)(86362001)(235185007)(5660300002)(44832011)(2906002)(84970400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2024 10:37:25.6168 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef177355-2c11-4028-41e1-08dc2891f0dd 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: DB5PEPF00014B92.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB9467 X-Spam-Status: No, score=-11.9 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, T_SCC_BODY_TEXT_LINE, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi All, There's a bug in vectorizable_live_operation that restart_loop is defined outside the loop. This variable is supposed to indicate whether we are doing a first or last index reduction. The problem is that by defining it outside the loop it becomes dependent on the order we visit the USE/DEFs. In the given example, the loop isn't PEELED, but we visit the early exit uses first. This then sets the boolean to true and it can't get to false again. So when we visit the main exit we still treat it as an early exit for that SSA name. This cleans it up and renames the variables to something that's hopefully clearer to their intention. Bootstrapped Regtested on aarch64-none-linux-gnu and x86_64-pc-linux-gnu no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/113808 * tree-vect-loop.cc (vectorizable_live_operation): Don't cache the value cross iterations. gcc/testsuite/ChangeLog: PR tree-optimization/113808 * gfortran.dg/vect/vect-early-break_1-PR113808.f90: New test. --- inline copy of patch -- diff --git a/gcc/testsuite/gfortran.dg/vect/vect-early-break_1-PR113808.f90 b/gcc/testsuite/gfortran.dg/vect/vect-early-break_1-PR113808.f90 new file mode 100644 index 0000000000000000000000000000000000000000..5c339fa7a348fac5527bbbf456a535da96b5c1ed --- diff --git a/gcc/testsuite/gfortran.dg/vect/vect-early-break_1-PR113808.f90 b/gcc/testsuite/gfortran.dg/vect/vect-early-break_1-PR113808.f90 new file mode 100644 index 0000000000000000000000000000000000000000..5c339fa7a348fac5527bbbf456a535da96b5c1ed --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/vect-early-break_1-PR113808.f90 @@ -0,0 +1,21 @@ +! { dg-add-options vect_early_break } +! { dg-require-effective-target vect_early_break } +! { dg-require-effective-target vect_long_long } +! { dg-additional-options "-fopenmp-simd" } + +! { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } + +program main + integer :: n, i,k + n = 11 + do i = 1, n,2 + !$omp simd lastprivate(k) + do k = 1, i + 41 + if (k > 11 + 41 .or. k < 1) error stop + end do + end do + if (k /= 53) then + print *, k, 53 + error stop + endif +end diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 190df9ec7741fd05aa0b9abe150baf06b2ca9a57..eed2268e9bae7e7ad36d13da03e0b54eab26ef6f 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10950,7 +10950,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, did. For the live values we want the value at the start of the iteration rather than at the end. */ edge main_e = LOOP_VINFO_IV_EXIT (loop_vinfo); - bool restart_loop = LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo); + bool all_exits_as_early_p = LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo); FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, lhs) if (!is_gimple_debug (use_stmt) && !flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) @@ -10966,8 +10966,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, /* For early exit where the exit is not in the BB that leads to the latch then we're restarting the iteration in the scalar loop. So get the first live value. */ - restart_loop = restart_loop || !main_exit_edge; - if (restart_loop + if ((all_exits_as_early_p || !main_exit_edge) && STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def) { tmp_vec_lhs = vec_lhs0; --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/vect-early-break_1-PR113808.f90 @@ -0,0 +1,21 @@ +! { dg-add-options vect_early_break } +! { dg-require-effective-target vect_early_break } +! { dg-require-effective-target vect_long_long } +! { dg-additional-options "-fopenmp-simd" } + +! { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } + +program main + integer :: n, i,k + n = 11 + do i = 1, n,2 + !$omp simd lastprivate(k) + do k = 1, i + 41 + if (k > 11 + 41 .or. k < 1) error stop + end do + end do + if (k /= 53) then + print *, k, 53 + error stop + endif +end diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 190df9ec7741fd05aa0b9abe150baf06b2ca9a57..eed2268e9bae7e7ad36d13da03e0b54eab26ef6f 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10950,7 +10950,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, did. For the live values we want the value at the start of the iteration rather than at the end. */ edge main_e = LOOP_VINFO_IV_EXIT (loop_vinfo); - bool restart_loop = LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo); + bool all_exits_as_early_p = LOOP_VINFO_EARLY_BREAKS_VECT_PEELED (loop_vinfo); FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, lhs) if (!is_gimple_debug (use_stmt) && !flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) @@ -10966,8 +10966,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, /* For early exit where the exit is not in the BB that leads to the latch then we're restarting the iteration in the scalar loop. So get the first live value. */ - restart_loop = restart_loop || !main_exit_edge; - if (restart_loop + if ((all_exits_as_early_p || !main_exit_edge) && STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def) { tmp_vec_lhs = vec_lhs0;