From patchwork Thu Apr 18 10:11:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1924889 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=2RSxzt6w; 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=2RSxzt6w; 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 4VKtq80Tx4z1yZP for ; Thu, 18 Apr 2024 20:11:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F0553858C60 for ; Thu, 18 Apr 2024 10:11:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2043.outbound.protection.outlook.com [40.107.241.43]) by sourceware.org (Postfix) with ESMTPS id 070023858D37 for ; Thu, 18 Apr 2024 10:11:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 070023858D37 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 070023858D37 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.241.43 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1713435088; cv=pass; b=w/IFGR/VPtVIqXwuTogg/1tC4XrnxDH2yKWy73pE3wg0QXTQf7njH/ykiqxbvEa0DRRFWPgulShAV30bNLhQkVUDwXvM/e8bHRGfAjlrWkAkPdCOP3MHR3FdGdcOFD8TwlYIUU/rOCjjGelCyWILZ+mmj6d11ju1bA3OsEqQUe8= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1713435088; c=relaxed/simple; bh=IwkUVO6jX8B1+ERiXPG0IvaBag9wFnMlGMdgyYEtPgA=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=S2iMmZ6euxqXbHcRERHiexBcQ8vz3YFZ1rvs//qUSjtElltg9HzdyDO9vuL3uYheWXwzcKJnd57zzNH+9l2UVe/N+jN7mkfsowYQhhZtbUkHJMj5nYxaN8e1QePj4aoC9LbIFaXN1w1x5mYXqwyEGTc2h05gfYPtINd6hA9mmFw= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=RQLIXpzz3/QmXK1Nxle612lzfTTkH9NPV0zW3iuStbNTqPeqeZvUVGh96DnT+i4hmgGZwAZziuU7GxXH5AM5smc/0JZiz7phfKsmdRiSPPBbBPoYud8zBHIkBWEBfutqqKZpuP4fnnenqyGACgwbLHdtDGDoLcxYyaOH5MspVBwNKKmq1Dm0SAeQg13HOpPKnRiowgu/qhDcJA0wSQ+DTbK70SlHIhh8ADGNiIzO5Uf17wI7hEEtEfwULHTpHaWqrefTv4mNQeCUqwhubeBLjsDOb0XRBAsI7RsEB1DGgrQYpUjSmcygoeqeO6jlUjYIrUAgX0qP2XLZuqKoGR1TSQ== 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=4hr9BFWOH+F2iY19tb77tiqq7aoCCGlW8oySTv4eumE=; b=NChiOaHsT3L7K14lLPG0wpkf6jodRRZ/aAMFvbbUyF5uQCTDejdU6VHf8SRaykNVJrwSECXZKwXfuDz241cD1edHmnqwpFMERSb7NcL1AGvkwULGIg55M5JSBwcWxPaLWDDvx818+E544RgZ/4DWWIETumz83gdaYuR3CCqbAMoNvdeGG2Ml05Asm6kbpsyYpNu40hbZttuutgP9Yq8R/2sfsVEzETigq8SJ8fDWbyZHhsPmJq1uMmWl1s/K1/+YQvI8/SMI93L2ReS2PQ5UyQmTmg3Xgbr+Y6N13KCu5tCG398w31dEhTCYQn1oDvqIMKJ3yPbLaiHqzw+uMhGSZA== 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=4hr9BFWOH+F2iY19tb77tiqq7aoCCGlW8oySTv4eumE=; b=2RSxzt6w1XdOSRq94XqiasHaI6Ylht+BjAyT5nJkKh3MUHaM2w3Zkfnc6OWPgQNn4QTPOm9NvMmYRrpc8s4STg7c/Q+eUIbvwM8S34SsP2z1MPpQapxEhS3NZvcMrVYMX4Ka+D0EaK9FwgBkFZUcPmghUe36wBtycaRBlCBAc5Y= Received: from AS9PR06CA0317.eurprd06.prod.outlook.com (2603:10a6:20b:45b::27) by PA6PR08MB10860.eurprd08.prod.outlook.com (2603:10a6:102:3d9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.39; Thu, 18 Apr 2024 10:11:22 +0000 Received: from AM4PEPF00027A68.eurprd04.prod.outlook.com (2603:10a6:20b:45b:cafe::7d) by AS9PR06CA0317.outlook.office365.com (2603:10a6:20b:45b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.26 via Frontend Transport; Thu, 18 Apr 2024 10:11: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 AM4PEPF00027A68.mail.protection.outlook.com (10.167.16.85) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Thu, 18 Apr 2024 10:11:20 +0000 Received: ("Tessian outbound caed45120527:v313"); Thu, 18 Apr 2024 10:11:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5a7521c802af4aa1 X-CR-MTA-TID: 64aa7808 Received: from ef66582c72d1.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 64C89E74-60A5-4ADB-91F1-AE776ADE43A1.1; Thu, 18 Apr 2024 10:11:09 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ef66582c72d1.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 18 Apr 2024 10:11:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kVr3Oad1uoVmH2BYzlIzUmZuNUeiz28vNklsMbC7ysiIOiq6s9i8zs6mf7Swg4aBFgZTvHeGYybC8NQBOq+uICH60YPp6h2nNl52WwSYQpyrdGn1oe2zAHJooTty+NeVIBtUZF12DpPlvD+qZfpXJwT3YqB2wVBwEkH5eOlcmvDYj3AdWVST9D0cFLfW8DarLVlgPY5umn/12I4BrLmVcCLyt+D6hoTkX8janJSlW5hitx5gYkEEPQI7t2nvWUKUnWMzmi6YUYtGgRG3nGJxvjpBKzoorh/H5THj4HB7mwBQOlbVxv5xc4XFSc+EoSp8nQFEr9QH1uTBYRjHJLJtXQ== 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=4hr9BFWOH+F2iY19tb77tiqq7aoCCGlW8oySTv4eumE=; b=IXLCcErzb/JLwdtwoifIwV3GFHDl6U67Du5CqLDGbOH8c5oYW0uLuQrh30GfeW7Z2BAmENL0CNG//7ZzbgBfDBcu2sBPeB97eGzEeeEdC6xyZrXfBymr2Hpg7DLm+WFUw+rCen3icLC3LvNZx2GqgB1xaEDqVF/EKKA0EBO6pXygIhNt6O2NNGoix5GavDzn+NKuSnLPZm163XxlGH+AThSddgQMB4bVp4IgcuLXOvDne8XVP1qi+wfpTftUwS2jUDWPIMTOfkou4uJcXI7a9bQdyXiwtYjnH7/ZCKJLHPdrVUsOmC6FIvBseCnxalR956M09U4EbXI6Ww6VOkCjOA== 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=4hr9BFWOH+F2iY19tb77tiqq7aoCCGlW8oySTv4eumE=; b=2RSxzt6w1XdOSRq94XqiasHaI6Ylht+BjAyT5nJkKh3MUHaM2w3Zkfnc6OWPgQNn4QTPOm9NvMmYRrpc8s4STg7c/Q+eUIbvwM8S34SsP2z1MPpQapxEhS3NZvcMrVYMX4Ka+D0EaK9FwgBkFZUcPmghUe36wBtycaRBlCBAc5Y= 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 AS8PR08MB9409.eurprd08.prod.outlook.com (2603:10a6:20b:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Thu, 18 Apr 2024 10:11:06 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::a0e:800c:c8b2:5ff0]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::a0e:800c:c8b2:5ff0%4]) with mapi id 15.20.7472.037; Thu, 18 Apr 2024 10:11:06 +0000 Date: Thu, 18 Apr 2024 11:11:03 +0100 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, Richard.Earnshaw@arm.com, Marcus.Shawcroft@arm.com, Kyrylo.Tkachov@arm.com, richard.sandiford@arm.com Subject: [PATCH]AArch64: remove reliance on register allocator for simd/gpreg costing. [PR114741] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO2P123CA0100.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::15) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|AS8PR08MB9409:EE_|AM4PEPF00027A68:EE_|PA6PR08MB10860:EE_ X-MS-Office365-Filtering-Correlation-Id: dfce3e72-5457-43ac-944c-08dc5f8fe52b 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: akQxZnjuFQ0yI7F/OVwbuhkA4zL7m3NWWwVia1D4HRFfVuKTSF6bc3rPqYSTo3m0JDjs4dEeHBuJ5XrvOgX6NqyimqP4pFwazlKZUaByFjw4mGW9xgtoRzUrEBzKRIjuC1PHmQxCS4cFdpj43jz9l4Gg4YKSFuFt2a+rmCgGN4jry9vRXkoYbBlU5auqr8dHdAWczW4CTDdkAARKSmNNS8OYNqpb5DqexJModMlJNHGS/6M17DzOz9yMyUi2UNsc8e2HTltCrtOFvaA5724HLEe4OLFOTbbTTsXnVDQhlgpKpRuusm5vsEX3VuakLupjSyhFadmw27Z28TSkT0fm+sNElqfvIqIuK2AmUPQPUWqEy9EDcmsofT1b88BjUn+5D7/+IINTtkb8nBoee6OSL50udnpFJZDi6aO1+StHqVz8RfvcoBuc9cudv5dkFfN/gEpN54bIjnNUyeTz9LhXY35mq/e0ysQBKJSa9UcN14nlovWtS7lbaG0K7BQd+wiJ2Jo/IjOBF3nFIbcKlHtBWEHX+0OoHOI1tUhK1lD1Quqn2Fm2TgKb0H5zb9VrM+OPsgIGw0gvUdOxrgHqbREAZi8pySnOb6KGoXqN13T8A+43lRNnVeFr8HMXk+XCoq9D 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)(366007)(376005)(1800799015); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9409 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: AM4PEPF00027A68.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e7542477-d4b2-49d3-32a0-08dc5f8fdc61 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d610tt962TIKqWgIOKm5Nl6toeDG1Hs2a7cCZtrIhYkn6dqXFUcR7H+3y2kdZpVkIKO3F0Y9P5QoIwJcbTOcB6li3oiFcxvcMCnhyQ+7LrtdijaCWSAvhCEBwy/GbDGG/5WQ58LsjE7oykEJVMrtyGgc0xH9LQ5xXIPEVUS34x3VXcG57X900d0DtjXnAsDBH96GG8apM0ihGHtFDuaMgEKf+tsh8ItGaZyuuJx6pWl1JiIv7uBuyOjC6wczYtIQiphi/Hzmfrknv/Wd70SAl/++dGW7xK8zq9d2U/a+AYOF3GJOqWWIfDcPGqSAI4ZHMGIOQsi9lGI/fJIWyWhnNg/5wMG3P+3xmWkLOmiJQsI9GidfV/xge8Wxlh6GCkqLNquxA4r7SNjhhvrFzLmhXrtpJ4HqISG6p/38ELZtyoyl4nKmXiV8YwGvDuA2o3D5B8CEL1KSsTCXPubpWFm6EpDhIe9On9uMBgBG1PA+2CH4c/NmMtFWavV4WIsjtmBg3HVSmQd4aKHRAO/a9wBHLqeQDK4KC9cXJ7tfQcG7pt+FxOZvoF66dAyXW0rWFnrKdJMR02QXI9nLWt765yYD/MVAn/+IyChwpFAB/lC73zDcWgTtbJ4xRx/dioNhyNt7KP74RcdkB6UkCnXu/55yOjHais8nNBfdHhDSAeVCNbwT0lUhGyGcSXpj25kWXLD8xiN9XEo1khjDdnxXip7Bjw== 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)(36860700004)(376005)(1800799015)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2024 10:11:20.8943 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfce3e72-5457-43ac-944c-08dc5f8fe52b 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: AM4PEPF00027A68.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA6PR08MB10860 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, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, 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, In PR114741 we see that we have a regression in codegen when SVE is enable where the simple testcase: void foo(unsigned v, unsigned *p) { *p = v & 1; } generates foo: fmov s31, w0 and z31.s, z31.s, #1 str s31, [x1] ret instead of: foo: and w0, w0, 1 str w0, [x1] ret This causes an impact it not just codesize but also performance. This is caused by the use of the ^ constraint modifier in the pattern 3. The documentation states that this modifier should only have an effect on the alternative costing in that a particular alternative is to be preferred unless a non-psuedo reload is needed. The pattern was trying to convey that whenever both r and w are required, that it should prefer r unless a reload is needed. This is because if a reload is needed then we can construct the constants more flexibly on the SIMD side. We were using this so simplify the implementation and to get generic cases such as: double negabs (double x) { unsigned long long y; memcpy (&y, &x, sizeof(double)); y = y | (1UL << 63); memcpy (&x, &y, sizeof(double)); return x; } which don't go through an expander. However the implementation of ^ in the register allocator is not according to the documentation in that it also has an effect during coloring. During initial register class selection it applies a penalty to a class, similar to how ? does. In this example the penalty makes the use of GP regs expensive enough that it no longer considers them: r106: preferred FP_REGS, alternative NO_REGS, allocno FP_REGS ;; 3--> b 0: i 9 r106=r105&0x1 :cortex_a53_slot_any:GENERAL_REGS+0(-1)FP_REGS+1(1)PR_LO_REGS+0(0) PR_HI_REGS+0(0):model 4 which is not the expected behavior. For GCC 14 this is a conservative fix. 1. we remove the ^ modifier from the logical optabs. 2. In order not to regress copysign we then move the copysign expansion to directly use the SIMD variant. Since copysign only supports floating point modes this is fine and no longer relies on the register allocator to select the right alternative. It once again regresses the general case, but this case wasn't optimized in earlier GCCs either so it's not a regression in GCC 14. This change gives strict better codegen than earlier GCCs and still optimizes the important cases. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR target/114741 * config/aarch64/aarch64.md (3): Remove ^ from alt 2. (copysign3): Use SIMD version of IOR directly. gcc/testsuite/ChangeLog: PR target/114741 * gcc.target/aarch64/fneg-abs_2.c: Update codegen. * gcc.target/aarch64/fneg-abs_4.c: xfail for now. * gcc.target/aarch64/pr114741.c: New test. --- -- diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 385a669b9b3c31cc9108a660e881b9091c71fc7c..dbde066f7478bec51a8703b017ea553aa98be309 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -4811,7 +4811,7 @@ (define_insn "3" "" {@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] [ r , %r , r ; logic_reg , * ] \t%0, %1, %2 - [ rk , ^r , ; logic_imm , * ] \t%0, %1, %2 + [ rk , r , ; logic_imm , * ] \t%0, %1, %2 [ w , 0 , ; * , sve ] \t%Z0., %Z0., #%2 [ w , w , w ; neon_logic , simd ] \t%0., %1., %2. } @@ -7192,22 +7192,29 @@ (define_expand "copysign3" (match_operand:GPF 2 "nonmemory_operand")] "TARGET_SIMD" { - machine_mode int_mode = mode; - rtx bitmask = gen_reg_rtx (int_mode); - emit_move_insn (bitmask, GEN_INT (HOST_WIDE_INT_M1U - << (GET_MODE_BITSIZE (mode) - 1))); + rtx signbit_const = GEN_INT (HOST_WIDE_INT_M1U + << (GET_MODE_BITSIZE (mode) - 1)); /* copysign (x, -1) should instead be expanded as orr with the sign bit. */ rtx op2_elt = unwrap_const_vec_duplicate (operands[2]); if (GET_CODE (op2_elt) == CONST_DOUBLE && real_isneg (CONST_DOUBLE_REAL_VALUE (op2_elt))) { - emit_insn (gen_ior3 ( - lowpart_subreg (int_mode, operands[0], mode), - lowpart_subreg (int_mode, operands[1], mode), bitmask)); + rtx v_bitmask + = force_reg (V2mode, + gen_const_vec_duplicate (V2mode, + signbit_const)); + + emit_insn (gen_iorv23 ( + lowpart_subreg (V2mode, operands[0], mode), + lowpart_subreg (V2mode, operands[1], mode), + v_bitmask)); DONE; } + machine_mode int_mode = mode; + rtx bitmask = gen_reg_rtx (int_mode); + emit_move_insn (bitmask, signbit_const); operands[2] = force_reg (mode, operands[2]); emit_insn (gen_copysign3_insn (operands[0], operands[1], operands[2], bitmask)); diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c index eed41ea18e69ff60ac79cbdb7c0c935850b49b33..18d10ee834d5d9b4361d890447060e78f09d3a73 100644 --- a/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c @@ -9,8 +9,7 @@ /* ** f1: -** movi v[0-9]+.2s, 0x80, lsl 24 -** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** orr v[0-9]+.2s, #?128, lsl #?24 ** ret */ float32_t f1 (float32_t a) @@ -22,7 +21,7 @@ float32_t f1 (float32_t a) ** f2: ** movi v[0-9]+.4s, #?0 ** fneg v[0-9]+.2d, v[0-9]+.2d -** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** orr v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b ** ret */ float64_t f2 (float64_t a) diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c index d45c3d1210c682f38177a89f1137ab4f6decfbc1..6da95a4b052ca3d9e0b8db0e465c5f40139b2b18 100644 --- a/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c @@ -7,7 +7,7 @@ #include /* -** negabs: +** negabs: { xfail *-*-* } ** movi v31.4s, #?0 ** fneg v[0-9]+.2d, v[0-9]+.2d ** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b @@ -23,7 +23,7 @@ double negabs (double x) } /* -** negabsf: +** negabsf: { xfail *-*-* } ** movi v[0-9]+.2s, 0x80, lsl 24 ** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b ** ret diff --git a/gcc/testsuite/gcc.target/aarch64/pr114741.c b/gcc/testsuite/gcc.target/aarch64/pr114741.c new file mode 100644 index 0000000000000000000000000000000000000000..fd2182da0e966afcf0ab5bdef2f8d3892c2a3d67 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr114741.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +/* +** foo1: +** and w0, w0, 1 +** str w0, \[x1\] +** ret +*/ +void foo1(unsigned v, unsigned *p) +{ + *p = v & 1; +} + +#pragma GCC target "+sve" + +/* +** foo2: +** and w0, w0, 1 +** str w0, \[x1\] +** ret +*/ +void foo2(unsigned v, unsigned *p) +{ + *p = v & 1; +}