From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2085.outbound.protection.outlook.com [40.107.7.85]) by sourceware.org (Postfix) with ESMTPS id 6AC3D3858CDB for ; Mon, 6 Nov 2023 17:30:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AC3D3858CDB 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 6AC3D3858CDB Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.7.85 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699291814; cv=pass; b=M2UTH6U6uDeIsMW7c1lvgJXTLceCKcl412RtoSFP57oBa2y9vwLCCwNma0ydfOYCEEcfZg42lBId9a3B/tJUXHIK1JDmEct9nNl2ZLn066EYwMXeVEoNfDZDm0TBd4IAg7xGSpl1UKVrDA2G53cxFF9VL1XBNS9j6mRJ62EJf+k= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699291814; c=relaxed/simple; bh=Ka3fNETSoWa5pBDHI5i4Pb/Py7LAlRWzpNcZAH4IBwQ=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=QnRRNt0iS/vHFjJrsyvl/yjvyQ7XG5tlug/3Oi00Pd15rI5Y5sgS19fu8MnYQPTX0KC1EnHbnX9I43n5XAw/dydC3X6ZJGY551AkbXBMp1GWtyIVasWYE9Zz2J6hB4nUVhXUHe4WsC2/zaQpitvAZ6LapbE+sCgHnM5ut9dhD3k= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Mw1qhteafohm7hHHlrZUpSkQbg/ITGzey63ZgWuMZrNuzLJzsTMUBa30gUalbJxo5qWl5Y9gHk4G7sTU2hr6OWefrRQmldKmOSuSoNEeNRledGWKKdbDFSAQ1DR4e/aL/0x9Y/mZ7pVYozVgzlbpR3EIBWhZxOjKgTgnNzTJQcogg9DKqmJy6CCc7s71k0jWzLqA71NLO6ZuYwFVvWh4YGfRmIGx7uKtOVPGcQe8PA2rXWa22WXUBhy9COOBd/2+iuSyQUoY2G5Ge4o2agSlNlu3cOa3TqOEXNP8zYN70rS5CK2QX/suKeFh9LmsZDy7agDdlCFY65twsVk10ZOXpA== 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=Lrf941GtBOuIyDX+kZE4pBZ3dEbWHxzv55b64eSpsFg=; b=nudCHr2/JJ6nfNfj8bYVWnIjwlmRfYoC+i9s46Xl5I1SxxgQQvXn0Ijw7P/cbP8Q0P2ZbvTp/cUXyvces4+XWxph1RlCaYD+e89NoVExWpcPEj+XKYVooD1oxW6a6JixkEjn6BBteVEwk5T9gP3ppDP2rB9JHu5mP/DqhuRrlyDSQs+YXIO61F2urOb133Y900DCsXbaepsmW6Oyn8HN6QZFLvowc/oCexTfjri607onMFPFcWsfZVhFgNpGAjJxn4zTJkOL0pP7+E9j6lWCbfOIQxZ0hW9VRKXYNKOqXdPc9Ulta4gBgQa045pJIK+8XYvplwwW6ysmZ0whTeTxwg== 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=Lrf941GtBOuIyDX+kZE4pBZ3dEbWHxzv55b64eSpsFg=; b=pzrNsj4M5DIPmWjVI2HuK0ktYVzMOmSJY7dAizEwvxvozanmJuvp5/NWJKFw3yNGF3gqNJQ0JNErPYdQP2SYSlwiXhBX+YdOcYcWIsUJjf2y7cVRk12ZKhlTYdii5VnNZHYRlPaUfFcfn5SgW5uHhLIBwpWkqOU5+cie6fhOVsA= Received: from DUZPR01CA0018.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::6) by AS8PR08MB9340.eurprd08.prod.outlook.com (2603:10a6:20b:5a8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.27; Mon, 6 Nov 2023 17:30:09 +0000 Received: from DU6PEPF00009523.eurprd02.prod.outlook.com (2603:10a6:10:46b:cafe::74) by DUZPR01CA0018.outlook.office365.com (2603:10a6:10:46b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.26 via Frontend Transport; Mon, 6 Nov 2023 17:30:09 +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 DU6PEPF00009523.mail.protection.outlook.com (10.167.8.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.16 via Frontend Transport; Mon, 6 Nov 2023 17:30:09 +0000 Received: ("Tessian outbound 7671e7ddc218:v228"); Mon, 06 Nov 2023 17:30:09 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3a44c8358ef06801 X-CR-MTA-TID: 64aa7808 Received: from 62c2c68c30cb.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B2FE9111-6619-4EB3-BD82-248E70222BCF.1; Mon, 06 Nov 2023 17:29:58 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 62c2c68c30cb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 06 Nov 2023 17:29:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nN190Lr7eek9xyv9K9K5+JopMVehw+lI8jSkWwOJre0tGxqj2fwrGEkohD7vmJWMmRs29UpG5OGtC9oGSxwNSsh6vZmMdWEX2eipnm+mDRwoxcc1Y7hlNc3blDs6W2u4H27EHHzEXDJUBv5mjO7aFUJY11YNnG4WQoKhXmEo8zFiXFSeDOCK6OZk/F/KjbKniDPTgp9r+YM+sYUpg70ANSRHftkqLCBKWXltb1llPiavsrM0/37UxPkrbKwXRIFbImtGLKnunREt4etqOmaRPP+evH3CewLeLtUxgB5Vqd5RUDt64OSadVas5pxnnZIVoYs54pqKWletEn9OhWbEOA== 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=Lrf941GtBOuIyDX+kZE4pBZ3dEbWHxzv55b64eSpsFg=; b=Y5mjAp6aQrdN6ei3I5rkZ3sCIL3ACmNaADHlyH0Exh8kFvyqgn5tEv+aWScFobuVyNNaXVQISPREmVf56DkD+wiVB1dbnQz5uIvivWn3W4lkP4biu2AtknGX/6V5WrfZNhx9TYeOvEKslxyhkytLXLLlg0dXCgmRZLO0R4kNk6c9oeTCJBW3osSVyXO/3wOTnRe4uHokDTlNy1jgmiUFnnncaNp8bkpU3eeDUDNrT/7A0J2Zrbah3alg7z4ZqVnUVQcYatcDJJaT8v16eGgiorIDUcUMmtG2Infbh4HDk/TS9/i9pCY3LqjYN0fhet3fXBaYzDEHQwjyaIev4KW5rA== 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=Lrf941GtBOuIyDX+kZE4pBZ3dEbWHxzv55b64eSpsFg=; b=pzrNsj4M5DIPmWjVI2HuK0ktYVzMOmSJY7dAizEwvxvozanmJuvp5/NWJKFw3yNGF3gqNJQ0JNErPYdQP2SYSlwiXhBX+YdOcYcWIsUJjf2y7cVRk12ZKhlTYdii5VnNZHYRlPaUfFcfn5SgW5uHhLIBwpWkqOU5+cie6fhOVsA= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB6507.eurprd08.prod.outlook.com (2603:10a6:10:25a::6) by AS2PR08MB8335.eurprd08.prod.outlook.com (2603:10a6:20b:557::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 17:29:56 +0000 Received: from DB9PR08MB6507.eurprd08.prod.outlook.com ([fe80::6118:948d:f205:3182]) by DB9PR08MB6507.eurprd08.prod.outlook.com ([fe80::6118:948d:f205:3182%4]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 17:29:55 +0000 Message-ID: <5793c5af-9c01-48a8-9bf3-f289e7f32640@arm.com> Date: Mon, 6 Nov 2023 17:29:48 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PING][PATCH 2/2] arm: Add support for MVE Tail-Predicated Low Overhead Loops To: Stamatis Markianos-Wright via Gcc-patches , Richard Earnshaw , richard.sandiford@arm.com References: <949f5dd0-cdf0-715a-f04c-3de80c9b974f@arm.com> <32452185-e459-4521-9b77-e80d06573ee2@arm.com> Content-Language: en-US From: Stamatis Markianos-Wright In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0411.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:189::20) To DB9PR08MB6507.eurprd08.prod.outlook.com (2603:10a6:10:25a::6) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB6507:EE_|AS2PR08MB8335:EE_|DU6PEPF00009523:EE_|AS8PR08MB9340:EE_ X-MS-Office365-Filtering-Correlation-Id: c0aa7320-27d0-4de9-04f6-08dbdeee0690 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: XixEBRKOEMNUEjLyn/ZLb/KDTR7io0IQ/9a+IOmNof7YzubIZfuoN5ywnjnipqTlHoKznpchcIcJ7TAd04BOS0mwNRhZ/Dulkk6C36xnmO1UYIcDV1e2y8WD2DpFn+aB7ELbVPu/pumZJEqvihNu8PvWo+kr15SaI8gq3+h13QYhTfqt1ep2ivGH7GcwQA0QAnPIq8GVy8gLMapCNKD9TB/zYk6y36j8RRtTQ8WA92J1rCgqIb/3XPAEW986zL88z5oWFY1RyTfPA7QLZ3w0+U7xuW3ZzIbM1eAO3374qUJsYzcCQb0/M79oAFSaflAK+IDVJl1JuHDfXacHafooaShQ5d6lr0eFLix1/qUajhXwKxcrCeAabTzgzUHSN3Hj3wzNr26s4niErbjqdqFN0/kbOm6EA8aJGkUI0lG2lxVpfh5WGxeCVKrBilRp9Si3q7iLJpt55sKmhD+8Qwpfwf1rzErsJpm9hg6YBa1Yy/GLpfJc6K19JfnMigOOnmGZIVa8UYeehVcp6LQZX+DScCJGWQ/oe+OxOzngzo9OSNC3qmhB+/mt/s5/t/jNloUSsNbipJbwTo+7hdDJUlQfqbF8SORgUphHpBd4j3EqeOB2iEH06znewcFuXTw3n26ZJIT6rfL4PnXUQF3R+MwdZg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB6507.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(346002)(366004)(136003)(396003)(376002)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(31686004)(53546011)(6512007)(110136005)(66946007)(26005)(2616005)(478600001)(6506007)(8676002)(8936002)(66476007)(316002)(66556008)(6636002)(6666004)(6486002)(5660300002)(41300700001)(38100700002)(86362001)(31696002)(2906002)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8335 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: DU6PEPF00009523.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 00815182-759a-4e81-219c-08dbdeedfcb9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kXyeSdiXF1Qg7rHsyjvmcvtI8CvBTslX4hwVChFzedRvtTN4pC6zDuFiO1q2BNMZ/tRSJjTnvVLs6roRFYaCtt0HV5P4vn+3WJzfkL055O3MfYUiA0MKZ+aPwjlqHmfAsswJnK/QDMNzKMG2kxIkBjnOnajm5CryUJ9z3Mwx/wcnOot8R1qBs9kqxfPAh63CPVecTo0125EIIm/dvgSD2NV9US3vxi40HZWnc7siIvVVv+0s9c3JhrU4YH5Ceoh01R4dTawq7a8YSA42NdzOQw8a1rAgZACWX4YHstc+3teATppx5V5nt1lhonyEgyWLCW/nTP8PaDgrAiX6HORqPR1lTFRmnfpYx45+f+i4KfOiGne6IHTLi0rhtJU/CUFqh7vicnOzU3rYQzB0G9ahYLTkK0jl+Qs+ebcz9e1jEh55MIuO5U45BWaGgU9xkwA9lpaKRMhEfJlvgCXkhOCxHTR5dSCwAKy4HzRXOtV7EGfOX0Sj5n3th6wtE1zHtxeWsU/0sLJSP1/c9aymLiUgiKXWRQyZuBdjku1tEma0C1NcD4cUyKekvClif+m/Kqw9nXaa3e0YRTzg09yiNmrHK29CWA0T/X2LF0SoApiZeEHzBrUQp5I/RgINYyVgoE05RuDa+8LpoFXp1v4FfJYk/w6g30h2hNC5n8cx12qU1+3hiRUS6kwK7+rA3h6lR6EmrYyST/b3bWpcooCyUHyiVWN163etVvQvolgIehi6D3+s0yCU/5j3g6Otb2Ke7CWrWCYPizdjFk09O+yvnKW9xw== 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)(376002)(346002)(396003)(39860400002)(230922051799003)(451199024)(82310400011)(186009)(1800799009)(64100799003)(36840700001)(46966006)(40470700004)(26005)(6512007)(40480700001)(2616005)(2906002)(82740400003)(47076005)(36860700001)(81166007)(356005)(40460700003)(31696002)(86362001)(36756003)(336012)(8936002)(41300700001)(70586007)(70206006)(316002)(8676002)(478600001)(6636002)(6486002)(6506007)(5660300002)(53546011)(110136005)(31686004)(6666004)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 17:30:09.6741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0aa7320-27d0-4de9-04f6-08dbdeee0690 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: DU6PEPF00009523.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9340 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,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=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 06/11/2023 11:24, Richard Sandiford wrote: > Stamatis Markianos-Wright writes: >>> One of the main reasons for reading the arm bits was to try to answer >>> the question: if we switch to a downcounting loop with a GE condition, >>> how do we make sure that the start value is not a large unsigned >>> number that is interpreted as negative by GE? E.g. if the loop >>> originally counted up in steps of N and used an LTU condition, >>> it could stop at a value in the range [INT_MAX + 1, UINT_MAX]. >>> But the loop might never iterate if we start counting down from >>> most values in that range. >>> >>> Does the patch handle that? >> So AFAICT this is actually handled in the generic code in `doloop_valid_p`: >> >> This kind of loops fail because of they are "desc->infinite", then no >> loop-doloop conversion is attempted at all (even for standard dls/le loops) >> >> Thanks to that check I haven't been able to trigger anything like the >> behaviour you describe, do you think the doloop_valid_p checks are >> robust enough? > The loops I was thinking of are provably not infinite though. E.g.: > > for (unsigned int i = 0; i < UINT_MAX - 100; ++i) > ... > > is known to terminate. And doloop conversion is safe with the normal > count-down-by-1 approach, so I don't think current code would need > to reject it. I.e. a conversion to: > > unsigned int i = UINT_MAX - 101; > do > ... > while (--i != ~0U); > > would be safe, but a conversion to: > > int i = UINT_MAX - 101; > do > ... > while ((i -= step, i > 0)); > > wouldn't, because the loop body would only be executed once. > > I'm only going off the name "infinite" though :) It's possible that > it has more connotations than that. > > Thanks, > Richard Ack, yep, I see what you mean now, and yep, that kind of loop does indeed pass through doloop_valid_p Interestingly , in the v8-M Arm ARM this is done with: ``` boolean IsLastLowOverheadLoop(INSTR_EXEC_STATE_Type state) // This does not check whether a loop is currently active. // If the PE were in a loop, would this be the last one? return UInt(state.LoopCount) <= (1 << (4 - LTPSIZE)); ``` So architecturally the asm we output would be ok (except maybe the "branch too far subs;bgt;lctp" fallback at `predicated_doloop_end_internal` (maybe that should be `bhi`))... But now GE: isn't looking like an accurate representation of this operation in the compiler. I'm wondering if I should try to make `predicated_doloop_end_internal` contain a comparison along the lines of: (gtu: (plus: (LR) (const_int -num_lanes)) (const_int num_lanes_minus_1)) I'll give that a try :) The only reason I'd chosen to go with GE earlier, tbh, was because of the existing handling of GE in loop-doloop.cc Let me know if any other ideas come to your mind! Cheers, Stam