From patchwork Tue Feb 13 10:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1898168 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=WBq6Vaih; 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=WBq6Vaih; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4TYyYq5FSfz23hT for ; Tue, 13 Feb 2024 21:41:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 933B9385842C for ; Tue, 13 Feb 2024 10:41:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2081.outbound.protection.outlook.com [40.107.6.81]) by sourceware.org (Postfix) with ESMTPS id 90E6F3858C3A for ; Tue, 13 Feb 2024 10:41:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90E6F3858C3A 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 90E6F3858C3A Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.6.81 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707820889; cv=pass; b=ZU+oCXZhzjCnfG7/NCbIJyr7Umadkz/NF0DTV39eRvesf3jFHqqK7vkoQTFJbyI92sl3QdrpncF6/k0arcekzOMcd1Fv0i0H0C1NagZMXDJSty2Yw/SPzVDYHLcv8UnLaV5IoHrSzRXdzV2mw5hBaO2Nbjyj4mzHINBW2vZivxY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1707820889; c=relaxed/simple; bh=PQVFJ1zWUKrLmGkY9+DNhTS6mRe/HWmVVgMmYhKCNYM=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=EhRY5vXruBRRW3cGhuJ8rIZKTmyQAh0Jb2lv52GxMP6PChr6caqrECn0tNhDPRKN/S0gRInB5PIjxWi+qfkynOnqlClbX09qcs8bspv83EWGaz8jDqx0ruOqeoTb2pjoPPiYnt/K9QOmBHxYu9Mu9N4ry2tmjzJst1v/BPq+/N8= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=HfU8b+MJR4SerYt3q5o1SrZoCB9g0pV27fOqxW2Uv6S+HO/8uwogBwy20UFIp2UpLo9UMvJMmU0mecuP95TCQyGua5W+RiI54Myw7HXHBocbiGSr21mdBgGrUvy9Z1XVM/7clLaGOtFxjKZ73K4cw1Og+TTfVRF6b7Sn3LrA+wj3ld4tv9a2/lbeDeXCp2HTJV3xv8rFRxTkU4mHLdc9vqL0TqIKN7wOpa8YAOMyv6f3L6GNPelGzJmEZEGqMvtVxd6wW1KX/eiJ6mx5XWWXrFkVo4Or1/enKNhMvzHTdrMTGYaCN61KM5Yeoaab/BdqtzMrHICUfEP446Im6Zx1Sw== 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=oCossSqMcJN0Zg2zJER78T1/btrUeyVs71ALP3Ee6Pk=; b=ApySt9pWvD9KVRfFfzLOG2BM/6UkHsIObHqs8f+29xTvKQC6+k1h1XDM79veHnbu+fEgTynEo3RISnOxKVPCIhtcpo/0FsY3+2q8ygO2nhhhE4V0cnUmLK7Gy4KkMTksXObkmlZFMA+ODq6FehbEDQ3zSsRsRggeo6th3F/HTfLCy8IRwcmdePZwXpDgkKXw+L99DS8lM0gGjEOx7j7NiMSgZPSipwRLZPT6iTg791eTLwTUr+NYzUvVS5LCoOp7m8kVskx0Bt60S742AWU2MB6c8U88i7ILACz+HgMThTzIDurA8Z5olDLdrba3oYcqR0FE3AfHO9LECdX9t+WDsQ== 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=oCossSqMcJN0Zg2zJER78T1/btrUeyVs71ALP3Ee6Pk=; b=WBq6Vaih3nIo3ju4/d+3Niy8Er0HVf5jFst0TrKH3nnnHt0pFcsHjVZYAGFpaZ0JhyNUdCK55ODouB0UT5oMJu9+ApfUOsv5bstj4exjgKJFDvajffN2yUzFnpmY310axA7A0PkwiJrRq1EuSH0Xjmyn/NLWhqNDWyrpGuGXz80= Received: from AS9PR05CA0324.eurprd05.prod.outlook.com (2603:10a6:20b:491::18) by PR3PR08MB5594.eurprd08.prod.outlook.com (2603:10a6:102:8b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.35; Tue, 13 Feb 2024 10:41:23 +0000 Received: from AM3PEPF00009B9B.eurprd04.prod.outlook.com (2603:10a6:20b:491:cafe::7b) by AS9PR05CA0324.outlook.office365.com (2603:10a6:20b:491::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.39 via Frontend Transport; Tue, 13 Feb 2024 10:41:22 +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 AM3PEPF00009B9B.mail.protection.outlook.com (10.167.16.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Tue, 13 Feb 2024 10:41:22 +0000 Received: ("Tessian outbound 67699c3f02bc:v228"); Tue, 13 Feb 2024 10:41:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2733d4ad56c5be06 X-CR-MTA-TID: 64aa7808 Received: from f3eb3c20731d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C2BC14FB-9234-4B14-8DD5-AF61429DF49E.1; Tue, 13 Feb 2024 10:41:15 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f3eb3c20731d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 13 Feb 2024 10:41:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iRoS7zHmF6957tsdmEW3orjRv1vCxlN/Xfk1Nz/rvGd0hKstzMPgfHBHRIqrRaZOFLaF4RB+3SeVcR8sixxA+Mr8ueBN4oKQnoSWS40X09Dgi9OXqLRKfopjFGHvXYpEuVvOddjcxsJ5Ea1mvn3Lg40zArO9EDOsJevrGl4r7aWplM+mSeJB/Cjd0HF+H7I6s8yEuhCFSfe6qlAdsiVVUozPs0AdQHxb+bE6m/2Th7Ofwj1jC650QKkyTkpRgnXUU8KgYNId5Ti++RPcPgf98XJjADahOAQ3iHgC3b3OeoS/orovulBXvUkI6SNFrLqAa1yh/PE3U8lqpwsZiI78UA== 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=oCossSqMcJN0Zg2zJER78T1/btrUeyVs71ALP3Ee6Pk=; b=euybfnvkwb3h/wf8ZZ6YA6J6slVqxqsnLjpeJWqRlatV53REmqXZn2/iZkj5VcTQQs7IZSArVa7CaN0aFNMpzd0HHoR3aasi+WA51QoDVpm2gq4cS9C35ISD7IG6b90xXNXFS4nPDbMehIlweEoGSfvPg+6+4jcDJq4P1aTJLk/Vua8RGfA5A52zojMV6y2716gKde/YMTjq33gTsVuA3uc6HCy9yOi+hrjuiutcbBvvq5GzB4CDjJB43SbnBSaK9NFkMN97+0sXp1WQdI0fAgheAmQ8zPfJoj+I/ebr+2GJakJeToci5+va1Hd9IIoISqHzGseyREAaLctIbTgf0w== 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=oCossSqMcJN0Zg2zJER78T1/btrUeyVs71ALP3Ee6Pk=; b=WBq6Vaih3nIo3ju4/d+3Niy8Er0HVf5jFst0TrKH3nnnHt0pFcsHjVZYAGFpaZ0JhyNUdCK55ODouB0UT5oMJu9+ApfUOsv5bstj4exjgKJFDvajffN2yUzFnpmY310axA7A0PkwiJrRq1EuSH0Xjmyn/NLWhqNDWyrpGuGXz80= 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 DBAPR08MB5702.eurprd08.prod.outlook.com (2603:10a6:10:1a3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.39; Tue, 13 Feb 2024 10:41:14 +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.7270.033; Tue, 13 Feb 2024 10:41:14 +0000 Date: Tue, 13 Feb 2024 10:41:11 +0000 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH]middle-end: update vector loop upper bounds when early break vect [PR113734] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LNXP265CA0087.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::27) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|DBAPR08MB5702:EE_|AM3PEPF00009B9B:EE_|PR3PR08MB5594:EE_ X-MS-Office365-Filtering-Correlation-Id: 0067f55f-5455-4495-c742-08dc2c80525f 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: N5VTz074rxmmKUO8slvKoZjYTYnzgZXRLUruL2DN+2QjpiIrPRkD3ExXfOCeQhxj+NbjVrNXEuRmEv7LgX7JsOJyvhpSypsaTDB8QSSZPRVHvTrWsVhvLjDEj3HUDKtKUmie4guXEgGdHHb85Asb5exOUEVS/Joh2mi/HDa33sHv4Nry++XLvnrN4BeYoJ0HrkxSgIeCnWu5ucJrE3HtaIgzKir4/IFaSBF9jnc+pK17RUnrOT/H1zNh2F+NH/rwZQshryVwepz/ogJ47+xpNnulK5nOk1V/eJ8YxpMbfZdW/fNcK8np8rwwtq8Xb/ky2WZZFrb2NAuNbU8rKttFCTwwyFFOHDYPtxwSDVGZIjnmUZwma/N95DanXrn5j0bElGAD2/L5G1St4sKLNhHACbxDYpf6piw9i3AviBIseSnJ68HijqtQEvKgHdIJgIEHl+0nnlLc9n/ClcrXYH76oAlW9jQLQJvX3NAJhDOMx0Fx9eEmjtqfUi36jSI5JdlTn+2kCSgwlRU05jHtt7wZdcqBEke3kkuoKxnlZepdQVo= 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)(376002)(136003)(366004)(346002)(396003)(39860400002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(36756003)(86362001)(6512007)(6506007)(33964004)(478600001)(6486002)(44144004)(2616005)(41300700001)(26005)(66946007)(66556008)(5660300002)(8936002)(8676002)(4326008)(6916009)(6666004)(38100700002)(316002)(83380400001)(4743002)(66476007)(2906002)(44832011)(84970400001)(15650500001)(235185007); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5702 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: AM3PEPF00009B9B.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c7f9b4b6-e799-46e3-9be7-08dc2c804cfc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lzp/t7wwLzJpuZLHe3fgAXVFpMIPNnryk9Xn6CYrfIMNfrU8J+zLl9gAwqNzJ9EFuGXhVXfiRWYYwd4ae6gXSpDZv24Lp32YMU9Av07jNQ+uSCnNIlQgIl/BGpFD0SEBXTHZCMR+w9tG9V60BgBab5WaiECRnfZzrPnvT6Be7rCsnJhCKUw/fnu7aWVpHcNzY+Ekh+nFTKbNlbYIv9bMP3wRcvTkvwRGuDCf6ElChYA1sOfBtY0/QNsqeqlYyB+NZZSCS8O9cD9/hAmncw81f8fIQ7G+gkbkBjx0dtTvsSEqd90KscTT7a+3LF02LHUrjGjWh9kpU4rK0I7OMBVcL4lf5H2BZz/+c4geOwmdVKEPMRovrXPwGPk+MbbDdL+sMz8B6CojkY5z2zYzLo6OqA0Kb62e19SoZbGZBCb48nvDUzXNz59yRXQOXTO43smFmKyZZloigDvA9B2h2uWVZdA4l0aAhJxb1IJNF0WiLIzZy06xGc7xnbwUVty0UbWuwSZwkjSwfAUIqURntSled7FEv+wbzxJGXWv0n0cQeCM6JI3jlmzYGUt215g4Y2C7Y/3ndAKEOIBTaniqJGzSig== 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)(376002)(346002)(136003)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(82310400011)(40470700004)(46966006)(36840700001)(6486002)(478600001)(84970400001)(6512007)(41300700001)(4326008)(8676002)(8936002)(15650500001)(5660300002)(44832011)(2906002)(235185007)(44144004)(6506007)(6916009)(6666004)(70206006)(316002)(33964004)(70586007)(4743002)(2616005)(81166007)(336012)(26005)(86362001)(356005)(83380400001)(82740400003)(107886003)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 10:41:22.8743 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0067f55f-5455-4495-c742-08dc2c80525f 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: AM3PEPF00009B9B.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5594 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, When doing early break vectorization we should treat the final iteration as possibly being partial. This so that when we calculate the vector loop upper bounds we take into account that final iteration could have done some work. The attached testcase shows that if we don't then cunroll may unroll the loop an if the upper bound is wrong we lose a vector iteration. This is similar to how we adjust the scalar loop bounds for the PEELED case. 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/113734 * tree-vect-loop.cc (vect_transform_loop): Treat the final iteration of an early break loop as partial. gcc/testsuite/ChangeLog: PR tree-optimization/113734 * gcc.dg/vect/vect-early-break_117-pr113734.c: New test. --- inline copy of patch -- diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_117-pr113734.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_117-pr113734.c new file mode 100644 index 0000000000000000000000000000000000000000..36ae09483dfd426f977a3d92cf24a78d76de6961 --- diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_117-pr113734.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_117-pr113734.c new file mode 100644 index 0000000000000000000000000000000000000000..36ae09483dfd426f977a3d92cf24a78d76de6961 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_117-pr113734.c @@ -0,0 +1,37 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#define N 306 +#define NEEDLE 136 + +int table[N]; + +__attribute__ ((noipa)) +int foo (int i, unsigned short parse_tables_n) +{ + parse_tables_n >>= 9; + parse_tables_n += 11; + while (i < N && parse_tables_n--) + table[i++] = 0; + + return table[NEEDLE]; +} + +int main () +{ + check_vect (); + + for (int j = 0; j < N; j++) + table[j] = -1; + + if (foo (0, 0xFFFF) != 0) + __builtin_abort (); + + return 0; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 854e9d78bc71721e6559a6bc5dff78c813603a78..0b1656fef2fed83f30295846c382ad9fb318454a 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -12171,7 +12171,8 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) /* True if the final iteration might not handle a full vector's worth of scalar iterations. */ bool final_iter_may_be_partial - = LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo); + = LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo) + || LOOP_VINFO_EARLY_BREAKS (loop_vinfo); /* The minimum number of iterations performed by the epilogue. This is 1 when peeling for gaps because we always need a final scalar iteration. */ --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_117-pr113734.c @@ -0,0 +1,37 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#define N 306 +#define NEEDLE 136 + +int table[N]; + +__attribute__ ((noipa)) +int foo (int i, unsigned short parse_tables_n) +{ + parse_tables_n >>= 9; + parse_tables_n += 11; + while (i < N && parse_tables_n--) + table[i++] = 0; + + return table[NEEDLE]; +} + +int main () +{ + check_vect (); + + for (int j = 0; j < N; j++) + table[j] = -1; + + if (foo (0, 0xFFFF) != 0) + __builtin_abort (); + + return 0; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 854e9d78bc71721e6559a6bc5dff78c813603a78..0b1656fef2fed83f30295846c382ad9fb318454a 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -12171,7 +12171,8 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) /* True if the final iteration might not handle a full vector's worth of scalar iterations. */ bool final_iter_may_be_partial - = LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo); + = LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo) + || LOOP_VINFO_EARLY_BREAKS (loop_vinfo); /* The minimum number of iterations performed by the epilogue. This is 1 when peeling for gaps because we always need a final scalar iteration. */