From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2074.outbound.protection.outlook.com [40.107.20.74]) by sourceware.org (Postfix) with ESMTPS id 6221A3858D28 for ; Fri, 19 May 2023 09:08:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6221A3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=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=UHZhQiveCtnyWbqF0wKoZ04MsBmjBySfNON4rLf57fM=; b=4Tc3QeGGZPDOSYlh3CqQAq+pMNRQuH0NixJTLKP8cpzQKREV6ys/S4qYh2qUuauEPEU8dOYo0NVk+Q/sbcPEQbFc9tmGTaqhhnEDCeUEj2ND/ln+Q77H+Ji3xPIuPONzLUuGGgDX/RJB/OTyL2E6hUT+pyVZzQtSWb7CkSzgPd0= Received: from DB7PR05CA0048.eurprd05.prod.outlook.com (2603:10a6:10:2e::25) by AS2PR08MB8503.eurprd08.prod.outlook.com (2603:10a6:20b:55e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Fri, 19 May 2023 09:08:22 +0000 Received: from DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::7c) by DB7PR05CA0048.outlook.office365.com (2603:10a6:10:2e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 09:08: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 DBAEUR03FT036.mail.protection.outlook.com (100.127.142.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 09:08:22 +0000 Received: ("Tessian outbound e13c2446394c:v136"); Fri, 19 May 2023 09:08:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5a9bff6dd9dc72ab X-CR-MTA-TID: 64aa7808 Received: from 02a6c292568c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 35634CDA-A6DF-4EF6-86F6-9550518A466E.1; Fri, 19 May 2023 09:08:15 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 02a6c292568c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 May 2023 09:08:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W8air06uNu/NlOySlzvdZ8y+TFunaOsdS0q7ij1mAawvlpk+c2OR3R+8oD07XgMqn+GQomc3SMO/C4e037NJN+i33y/Ltctut0ZHlRL72xeQoDg/bf+zJLJbo0gG7LOFrbC+zyxbj2mxpfXZ5EJvI+ewau3HhalhPCClshk5odIEnIILvFjpDMq8O/GI4nyXw0+UMj0DzzSZ0UzyKxf7WuoYdGdoLrwFaR4htfTP/TFNyoe717UJO3bGUbF7gKn1PAavOAiYLTo/mNwSlc6Y/kIvMefM58SsWk0+/27jF60jO9oNhRdLs51PBydWpR0tjn3T7lln9GethDh4MmYTTw== 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=UHZhQiveCtnyWbqF0wKoZ04MsBmjBySfNON4rLf57fM=; b=HFHgK8US+G7IlC8uPuy9q/AEqfy83VM5YHeJYlk2WQ6NwLuEwbAKL+go37VgWCH4p2l0Qp50a8FAhPjb3gxJtxfWrl5MaX1jYJVGhig95fX7IVwpoI4Ci54iarIERSHtSJuwBCZHqPYF1BcOeTPMKmRsG0vvBvicNMb87d9KNMESyHtrzL8L1km6Y+DnqxS6NwyInsEtjcCmwvemFHGhR1StIhUrsLwfBo6dRZCtApko8om29kpU52O3FW7cWzF8FzLjg4rK0pcq589lQvytwE/4n5OnQCtoW7GtHJpFVop/TugfDnCVbbmwdM5XLA/laDxD4mMajGcZkvHXpWHI0w== 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=UHZhQiveCtnyWbqF0wKoZ04MsBmjBySfNON4rLf57fM=; b=4Tc3QeGGZPDOSYlh3CqQAq+pMNRQuH0NixJTLKP8cpzQKREV6ys/S4qYh2qUuauEPEU8dOYo0NVk+Q/sbcPEQbFc9tmGTaqhhnEDCeUEj2ND/ln+Q77H+Ji3xPIuPONzLUuGGgDX/RJB/OTyL2E6hUT+pyVZzQtSWb7CkSzgPd0= Received: from AS8PR08MB7079.eurprd08.prod.outlook.com (2603:10a6:20b:400::12) by DB9PR08MB6507.eurprd08.prod.outlook.com (2603:10a6:10:25a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 09:08:13 +0000 Received: from AS8PR08MB7079.eurprd08.prod.outlook.com ([fe80::b487:af1e:9182:b18f]) by AS8PR08MB7079.eurprd08.prod.outlook.com ([fe80::b487:af1e:9182:b18f%6]) with mapi id 15.20.6411.021; Fri, 19 May 2023 09:08:13 +0000 From: Tejas Belagod To: Richard Sandiford CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] [PR96339] AArch64: Optimise svlast[ab] Thread-Topic: [PATCH] [PR96339] AArch64: Optimise svlast[ab] Thread-Index: AQHZV/wJ/KX/qZALAEyoz6/5XPXgAK9VzsLUgAcU47mAABIEWoAAJeHQgAASM1qABIQdFQ== Date: Fri, 19 May 2023 09:08:12 +0000 Message-ID: References: <20230316113927.4967-1-tejas.belagod@arm.com> In-Reply-To: Accept-Language: en-GB, 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: AS8PR08MB7079:EE_|DB9PR08MB6507:EE_|DBAEUR03FT036:EE_|AS2PR08MB8503:EE_ X-MS-Office365-Filtering-Correlation-Id: 91c29abd-c290-480d-299c-08db5848988c 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: 1/k7nm9jdEjMrYtat8ccm5PueQ7Iabrps7bfBjNT19b7c2Kd8zWYX1qWIcd75laBkh3FhOdfB+XExJlYqxoDWNHRJ1dI20EuTMUuHEycCrDZYP7JZawI6957SeskSILqMPylIxaZz3IEfGoKjv4iSwwSRzur3Rlp39A7zNV6uxqTL3moTkvj3rW074OV9czvcqPZaqMNrmhotxNOg9uebadrJ7/C99b9FASdB5sPCSXrTZtlKeJCvBMTNJfqfV+V9TsQwQnVA+eANruhP5sfKK/3CIQDuUVzeL99IUwNVzN8HaP1MK29pd6Aza91R+Vklzzb/ziWLYUV5DXW41Zsk9ez4FbRW/x6GfucZPOI4athF7LuyMJU+X5qZeFlP58gLntmbt8EV6Q2Ill4amNOVekQjyVnWgxSFSw2lkPDrPhlWj1nmiAIUn2Ygjlz+i+Ux9uSXOnhILHmRIpg3dj8T4TB6nX49X6VBa956jTY2hDYIMx1VtqNAtSREtu6AWrVWoHsesFSCqrlWFf3h3x92zF7CLpvGPitrAmY1cSrNJeznKNlFQeny73K9KjbXRV5purcMTaqnvnkWaBTgKyGx+/Zrlg+WrbZ4ymB3poyj8+y8sJMWXfNcjJRSoubT7Uh X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB7079.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(39860400002)(366004)(346002)(376002)(451199021)(91956017)(76116006)(6636002)(64756008)(66556008)(4326008)(66476007)(66946007)(66446008)(6862004)(8936002)(55016003)(8676002)(478600001)(316002)(122000001)(41300700001)(7696005)(71200400001)(2906002)(33656002)(86362001)(9686003)(53546011)(6506007)(26005)(38100700002)(83380400001)(186003)(38070700005)(52536014)(5660300002);DIR:OUT;SFP:1101; Content-Type: multipart/alternative; boundary="_000_AS8PR08MB7079885BE6ABA5593B9F7F70EA7C9AS8PR08MB7079eurp_" MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6507 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: DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f150db73-32df-460b-28ef-08db584892fe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3+hmjWqi97KB73+dQ9aO49Azj9nQYD3838wDkV5f++QhEaWeUizUarhG+pPx9j7fxg2cPManzaB6WhNp5cUuAXk6gEVKQY7Qtlbqeou259DUT0qGwfK9wc0YN6eGd/6eprr/qctUuOM4UgGg61MxF5yaGOkEyRWDq/Wxshmaf3Z1yHAbO+On3o/qPi2jTYxw//EQPn+dg3YHHS4R4Gr+6oWG9U5ydfDhoynBmyaujrOrLRGLKnh9czkXLbVb4wgwlQl7k+M/5OntIcKij9ADEVfnUv9FLZJxTeM0u39U8o3m1NOGMhe2n9A04WBnGBdsG3bzMME+vikOFwyhb3OA/j3suJENfR4rhis4c9rfyR2fCz3IVupvi0RzlZ0n6AeknEWczp2wnNkEgZ3RI720jbg1um11iXM+v/VATXKFhfBxJ6ql43Q0wWw8HAfsE7nGl48bLfxXyBGlTlOm+1UopjUcepw/PUcxzlQvVGXJSVPrj5tBG2Z03pWGHmtZ4WNGuKXFnaGvwsCVmORTrIDnBMJR6fEH2LZR2Ra1WzQJRXlwiYDIPx49F/xMi8Ke01jgVhS8xesOgxsq/rFy6JiuPOS26vRpr7SxQqGChV1d1LYN5em4ACVlBfj3y8KLhqXiSu7e5JZvCmBLvKxiamMzuVkOoc4yfUPkuCOKB3SeFyG+WMEDkFfh7fG/1oDWe8wU5XLINXjzGdNXkMFEkIIjcoVtQBZH7xVHmS/CSl58xqqllAY3HodV5iL8SJ+pp71M 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:(13230028)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199021)(36840700001)(40470700004)(46966006)(186003)(40480700001)(55016003)(7696005)(33656002)(2906002)(86362001)(82310400005)(478600001)(82740400003)(53546011)(356005)(40460700003)(81166007)(26005)(6506007)(9686003)(316002)(70206006)(70586007)(4326008)(8936002)(6636002)(47076005)(83380400001)(6862004)(8676002)(41300700001)(36860700001)(336012)(5660300002)(52536014);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 09:08:22.3112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91c29abd-c290-480d-299c-08db5848988c 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: DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8503 X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,HTML_MESSAGE,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: --_000_AS8PR08MB7079885BE6ABA5593B9F7F70EA7C9AS8PR08MB7079eurp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable From: Richard Sandiford Date: Tuesday, May 16, 2023 at 5:36 PM To: Tejas Belagod Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] [PR96339] AArch64: Optimise svlast[ab] Tejas Belagod writes: >>> + { >>> + b =3D build3 (BIT_FIELD_REF, TREE_TYPE (f.lhs), val, >>> + bitsize_int (step * BITS_PER_UNIT), >>> + bitsize_int ((16 - step) * BITS_PER_UNIT)); >>> + >>> + return gimple_build_assign (f.lhs, b); >>> + } >>> + >>> + /* If VECTOR_CST_NELTS_PER_PATTERN (pred) =3D=3D 2 and every mult= iple of >>> + 'step_1' in >>> + [VECTOR_CST_NPATTERNS .. VECTOR_CST_ENCODED_NELTS - 1] >>> + is zero, then we can treat the vector as VECTOR_CST_NPATTERNS >>> + elements followed by all inactive elements. */ >>> + if (!const_vl && VECTOR_CST_NELTS_PER_PATTERN (pred) =3D=3D 2) >> >> Following on from the above, maybe use: >> >> !VECTOR_CST_NELTS (pred).is_constant () >> >> instead of !const_vl here. >> >> I have a horrible suspicion that I'm contradicting our earlier discussion >> here, sorry, but: I think we have to return null if NELTS_PER_PATTERN != =3D 2. >> >> >> >> IIUC, the NPATTERNS .. ENCODED_ELTS represent the repeated part of the > encoded >> constant. This means the repetition occurs if NELTS_PER_PATTERN =3D=3D 2= , IOW the >> base1 repeats in the encoding. This loop is checking this condition and = looks >> for a 1 in the repeated part of the NELTS_PER_PATTERN =3D=3D 2 in a VL v= ector. >> Please correct me if I=92m misunderstanding here. > > NELTS_PER_PATTERN =3D=3D 1 is also a repeating pattern: it means that the > entire sequence is repeated to fill a vector. So if an NELTS_PER_PATTERN > =3D=3D 1 constant has elements {0, 1, 0, 0}, the vector is: > > {0, 1, 0, 0, 0, 1, 0, 0, ...} > > > Wouldn=92t the vect_all_same(pred, step) cover this case for a given valu= e of > step? > > > and the optimisation can't handle that. NELTS_PER_PATTERN =3D=3D 3 isn't > likely to occur for predicates, but in principle it has the same problem. > > > > OK, I had misunderstood the encoding to always make base1 the repeating v= alue > by adjusting the NPATTERNS accordingly =96 I didn=92t know you could also= have the > base2 value and beyond encoding the repeat value. In this case could I ju= st > remove NELTS_PER_PATTERN =3D=3D 2 condition and the enclosed loop would c= heck for a > repeating =911=92 in the repeated part of the encoded pattern? But for NELTS_PER_PATTERN=3D=3D1, the whole encoded sequence repeats. So you would have to start the check at element 0 rather than NPATTERNS. And then (for NELTS_PER_PATTERN=3D=3D1) the loop would reject any constant that has a nonzero element. But all valid zero-vector cases have been handled by this point, so the effect wouldn't be useful. It should never be the case that all elements from NPATTERNS onwards are zero for NELTS_PER_PATTERN=3D=3D3; that case should be canonicalised to NELTS_PER_PATTERN=3D=3D2 instead. So in practice it's simpler and more obviously correct to punt when NELTS_PER_PATTERN !=3D 2. Thanks for the clarification. I understand all points about punting when NELTS_PER_PATTERN !=3D2, but one. Am I correct to understand that we still need to check for the case when th= ere's a repeating non-zero elements in the case of NELTS_PER_PATTERN =3D=3D= 2? eg. { 0, 0, 1, 1, 1, 1,....} which should be encoded as {0, 0, 1, 1} wi= th NPATTERNS =3D 2 ? Thanks, Tejas. Thanks, Richard --_000_AS8PR08MB7079885BE6ABA5593B9F7F70EA7C9AS8PR08MB7079eurp_--