From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2051.outbound.protection.outlook.com [40.107.14.51]) by sourceware.org (Postfix) with ESMTPS id D221D3858D32 for ; Wed, 15 Nov 2023 14:14:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D221D3858D32 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 D221D3858D32 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.14.51 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1700057693; cv=pass; b=ULVS/hbfANMQDZS4HQL7TneE3dY9q1WQoAXl/SPgGNUIK1gUhR9AufVHgH5bATEAM8sFD5xS9YQT9Qj6nJD6SfvfNMVhYP5cj59ITjzo4BFIndHGEA8uccAEbypTrxVi1tX0sQTWvkey19Pjef/U1FQvBH1PRw72TztzMV6gHMo= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1700057693; c=relaxed/simple; bh=vR7JWIRt60g9H/7VIxiQq/s0M8YOclx9QRiNvjF7hMQ=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=jn3WzmdrpQaZJdG5xK9ctYvPU7TclrwpK9TBO7tfO62E5AiNmB543WjKZWAzB6Y3VUGSelWIGfiXDoTe6CteTZPOWYHg6lNbVOxbqE46tKHr3Hos20C4SY0FYlFU3R7jnGD/vpdwowUT1NLsP8UFr0V/WTnSzRPoLEJDh+PDLoc= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=auRW4WWkeFenLTBOEU0EaKjrGM+rVPOgkogELdE+4iKoS94ySyuCk293/5Zuzj8KUVMeW5hU5ken7IlPArvAGxK4OHZRreZrLKzo//d6d+aLtG8k3uhJ66nvtt6lXdm36NQX0a09X8f7Zicjv6ydW2DI8hjgSGaCRc4qHu7nj2+zbTcjYO/WQv9dc4ujWli6j18f85bRlp0QvlOEC7DHuwc3nk3PvhJHTZ0JzcJWs+SV3+ZrAAvGSfOhXJi8or6TmCKrd6Ob6/lxF65gtLFRewysZYNl2owhHH9CrRjBXgB50CQHRWdTzgfrv3za9KOXQ9Qfg2XFzYMkT3tz2m24uA== 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=iDalQiE3XTkqzuwNdEZ3MhnMSGop9Bieky6AEb4yFMA=; b=Vb69HrKNmNiVDY9jpLh5zBg3dknkPr5cHue6YI49YBz0NpXlCzl6CKaxJOw0bhdE0ceeUDOUuEHb8zi1HU94WLvuD4LzRujKUSslYI8irmZW5HoRt0MtkfMd+86PSM2Iyqn/Mg0tQMpjlnHsMr7VxkYUzciGFb7W1+bgS9L51ciQdLT1XGTDcSMyu0PMr4R6dHkJ73/aHYsFPxpiFBu0YA7raVeYKplQNBvkOLfsj3Jm7no2PrVHlmDFzbvL6U0XC+0FWl7V3VfpW9dVDRI/+rGdJ5aicLHWXmr5Xe/uY05EiF3Zttd3ZYiZpOK58RUJ22ExjrHhwVTo2wvRx62dHg== 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=iDalQiE3XTkqzuwNdEZ3MhnMSGop9Bieky6AEb4yFMA=; b=NNiE9XGWid/Z0DfW1eH5yGDB6G+NS5fd2Kb/2cssak01jdrGQrVkrMOTJRkqyLvXV4U8j1u6UmxnTqg1Y8rVO+5XaGpBVwJ+t2bWHPXc7pOnTyl+mwB0V8IxwzDC2/tPgrNDI+/CiQyB8V7jcC1V0UItpTubpVmfKzbiWcpGKDA= Received: from DUZPR01CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::11) by AS2PR08MB10154.eurprd08.prod.outlook.com (2603:10a6:20b:62e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.18; Wed, 15 Nov 2023 14:14:47 +0000 Received: from DB5PEPF00014B98.eurprd02.prod.outlook.com (2603:10a6:10:469:cafe::42) by DUZPR01CA0053.outlook.office365.com (2603:10a6:10:469::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31 via Frontend Transport; Wed, 15 Nov 2023 14:14:47 +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 DB5PEPF00014B98.mail.protection.outlook.com (10.167.8.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.19 via Frontend Transport; Wed, 15 Nov 2023 14:14:47 +0000 Received: ("Tessian outbound 8289ea11ec17:v228"); Wed, 15 Nov 2023 14:14:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 64f7f88e80a00960 X-CR-MTA-TID: 64aa7808 Received: from 43b1ab67eb7d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8992F433-C7F3-4D0A-A5DC-0E9A2D46A428.1; Wed, 15 Nov 2023 14:14:41 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 43b1ab67eb7d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 15 Nov 2023 14:14:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iLtB9YqcYw1uLWpMsQqTuNv3hW8firbobmJkSIkDYeIVC0fUsuBtgrQunvvb3FmbhBvALn3HAb8brx14PBzCCx5X2FTmkH9uVp5TAoyw9BZT2YnKJYlLcusIpj3ROg4FCAiwKLkzIyuYSjv+om0WdK5LG6O79C5hiNaDhAG1cW0MhWYn/KqqjJin8UM4HLW6gk+TAId4F22nx3wnjTyYjR0EYYpVo78AsVdNPuT+tHw6nAKvOAu+uP1Xs6bJsmgYrUH69mM7syIrqL2zy3LB3e9kzjZypscOpEoIiDVWZKDykmA8mWk77MWdiFDjhpx7ttvxFwUaVlxt9aGG2sCQow== 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=iDalQiE3XTkqzuwNdEZ3MhnMSGop9Bieky6AEb4yFMA=; b=GN787QEnpoVbHfMBFuPCw5ZNGDFDQ0B1Id20pcAVd8jTwzMGq+Z4lKD2mO+bWp5H3CYYUuffNrCwgVLJhNXRso5mwf7qPUTfb0HnR2rBKdIIUzQQvoFT7UBS44TjX6p/spd0e6bAk6zcO+rY70p7rA8kOb0FZI5ig5uv/Bn8SrI6/0/dh0B7AHUyMX20HwT5yP48voyOr0FrJUQTl6wupYv7NIAZyiYC6gVsdW4em9hscWrqLddOM6IMvd15ib9VP58mlJ8Sqv/vfSVTTYzqo3oNYHGwyburNh56b8lcMptLdGK2QX1uF6FUzvexDjYwPtNS9duEhbZj8RtC8xXhbw== 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=iDalQiE3XTkqzuwNdEZ3MhnMSGop9Bieky6AEb4yFMA=; b=NNiE9XGWid/Z0DfW1eH5yGDB6G+NS5fd2Kb/2cssak01jdrGQrVkrMOTJRkqyLvXV4U8j1u6UmxnTqg1Y8rVO+5XaGpBVwJ+t2bWHPXc7pOnTyl+mwB0V8IxwzDC2/tPgrNDI+/CiQyB8V7jcC1V0UItpTubpVmfKzbiWcpGKDA= Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by DU0PR08MB8187.eurprd08.prod.outlook.com (2603:10a6:10:3ee::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.18; Wed, 15 Nov 2023 14:14:38 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3%6]) with mapi id 15.20.6977.029; Wed, 15 Nov 2023 14:14:38 +0000 From: Tamar Christina To: Richard Biener CC: "gcc-patches@gcc.gnu.org" , nd , "jlaw@ventanamicro.com" Subject: RE: [PATCH 7/21]middle-end: update IV update code to support early breaks and arbitrary exits Thread-Topic: [PATCH 7/21]middle-end: update IV update code to support early breaks and arbitrary exits Thread-Index: AQHaEIRUWLSyh++pSEG+iB4lA+c+BLB6jLQwgADZ7QCAAAD4UIAABQiAgAALGkA= Date: Wed, 15 Nov 2023 14:14:38 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: VI1PR08MB5325:EE_|DU0PR08MB8187:EE_|DB5PEPF00014B98:EE_|AS2PR08MB10154:EE_ X-MS-Office365-Filtering-Correlation-Id: dad2fef6-7370-4350-ae20-08dbe5e53955 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: PD0A0s1ot8vWVtKrQ+Jhv2kJIbuzel+CGr95UGj0jEJ5OqBB3fnS8+HDaewarHCmmVdREwLnr8hXZDd+wFiL73o0mDUWXDjZ7xtCXLTDxKP3MgpOzCxGyvLHnJCcthUaAXb+ex+vpCUZRUAgwvBoWPWPj0o0r7BMeoXXmmFWVfo92A/aurgCyg1qwi/ZcJ1ER66/Mr5msIc/B3u4ONOTO9DI+b6mgahq3JsAvbVqvSz0XYuEnSanNQAaPMddCUxxPOLsjSH3aQZyceSpbmbAa3p3O2Eq4+LosfvujekFKUkws+EZd8cQ81XKDtrHGpn9MowfATEtXrVBTpVsiwOV7DZ17JEKSf7cJVINmGfM5CmFEEHmj4/IvdvQSqiAAkMklS5UKY20RHdBsBclAAVs9dP2qcMWqhSrbNcqYzfyjAmjRx2q2Be1lIskuFRhyKxXMsUNB/FsSYm/Qydo5kxTdPUYTj8KHn88v/oDSRhm2H3Z8d072GvSLbTJxSr5nxsKADxpwoegtMaj2JulvjilQZF82RwU62/pizicI9T23/NFZlwbQs07pU8m5tpI41kJotLGCKWqG4FcXMqSvoMSAC27jjgHE6xsxjp4qWPd/Og= 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)(366004)(396003)(376002)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(9686003)(316002)(66476007)(66556008)(66446008)(64756008)(4326008)(8676002)(54906003)(8936002)(66946007)(76116006)(6916009)(966005)(478600001)(38100700002)(52536014)(53546011)(6506007)(7696005)(15650500001)(5660300002)(71200400001)(55016003)(30864003)(26005)(2906002)(83380400001)(66899024)(41300700001)(122000001)(86362001)(33656002)(38070700009);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8187 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: DB5PEPF00014B98.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 88981e68-2c4e-41a8-1476-08dbe5e533ea X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mM0ZIswZljMYZwnR9IB4Rkdymi4nCiq8OwDkk+y8RDhbkk8WZ4eoKrPzut3gzIdGI4kQxqPlhAGbXYqU95x8HsvIVTy+gb5IwRoWTbGxb9T93JFAwVcuQh5dAsYexkHsMQWfLlNB6rYWVaSqdvibngiAsIesc3gj5T2V6z+USDKv/Erx+Oua8UGeiKCsgx+6LKg7yDQLbVdZykZFEruEeSU/sJ7ILYtRM7HV4FMOFiLS1aiTWXgypoydFSapx4q01OaRClWGE8tYIP0KLuE6EjQQscxiSGD2Z8OqiVNlskGkRqHpnwwyUu+7gnQFquET8xBmMJ2BPF2j9/eJvwQPVR76udJMF5dZWCYZ++/ikqlQa+R1dagEpcs6emc7skA3SiQj5FXW+BAZlKMW1jLx2niGmVHPYRoZ9/6GIK5LVjEbcC1HaxyUUBsjMqNa9Y2r/qml4Wjf9vB+J/iNbIiil4ylawnAtIP50poJV20Gc/lSUjbOpENvyuy1OKF8ubioMSJ3oa2K28lOMwRvWmiDv/8JdoY28P/JcOfvQyYzoZBdlYeWmEb3q8DghQ5gYEdoLAwYN0uLwhlbbZ03lYZJbXsFcRvHiRzy5lhAEtC65tGm2BTmHvFPvkd7t6frMIlidewLQ4evPxkz6uI6wOVHy3sMZdwfqoUfJb8S1KELvUWVGMvXccjzhrb6VxiUGHW58Yn3kBf/3Xj/0PpxMdJe7oEIYXXe57yX3h7lnMhZsZY= 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)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(36840700001)(46966006)(40470700004)(40480700001)(83380400001)(9686003)(15650500001)(26005)(478600001)(30864003)(52536014)(6506007)(7696005)(5660300002)(107886003)(336012)(55016003)(2906002)(47076005)(8936002)(8676002)(4326008)(6862004)(53546011)(316002)(36860700001)(41300700001)(66899024)(40460700003)(356005)(81166007)(966005)(82740400003)(70206006)(54906003)(70586007)(33656002)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2023 14:14:47.5245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dad2fef6-7370-4350-ae20-08dbe5e53955 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: DB5PEPF00014B98.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10154 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,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 List-Id: > -----Original Message----- > From: Richard Biener > Sent: Wednesday, November 15, 2023 1:23 PM > To: Tamar Christina > Cc: gcc-patches@gcc.gnu.org; nd ; jlaw@ventanamicro.com > Subject: RE: [PATCH 7/21]middle-end: update IV update code to support ear= ly > breaks and arbitrary exits >=20 > On Wed, 15 Nov 2023, Tamar Christina wrote: >=20 > > > -----Original Message----- > > > From: Richard Biener > > > Sent: Wednesday, November 15, 2023 1:01 PM > > > To: Tamar Christina > > > Cc: gcc-patches@gcc.gnu.org; nd ; > jlaw@ventanamicro.com > > > Subject: RE: [PATCH 7/21]middle-end: update IV update code to > > > support early breaks and arbitrary exits > > > > > > On Wed, 15 Nov 2023, Tamar Christina wrote: > > > > > > > Patch updated to latest trunk: > > > > > > > > Hi All, > > > > > > > > This changes the PHI node updates to support early breaks. > > > > It has to support both the case where the loop's exit matches the > > > > normal loop exit and one where the early exit is "inverted", i.e. > > > > it's an early > > > exit edge. > > > > > > > > In the latter case we must always restart the loop for VF iteration= s. > > > > For an early exit the reason is obvious, but there are cases where > > > > the "normal" exit is located before the early one. This exit then > > > > does a check on ivtmp resulting in us leaving the loop since it thi= nks we're > done. > > > > > > > > In these case we may still have side-effects to perform so we also > > > > go to the scalar loop. > > > > > > > > For the "normal" exit niters has already been adjusted for > > > > peeling, for the early exits we must find out how many iterations > > > > we actually did. So we have to recalculate the new position for ea= ch exit. > > > > > > > > Thanks, > > > > Tamar > > > > > > > > gcc/ChangeLog: > > > > > > > > * tree-vect-loop-manip.cc (vect_set_loop_condition_normal): Hide > > > unused. > > > > (vect_update_ivs_after_vectorizer): Support early break. > > > > (vect_do_peeling): Use it. > > > > > > > > --- inline copy of patch --- > > > > > > > > diff --git a/gcc/tree-vect-loop-manip.cc > > > > b/gcc/tree-vect-loop-manip.cc index > > > > > > > > d3fa8699271c4d7f404d648a38a95beabeabc99a..e1d210ab4617c894dab3 > > > d2654cf1 > > > > c842baac58f5 100644 > > > > --- a/gcc/tree-vect-loop-manip.cc > > > > +++ b/gcc/tree-vect-loop-manip.cc > > > > @@ -1200,7 +1200,7 @@ > > > > vect_set_loop_condition_partial_vectors_avx512 > > > (class loop *loop, > > > > loop handles exactly VF scalars per iteration. */ > > > > > > > > static gcond * > > > > -vect_set_loop_condition_normal (loop_vec_info loop_vinfo, edge > > > > exit_edge, > > > > +vect_set_loop_condition_normal (loop_vec_info /* loop_vinfo */, > > > > +edge exit_edge, > > > > class loop *loop, tree niters, tree step, > > > > tree final_iv, bool niters_maybe_zero, > > > > gimple_stmt_iterator loop_cond_gsi) @@ - > > > 1412,7 +1412,7 @@ > > > > vect_set_loop_condition (class loop *loop, edge loop_e, > > > > loop_vec_info > > > loop_vinfo > > > > When this happens we need to flip the understanding of main and > other > > > > exits by peeling and IV updates. */ > > > > > > > > -bool inline > > > > +bool > > > > vect_is_loop_exit_latch_pred (edge loop_exit, class loop *loop) { > > > > return single_pred (loop->latch) =3D=3D loop_exit->src; @@ -2142= ,6 > > > > +2142,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo) > > > > Input: > > > > - LOOP - a loop that is going to be vectorized. The last few = iterations > > > > of LOOP were peeled. > > > > + - VF - The chosen vectorization factor for LOOP. > > > > - NITERS - the number of iterations that LOOP executes (befor= e it is > > > > vectorized). i.e, the number of times the ivs shou= ld be bumped. > > > > - UPDATE_E - a successor edge of LOOP->exit that is on the > > > > (only) path > > > > > > the comment on this is now a bit misleading, can you try to update > > > it and/or move the comment bits to the docs on EARLY_EXIT? > > > > > > > @@ -2152,6 +2153,9 @@ vect_can_advance_ivs_p (loop_vec_info > > > loop_vinfo) > > > > The phi args associated with the edge UPDATE_E i= n the bb > > > > UPDATE_E->dest are updated accordingly. > > > > > > > > + - restart_loop - Indicates whether the scalar loop needs to > > > > + restart the > > > > > > params are ALL_CAPS > > > > > > > + iteration count where the vector loop began. > > > > + > > > > Assumption 1: Like the rest of the vectorizer, this function = assumes > > > > a single loop exit that has a single predecessor. > > > > > > > > @@ -2169,18 +2173,22 @@ vect_can_advance_ivs_p (loop_vec_info > > > loop_vinfo) > > > > */ > > > > > > > > static void > > > > -vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, > > > > - tree niters, edge update_e) > > > > +vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, > > > > +poly_uint64 vf, > > > > > > LOOP_VINFO_VECT_FACTOR? > > > > > > > + tree niters, edge update_e, bool > > > restart_loop) > > > > > > I think 'bool early_exit' is better here? I wonder if we have an "ea= rly" > > > exit after the main exit we are probably sure there are no > > > side-effects to re- execute and could avoid this restarting? > > > > Side effects yes, but the actual check may not have been performed yet. > > If you remember > > https://gist.github.com/Mistuke/66f14fe5c1be32b91ce149bd9b8bb35f > > There in the clz loop through the "main" exit you still have to see if > > that iteration did not contain the entry. This is because the loop > > counter is incremented before you iterate. > > > > > > > > > { > > > > gphi_iterator gsi, gsi1; > > > > class loop *loop =3D LOOP_VINFO_LOOP (loop_vinfo); > > > > basic_block update_bb =3D update_e->dest; > > > > - > > > > - basic_block exit_bb =3D LOOP_VINFO_IV_EXIT (loop_vinfo)->dest; > > > > - > > > > - /* Make sure there exists a single-predecessor exit bb: */ > > > > - gcc_assert (single_pred_p (exit_bb)); > > > > - gcc_assert (single_succ_edge (exit_bb) =3D=3D update_e); > > > > + bool inversed_iv > > > > + =3D !vect_is_loop_exit_latch_pred (LOOP_VINFO_IV_EXIT (loop_vinfo= ), > > > > + LOOP_VINFO_LOOP (loop_vinfo)); > > > > + bool needs_interm_block =3D LOOP_VINFO_EARLY_BREAKS (loop_vinfo) > > > > + && flow_bb_inside_loop_p (loop, update_e->src); > > > > + edge loop_e =3D LOOP_VINFO_IV_EXIT (loop_vinfo); > > > > + gcond *cond =3D get_loop_exit_condition (loop_e); > > > > + basic_block exit_bb =3D loop_e->dest; > > > > + basic_block iv_block =3D NULL; > > > > + gimple_stmt_iterator last_gsi =3D gsi_last_bb (exit_bb); > > > > > > > > for (gsi =3D gsi_start_phis (loop->header), gsi1 =3D gsi_start_p= his > (update_bb); > > > > !gsi_end_p (gsi) && !gsi_end_p (gsi1); @@ -2190,7 +2198,6 > > > > @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, > > > > tree step_expr, off; > > > > tree type; > > > > tree var, ni, ni_name; > > > > - gimple_stmt_iterator last_gsi; > > > > > > > > gphi *phi =3D gsi.phi (); > > > > gphi *phi1 =3D gsi1.phi (); > > > > @@ -2222,11 +2229,52 @@ vect_update_ivs_after_vectorizer > > > (loop_vec_info loop_vinfo, > > > > enum vect_induction_op_type induction_type > > > > =3D STMT_VINFO_LOOP_PHI_EVOLUTION_TYPE (phi_info); > > > > > > > > - if (induction_type =3D=3D vect_step_op_add) > > > > + tree iv_var =3D PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge > (loop)); > > > > + /* create_iv always places it on the LHS. Alternatively we = can set a > > > > + property during create_iv to identify it. */ > > > > + bool ivtemp =3D gimple_cond_lhs (cond) =3D=3D iv_var; > > > > + if (restart_loop && ivtemp) > > > > { > > > > + type =3D TREE_TYPE (gimple_phi_result (phi)); > > > > + ni =3D build_int_cst (type, vf); > > > > + if (inversed_iv) > > > > + ni =3D fold_build2 (MINUS_EXPR, type, ni, > > > > + fold_convert (type, step_expr)); > > > > + } > > > > + else if (induction_type =3D=3D vect_step_op_add) > > > > + { > > > > + > > > > tree stype =3D TREE_TYPE (step_expr); > > > > - off =3D fold_build2 (MULT_EXPR, stype, > > > > - fold_convert (stype, niters), step_expr); > > > > + > > > > + /* Early exits always use last iter value not niters. */ > > > > + if (restart_loop) > > > > + { > > > > + /* Live statements in the non-main exit shouldn't be adjust= ed. We > > > > + normally didn't have this problem with a single exit as live > > > > + values would be in the exit block. However when dealing with > > > > + multiple exits all exits are redirected to the merge block > > > > + and we restart the iteration. */ > > > > > > Hmm, I fail to see how this works - we're either using the value to > > > continue the induction or not, independent of STMT_VINFO_LIVE_P. > > > > That becomes clear in the patch to update live reductions. > > Essentially any live Reductions inside an alternative exit will reduce > > to the first element rather than the last and use that as the seed for = the > scalar loop. >=20 > Hum. Reductions are vectorized as N separate reductions. I don't think = you > can simply change the reduction between the lanes to "skip" > part of the vector iteration. But you can use the value of the vector fr= om > before the vector iteration - the loop header PHI result, and fully reduc= e that > to get at the proper value. That's what It's supposed to be doing though. The reason live operations are skipped here is that if we don't we'll re-adjust the IV even though the= value will already be correct after vectorization. Remember that this code only gets so far for IV PHI nodes. The loop phi header result itself can be live, i.e. see testcases vect-early-break_70.c to vect-early-break_75.c you have i_15 =3D PHI we use i_15 in the early exit. This should not be adjusted because when it'= s vectorized the value at 0[lane 0] is already correct. This is why for any = PHI inside the early exits it uses the value 0[0] instead of N[lane_max]. Perhaps I'm missing something here? Regards, Tamar >=20 > > It has to do this since you have to perform the side effects for the > > non-matching elements still. > > > > Regards, > > Tamar > > > > > > > > > + if (STMT_VINFO_LIVE_P (phi_info)) > > > > + continue; > > > > + > > > > + /* For early break the final loop IV is: > > > > + init + (final - init) * vf which takes into account peeling > > > > + values and non-single steps. The main exit can use niters > > > > + since if you exit from the main exit you've done all vector > > > > + iterations. For an early exit we don't know when we exit so > > > we > > > > + must re-calculate this on the exit. */ > > > > + tree start_expr =3D gimple_phi_result (phi); > > > > + off =3D fold_build2 (MINUS_EXPR, stype, > > > > + fold_convert (stype, start_expr), > > > > + fold_convert (stype, init_expr)); > > > > + /* Now adjust for VF to get the final iteration value. */ > > > > + off =3D fold_build2 (MULT_EXPR, stype, off, > > > > + build_int_cst (stype, vf)); > > > > + } > > > > + else > > > > + off =3D fold_build2 (MULT_EXPR, stype, > > > > + fold_convert (stype, niters), step_expr); > > > > + > > > > if (POINTER_TYPE_P (type)) > > > > ni =3D fold_build_pointer_plus (init_expr, off); > > > > else > > > > @@ -2238,6 +2286,8 @@ vect_update_ivs_after_vectorizer > > > > (loop_vec_info > > > loop_vinfo, > > > > /* Don't bother call vect_peel_nonlinear_iv_init. */ > > > > else if (induction_type =3D=3D vect_step_op_neg) > > > > ni =3D init_expr; > > > > + else if (restart_loop) > > > > + continue; > > > > > > This looks all a bit complicated - why wouldn't we simply always use > > > the PHI result when 'restart_loop'? Isn't that the correct old start= value in > all cases? > > > > > > > else > > > > ni =3D vect_peel_nonlinear_iv_init (&stmts, init_expr, > > > > niters, step_expr, > > > > @@ -2245,9 +2295,20 @@ vect_update_ivs_after_vectorizer > > > (loop_vec_info > > > > loop_vinfo, > > > > > > > > var =3D create_tmp_var (type, "tmp"); > > > > > > > > - last_gsi =3D gsi_last_bb (exit_bb); > > > > gimple_seq new_stmts =3D NULL; > > > > ni_name =3D force_gimple_operand (ni, &new_stmts, false, > > > > var); > > > > + > > > > + /* For non-main exit create an intermediat edge to get any u= pdated iv > > > > + calculations. */ > > > > + if (needs_interm_block > > > > + && !iv_block > > > > + && (!gimple_seq_empty_p (stmts) || !gimple_seq_empty_p > > > (new_stmts))) > > > > + { > > > > + iv_block =3D split_edge (update_e); > > > > + update_e =3D single_succ_edge (update_e->dest); > > > > + last_gsi =3D gsi_last_bb (iv_block); > > > > + } > > > > + > > > > /* Exit_bb shouldn't be empty. */ > > > > if (!gsi_end_p (last_gsi)) > > > > { > > > > @@ -3342,8 +3403,26 @@ vect_do_peeling (loop_vec_info loop_vinfo, > > > > tree > > > niters, tree nitersm1, > > > > niters_vector_mult_vf steps. */ > > > > gcc_checking_assert (vect_can_advance_ivs_p (loop_vinfo)); > > > > update_e =3D skip_vector ? e : loop_preheader_edge (epilog); > > > > - vect_update_ivs_after_vectorizer (loop_vinfo, niters_vector_= mult_vf, > > > > - update_e); > > > > + if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo)) > > > > + update_e =3D single_succ_edge (e->dest); > > > > + bool inversed_iv > > > > + =3D !vect_is_loop_exit_latch_pred (LOOP_VINFO_IV_EXIT (loop_vinfo= ), > > > > + LOOP_VINFO_LOOP (loop_vinfo)); > > > > > > You are computing this here and in vect_update_ivs_after_vectorizer? > > > > > > > + > > > > + /* Update the main exit first. */ > > > > + vect_update_ivs_after_vectorizer (loop_vinfo, vf, > niters_vector_mult_vf, > > > > + update_e, inversed_iv); > > > > + > > > > + /* And then update the early exits. */ > > > > + for (auto exit : get_loop_exit_edges (loop)) > > > > + { > > > > + if (exit =3D=3D LOOP_VINFO_IV_EXIT (loop_vinfo)) > > > > + continue; > > > > + > > > > + vect_update_ivs_after_vectorizer (loop_vinfo, vf, > > > > + niters_vector_mult_vf, > > > > + exit, true); > > > > > > ... why does the same not work here? Wouldn't the proper condition > > > be !dominated_by_p (CDI_DOMINATORS, exit->src, LOOP_VINFO_IV_EXIT > > > (loop_vinfo)->src) or similar? That is, whether the exit is at or > > > after the main IV exit? (consider having two) > > > > > > > + } > > > > > > > > if (skip_epilog) > > > > { > > > > > > >=20 > -- > Richard Biener > SUSE Software Solutions Germany GmbH, > Frankenstrasse 146, 90461 Nuernberg, Germany; > GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG > Nuernberg)