From patchwork Mon Feb 5 13:08:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 85307 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18B4A385829C for ; Mon, 5 Feb 2024 13:09:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2058.outbound.protection.outlook.com [40.107.15.58]) by sourceware.org (Postfix) with ESMTPS id 87D4B3858409 for ; Mon, 5 Feb 2024 13:09:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87D4B3858409 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 87D4B3858409 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.15.58 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707138554; cv=pass; b=PuvnCD2jbOi3pIl1B827Zr7bCTBtWTpDDJ/HPxFPdEZHCayo5T9nOzkZau1L4TD8nJICze/T2PvQWesbITEq1+fZZM9/EyTZ37X8CeP7TqqteOO/ZaNODuRXSaRTSkbNVapbmCfEwyD4qfbqQ1SjicDo1NqibRUfU6RjNbs7A3U= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707138554; c=relaxed/simple; bh=dHkmpYaGiH1YjswrYhAlc2ylLelHgQjEYsSdIOjzdFc=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=fxb9urXUycYsQbH4KvnYy5HXiIp1g3aDTV4tDgqRxYs/6/RmJZnaaBtDUKCAGNux/SotvEoWBFvzFrUBtNQtjCf6+owb920UNwbYcv+NxXx4Jagvdlc5EmMeTsHoFWV0gylSjhcBvbZiYkYtPdj5k0ns+dHssHPKBYEF9mYaL20= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=odI9cvjmkxlSvML5pecboRYg5+8ySAe0IjEnx1TX4v71cPnjHHrbSyyfZ7mB5gd1DIwfF32/jtYMkWYJj2GZWIJcsLSRP9B9+tKlhuz+FdtB7QAleooFUzDnTj54kXKOAO+6zXfx1tGAumbfW6bFesbuBeFPjiltCQEhYGUuzKJE5as+H6LIEO7dnX5ybpcPR0q0ytqzArLwY9Sv+IDHMQLI/xrxwDTILBVEpumAx5Wm2SsznMmQy//ttIq/F0GHaMsruf/FUDMtfjgsBQtUDCipI/gv8yg133SPfHXSpHACoPBNa/yxnqaQ7lcdXuXQyKNItH1rS4W/OXcrX4Lmxg== 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=mQ7M0/ctGuVXBVTAchiD0gXoJC/trBpmA6IrsKI0UUA=; b=K5dUBjk/qAvKCZRD1tbasKZApNd2vFx68X/2ih7NS+wYTzyuZmF2gWu6Atk7MQj6UfsY7i9883CaO9oODGjdhTo22kSq1/I+wohyeO58jTK5uiG6wFcv3p5vHcNsb8Rqq7hpqvyool65UgMMTaPwCdVK6RXv/sphf9cf0mEMN764HVbcJZvUJqclUfN0+o5VTREatDGruQUHde6eej/9S9rJOHD4eHIJYMMsFehwOHkXAZziUSTqeeSjNJB4o3ovMHuO6e9ko64FHO6Gj+PJYS4t0UWIWWRi1cimhL5qfLGmF1NAe3Fv6+u4OC2fVN3Vg4AbOMLF0H/+yWiLQ+ISbQ== 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=mQ7M0/ctGuVXBVTAchiD0gXoJC/trBpmA6IrsKI0UUA=; b=dwgHX0BthL8pgvJDMano9GUHNmBec1AXUEBokrW7D6AcGCDkwXRvK40Rnt1EDQOJ+0MnU+m453tjzyjowHLtUXiBqvJfELhwK7T4Q7uZtNZn42OwpVGHfGya0rPdQXtX/JIaW8oKrdpflK5jzL7wuGj6SnbmyKxLOjoAzK+1Rf4= Received: from DU7PR01CA0042.eurprd01.prod.exchangelabs.com (2603:10a6:10:50e::26) by PAWPR08MB8886.eurprd08.prod.outlook.com (2603:10a6:102:33a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.34; Mon, 5 Feb 2024 13:09:06 +0000 Received: from DU2PEPF00028D00.eurprd03.prod.outlook.com (2603:10a6:10:50e:cafe::7b) by DU7PR01CA0042.outlook.office365.com (2603:10a6:10:50e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.34 via Frontend Transport; Mon, 5 Feb 2024 13:09:05 +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 DU2PEPF00028D00.mail.protection.outlook.com (10.167.242.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Mon, 5 Feb 2024 13:09:05 +0000 Received: ("Tessian outbound c4f080b252bb:v228"); Mon, 05 Feb 2024 13:09:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d2739428d68f2f2e X-CR-MTA-TID: 64aa7808 Received: from 91e7ea1e4e48.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 11F499F5-075B-4B3C-94CA-0E892B960107.1; Mon, 05 Feb 2024 13:08:59 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 91e7ea1e4e48.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 05 Feb 2024 13:08:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fW9Sy2O3/ZhbXceMCnFR6yt+AIxuEwgeHCt84uKeceHgCETFtsZv/aC4CSjlmOOsUpakqQcZNZHNuHI8O5v6NMjb7yeXnv9aZQC11XrlRE09W/2GvMZ6096yVfkLlNbS5I/xnbJsIPvqzrjXVmKZ/o5jxhuEYZIjfPpap56idlBZfgAJl8NIUGS+FJlNU7/IjTRF+lmiSSPqQN6YoC6aPF1gqxLIgwUypXXcd++IdihnIZimxmMu3E9pGrg/LdwDXrnGbLDdwOWr1RSsXib/KBS8A/0WqlpK+5V5v2sHY04ho6UHiPMOWy6dDwkFzqyw9tpnSqcmNfxBhYvXdDJQaA== 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=mQ7M0/ctGuVXBVTAchiD0gXoJC/trBpmA6IrsKI0UUA=; b=YZWiY/Lxez1Ck+CiavEldM+RFTy9Cl231kDtB/H3gnLB3vfTLB6NURihksj/MfS3rhCUgt/j2KawCpWPJ1h6QalcQexH+DLfYPNx4+o6/JrUlJhKfY75/72St03Bzqogqbk8tdxGRDxniehhQUzM/Xp2M3IgVS1SZ7qaezT5y1xIGUv1XXpiAmyibbr1qXduVRTmVoSWarwz/Uh+8K/C7EEE/CHVCvd2ztRVmmbGka6ec+VubAiIq2BVu2vAeGYMz/LJ5e0QQqVPUhxayhEWcVCW8DhgnQWmIWGJnEdzRtHcBia+/E9EOIEwcn2tTxnnIB+BcgeNlWLUe5ZwsI5QHQ== 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=mQ7M0/ctGuVXBVTAchiD0gXoJC/trBpmA6IrsKI0UUA=; b=dwgHX0BthL8pgvJDMano9GUHNmBec1AXUEBokrW7D6AcGCDkwXRvK40Rnt1EDQOJ+0MnU+m453tjzyjowHLtUXiBqvJfELhwK7T4Q7uZtNZn42OwpVGHfGya0rPdQXtX/JIaW8oKrdpflK5jzL7wuGj6SnbmyKxLOjoAzK+1Rf4= 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 PAWPR08MB9856.eurprd08.prod.outlook.com (2603:10a6:102:2ea::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.34; Mon, 5 Feb 2024 13:08:57 +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.032; Mon, 5 Feb 2024 13:08:57 +0000 Date: Mon, 5 Feb 2024 13:08:53 +0000 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH]middle-end: fix ICE when moving statements to empty BB [PR113731] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LNXP265CA0002.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::14) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|PAWPR08MB9856:EE_|DU2PEPF00028D00:EE_|PAWPR08MB8886:EE_ X-MS-Office365-Filtering-Correlation-Id: 83d9cb7f-5770-444c-370b-08dc264ba1c1 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: hgAXwrGjpx1Hrbp4qUblc9cY7uWCn15cjmxXvCLIxu3WbqUigCbNYQldl3NEkKEgRxoAlwYHspZgSH1L6HFZChgKRtjcpiwJ7SEcpvUtN/CWaxz9xiLzyO4WdtWDUROa24tbFE+CYjjC6hOOO6D4Gcjj1XgVb6mKqsD5dhkkWL3LbACJAHZJPUKVOTxxwealZSEv2kMKsAWJ4ksR8SNhkw46RaBN5b6InLNpciezy7NXGWrUUFbCNIehmncyjzFNI5/Yk/FCKzzIcClW1EVm7UNAi1nQjb1kZljtjSM0Dg3ggLjB/rVjUS0go7yg9B8k09CJy0PdaPvCFw+My+/iAXkmaweyPwuAaLQgTC03hPNI2U8l2BN49RDwsE2e8jOQs6aaXPUoHyZDnPx/Vr/Kef4aS/XZ+5cNAypKk8wb/ZgHH/ZY8XBnwGn7PHxFINfuMJLiChsq95ifswpXsNBPoXrUdMeiFkggbtrwjQyLr31rXybPbhGs3qnvfz3VPlqKx+ywL6BYI40QxLeS3QM/ghXFNLUmWtv24Z0HOtyoM/csNGFgmJClBVysJnJA6J2+4T7NGm1oANKs4YQk6S/beNrEoON1wji4Jq7TugaioJV0wZSrKk73B1zEowvYBWzI 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)(39860400002)(136003)(346002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(41300700001)(8936002)(4326008)(8676002)(5660300002)(235185007)(44832011)(86362001)(6916009)(66946007)(6486002)(66476007)(316002)(66556008)(478600001)(36756003)(2906002)(38100700002)(2616005)(6512007)(33964004)(83380400001)(6666004)(6506007)(26005)(4743002)(44144004)(84970400001)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9856 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: DU2PEPF00028D00.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b368e4a7-227b-4503-7eb5-08dc264b9c56 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CkbJ7Jypdr1VgCO7+4fJsl5C52F2gSjXUqGOmF1DJNQOIKWgZgViKYuD+W50+8kZwWrNf4s1xikSqIQ0Q15bsPFsunPcX8JiHS1mrLD32JF5zfUBZm3cuZh+Vjf2eParBx64vxQlqumhgCox+xsgUQChqAR3bNcskpQm3rO6zo/xRc4BaVH4JDFsoTB0jqSbmO+acBTgUpRjBWwaBzWmoyx3kqo8Xfw/JMCVCNiYFt94TfRJXPgtluw5c8GWdW76v7zLbdfnE4ifq6Po9K5gPvow3JPiBg4nFr+y2m/JqjvQWfgZcG2J6EkynV3BosVQMtsfOHIm9g6DC/PzPCvf0Z5YIxhkRiQlwv0jsAF2SkJ82UTwdGKs9OPGDWv9/BOlVeYzTBJUAiyNXF0kUB88qhJEXQuKD3X5L1WH5X72SLBApjFg0K8gOCAxeQOR3K4MptmaIMc/fEhhQedjBu0FKMvNwoQo2pBf6Stw0ojM7G3NEsyBWEMmzNnMBOgQzIWZ1zqZL6aMb/ikf0gsTTUDawHx+ljNzPgZiCYuI6951ehU4KAPo/S+EjAM6dodmz6HLg4zP+/ic1bu8pxjaeDCXPk2ZbZrmee4sXP64ZZXaF4966kl077cphFWGHT1eniBlsrDEj2m3AqiOWi/zbhYumnr7bXcmfBaHjjTHPdNCF758qhdAMr2DAIoW2JdCIBEyRuxfTY2sk4u8xrynzw5c2JsuzeJoRnt+mTP/ZI2eRXqWNjzrixbC5lkW7pBgi7l8sTWJrC6c9QrYCcpY+K0qw== 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)(346002)(39860400002)(376002)(396003)(230922051799003)(1800799012)(451199024)(82310400011)(186009)(64100799003)(36840700001)(46966006)(40470700004)(86362001)(47076005)(83380400001)(26005)(81166007)(107886003)(478600001)(336012)(4743002)(356005)(82740400003)(36860700001)(2616005)(8936002)(4326008)(8676002)(70586007)(70206006)(6916009)(5660300002)(2906002)(316002)(6506007)(6666004)(44832011)(235185007)(6512007)(44144004)(6486002)(33964004)(36756003)(41300700001)(84970400001)(40480700001)(40460700003)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2024 13:09:05.7964 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83d9cb7f-5770-444c-370b-08dc264ba1c1 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: DU2PEPF00028D00.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB8886 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+patchwork=sourceware.org@gcc.gnu.org Hi All, We use gsi_move_before (&stmt_gsi, &dest_gsi); to request that the new statement be placed before any other statement. Typically this then moves the current pointer to be after the statement we just inserted. However it looks like when the BB is empty, this does not happen and the CUR pointer stays NULL. There's a comment in the source of gsi_insert_before that explains: /* If CUR is NULL, we link at the end of the sequence (this case happens so it adds it to the end instead of start like you asked. This means that in this case there's nothing to move and so we shouldn't move the pointer if we're already at the HEAD. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/113731 * tree-vect-loop.cc (move_early_exit_stmts): Conditionally move pointer. gcc/testsuite/ChangeLog: PR tree-optimization/113731 * gcc.dg/vect/vect-early-break_111-pr113731.c: New test. --- inline copy of patch -- diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c new file mode 100644 index 0000000000000000000000000000000000000000..2d6db91df97625a7f11609d034e89af0461129b2 --- diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c new file mode 100644 index 0000000000000000000000000000000000000000..2d6db91df97625a7f11609d034e89af0461129b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +char* inet_net_pton_ipv4_bits; +char inet_net_pton_ipv4_odst; +void __errno_location(); +void inet_net_pton_ipv4(); +void inet_net_pton() { inet_net_pton_ipv4(); } +void inet_net_pton_ipv4(char *dst, int size) { + while ((inet_net_pton_ipv4_bits > dst) & inet_net_pton_ipv4_odst) { + if (size-- <= 0) + goto emsgsize; + *dst++ = '\0'; + } +emsgsize: + __errno_location(); +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 30b90d99925bea74caf14833d8ab1695607d0fe9..e2587315020a35a7d4ebd3e7a9842caa36bb5d3c 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -11801,7 +11801,8 @@ move_early_exit_stmts (loop_vec_info loop_vinfo) gimple_stmt_iterator stmt_gsi = gsi_for_stmt (stmt); gsi_move_before (&stmt_gsi, &dest_gsi); - gsi_prev (&dest_gsi); + if (!gsi_end_p (dest_gsi)) + gsi_prev (&dest_gsi); } /* Update all the stmts with their new reaching VUSES. */ --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_111-pr113731.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +char* inet_net_pton_ipv4_bits; +char inet_net_pton_ipv4_odst; +void __errno_location(); +void inet_net_pton_ipv4(); +void inet_net_pton() { inet_net_pton_ipv4(); } +void inet_net_pton_ipv4(char *dst, int size) { + while ((inet_net_pton_ipv4_bits > dst) & inet_net_pton_ipv4_odst) { + if (size-- <= 0) + goto emsgsize; + *dst++ = '\0'; + } +emsgsize: + __errno_location(); +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 30b90d99925bea74caf14833d8ab1695607d0fe9..e2587315020a35a7d4ebd3e7a9842caa36bb5d3c 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -11801,7 +11801,8 @@ move_early_exit_stmts (loop_vec_info loop_vinfo) gimple_stmt_iterator stmt_gsi = gsi_for_stmt (stmt); gsi_move_before (&stmt_gsi, &dest_gsi); - gsi_prev (&dest_gsi); + if (!gsi_end_p (dest_gsi)) + gsi_prev (&dest_gsi); } /* Update all the stmts with their new reaching VUSES. */