From patchwork Mon Aug 17 08:59:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1345931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: 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=lSKchxZ2; 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=lSKchxZ2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BVSgX2VNmz9sTH for ; Mon, 17 Aug 2020 19:00:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 114913857C7D; Mon, 17 Aug 2020 09:00:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90071.outbound.protection.outlook.com [40.107.9.71]) by sourceware.org (Postfix) with ESMTPS id D54113857C7D for ; Mon, 17 Aug 2020 09:00:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D54113857C7D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Alex.Coplan@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=+CZnHJJpcfbIxPi11zT79NUcDq8AndzZ42zm9hpGKRI=; b=lSKchxZ299lKEMNvdK4+LGpKvCgyXBtqq11e/U79Kse+3G2kI34NZUz2nlVNzvPAjbiWao6j0ByweV5U1JNtTN255D3/7cooZ07LdDcKLR5n0gmAOisx+WjA4PXGpl9DbUzlPKKKVb0jrUAAcUpc5wZZlp1W3H6Oh36T/KFFFKY= Received: from AM6P195CA0037.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::14) by PR2PR08MB4761.eurprd08.prod.outlook.com (2603:10a6:101:17::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15; Mon, 17 Aug 2020 09:00:19 +0000 Received: from VE1EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:87:cafe::5a) by AM6P195CA0037.outlook.office365.com (2603:10a6:209:87::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Mon, 17 Aug 2020 09:00:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT007.mail.protection.outlook.com (10.152.18.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Mon, 17 Aug 2020 09:00:18 +0000 Received: ("Tessian outbound 34b830c8a0ef:v64"); Mon, 17 Aug 2020 09:00:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6c2d3e2c97b90781 X-CR-MTA-TID: 64aa7808 Received: from b5328bed116b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B01ADF59-1C4C-46F5-B169-37E5473A1DFE.1; Mon, 17 Aug 2020 08:59:39 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b5328bed116b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 17 Aug 2020 08:59:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEnQY18Dg4X4aG81Un/lxhW0TwM20TnVf+jMNKogGfLiu8+6iI9LaiojYg9Lw4Tuc+oDD75RXxna6c7wj7ca9jsjN0lqfODTuAb3EWXFXZMLag9sTRVLc5d+YiPgGZKvgAQ1bAlKDlogm4wAKDwbtEUyJ7kA5lLyWP6nmweoYBYemVAqWP+u10i57HORKMgKSlZcFgtfizdb7Bvh06y4MaN9Yi29A+GTAPEIe0HSwU1IB1m2Ur918Em7vH9uTE57C+XI+jjaQg5FZbPndZrozIwSEQo0E0dzDtptE4eE4m3+AxJe/r8EBOsZZnG0ItQKcvcPY4lo6mkGeFAXtpnZfg== 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-SenderADCheck; bh=+CZnHJJpcfbIxPi11zT79NUcDq8AndzZ42zm9hpGKRI=; b=AYo0AjcW8Tj/l8XMIaO/F7l0YoXMvwZREWmUvJoK9Gr6xCV5FXQTpntxvvBOJokbRoRs81SjXVz82mWgm0LbwEnWRfysfzJb+lWuygD64j8uK6QwgAY2pmG7KgkcaGrUPtLcIr6/ATM3XZc+1wPpS22gXfLHGzXrP431bgyPOouwD1wVojuiSmSnuq0EqLjM3Jvhyi1o4CPpK2mweARWp78QwLMpzMqQ6qq5ZJ//19czBVcNC4fmWQQuk8SC31gRXSja/8ihVT2dKxvdoVztw2vO33Nb3FkMffQqD2nNBuMbw+b5h2RYLOUvEftn66YHBVWfCGxZrDoNsR5iR9Wkcg== 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=+CZnHJJpcfbIxPi11zT79NUcDq8AndzZ42zm9hpGKRI=; b=lSKchxZ299lKEMNvdK4+LGpKvCgyXBtqq11e/U79Kse+3G2kI34NZUz2nlVNzvPAjbiWao6j0ByweV5U1JNtTN255D3/7cooZ07LdDcKLR5n0gmAOisx+WjA4PXGpl9DbUzlPKKKVb0jrUAAcUpc5wZZlp1W3H6Oh36T/KFFFKY= Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) by VI1PR08MB3693.eurprd08.prod.outlook.com (2603:10a6:803:ba::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.18; Mon, 17 Aug 2020 08:59:37 +0000 Received: from VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::b8ed:5041:249f:6770]) by VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::b8ed:5041:249f:6770%2]) with mapi id 15.20.3261.026; Mon, 17 Aug 2020 08:59:37 +0000 Date: Mon, 17 Aug 2020 09:59:34 +0100 From: Alex Coplan To: gcc-patches@gcc.gnu.org Subject: [PATCH] aarch64: Don't generate invalid zero/sign-extend syntax Message-ID: <20200817085933.z5fg52xopegjojtn@arm.com> Content-Disposition: inline User-Agent: NeoMutt/20171215 X-ClientProxiedBy: LNXP265CA0014.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::26) To VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.54) by LNXP265CA0014.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Mon, 17 Aug 2020 08:59:36 +0000 X-Originating-IP: [217.140.106.54] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 22ff2550-5c4e-4e3d-87a4-08d8428bf729 X-MS-TrafficTypeDiagnostic: VI1PR08MB3693:|PR2PR08MB4761: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xgSLSTHLkZj3ZDImlS01ZXECMxDvNoB36w+FKC84sqGWRKeAecSEnOY2l9eWNbBAkz1vzGtubC2L0JPwDRT5fmUcURF6gYdxKEiRLy3LDH4Mam4D7ut83l73h8ogBKGIN3kGanuZ9YBawgO7d5LY2Fjxv4iSPmbUyylmKcvE6MNyOC3f7PD+jXNi/+6sBDwy13VIv+vDwmlLOGRKROXNjl9SzVhBL8VY1edOloYiiVR99ODod4ckNtVu5k7LtbXDEzKqpfUkP9tPoo9jzCeSEr7jzBHQHViGeAglpAbq9hjdRzX9MntwVTtp2R1QF3VQv9eu6myecJ4fmn9CRv4/m0oMNnN+L6kaRYjevX4uqFrbEBqinhdRxaHRMxXmUaNO X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB4029.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(39860400002)(136003)(376002)(346002)(66476007)(33964004)(66556008)(66616009)(44144004)(66946007)(8936002)(8886007)(8676002)(478600001)(52116002)(7696005)(6916009)(21480400003)(956004)(2616005)(54906003)(36756003)(55016002)(86362001)(316002)(26005)(44832011)(186003)(83380400001)(2906002)(16526019)(1076003)(4326008)(235185007)(5660300002)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: KZI6EsByRYw+WTJDR226A8xGx2bdRQl2DymDnu8aulkt67TchzOSxYTWzUwj4D6/thJVfyK3E9pT814NtbeQuYj1gMdYe0hkXWrmX7La8RS4oggH+XOmxbmHM9fO83TrhgRN3PKrA4Xh7M7G2lb7OAmjsK0YTicE4M9Ah3qYiJm8BbxDEwxexXTj+cJMJopvwvMNDmqNnIGj1xlX2Be/jWfeS2queCp5VtFEogbg7eIxEiOA7b0qMFWrjEE8Ewwt/Jvu7J6yM6d3fGKTwlg/mgO9b821epBwGjhek5jANfbDqOgJzZbE2l2bLVOzZDHxiXHqg5l2/o0+3qiklRrO7EPzhf2MfGFpKAKvkimCzylRBvymoWEmnxi3lxUXcaEluExMF8A4zjnRTGU6NStCIIAXRaBB+ajZMkAKREENvboi1B6aka7jCNB3oyZbKKV3Xnjhk0AqN+W00lG1ueCw7RU2Hda1DwLThox5ddFM15+hR9d1sxQtr57qnusEylGrzFmpTuG17pl8OUWLCbEhMcpF0cHVAY188d0raKRvcUdtT5S0ynY3JdrUv5XbOqI8BaQIrQf6FOaNbhLUibjN0J/ESh/oWjQRdgPEqTtq/4TwdeKjJH3r1nRMkLuJk7fIKZrd995DBc3UfB71tJzLiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3693 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: babc32cf-1df6-4456-82fa-08d8428bddda X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ep2O4/mXMoC0FDihokri2SmufolpOT7XaN1hwLQJkhMI5491gCmOPW+OtlpsgjdMp0dWwmXjXFWpoUHUDF6SeqZttaF136gDqabjJA4pBo31UHVzq9mlhYx9kUQvFgWymLciZx4Y9ExeskIU7tCs2NOe0RGowMF9m3wg9jF9mHdA/82GBwRDHrozhM28mFbr4vcgpYTzkSGiCVkmkGQVwyYfYcN9oVH+JaQ+xZ4Vy44KCZrnAhbOvdQfDgn1bRnHhhCr5TFk+3u9dxxB9AOnovgUzE2x8AdSbsRtLafUO9lSVcfnn8ZQMPmH5j2W5IZ6JnhjO8eyptvqm6y15EbdFD/GtrDGHDZwGbls4ycBTFMmw2RsNRFp05vu3B/3mJFoxsFHvVnjwZ5VXZg5otKSgB1Dz0jr6pUJ0bYwJCkPum8= 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:(4636009)(39860400002)(376002)(396003)(136003)(346002)(46966005)(36756003)(55016002)(956004)(44832011)(336012)(2616005)(8936002)(8886007)(235185007)(5660300002)(86362001)(66616009)(70586007)(70206006)(1076003)(8676002)(54906003)(36906005)(26005)(316002)(2906002)(186003)(16526019)(33964004)(21480400003)(44144004)(82310400002)(356005)(81166007)(478600001)(7696005)(83380400001)(82740400003)(47076004)(6916009)(4326008)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2020 09:00:18.6067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22ff2550-5c4e-4e3d-87a4-08d8428bf729 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: VE1EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4761 X-Spam-Status: No, score=-15.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Earnshaw , Marcus Shawcroft Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hello, Given the following C function: double *f(double *p, unsigned x) { return p + x; } prior to this patch, GCC at -O2 would generate: f: add x0, x0, x1, uxtw 3 ret but this add instruction uses architecturally-invalid syntax: the width of the third operand conflicts with the width of the extension specifier. The third operand is only permitted to be an x register when the extension specifier is (u|s)xtx. This instruction, and analogous insns for adds, sub, subs, and cmp, are rejected by clang, but accepted by binutils. Assembling and disassembling such an insn with binutils gives the architecturally-valid version in the disassembly: 0: 8b214c00 add x0, x0, w1, uxtw #3 This patch fixes several patterns in the AArch64 backend to use the standard syntax as specified in the Arm ARM such that GCC's output can be assembled by assemblers other than GAS. Note that an obvious omission here is that this patch does not touch the mult patterns such as *add__mult_. I found that I couldn't hit these patterns with C code since multiplications by powers of two always get turned into shifts by earlier RTL passes. If there's a way to reliably hit these patterns, then perhaps these should be updated as well. Testing: * New test which checks for the correct syntax in all updated patterns (fails before and passes after the aarch64.md change). * New test can be assembled by both GAS and llvm-mc following the change. * Bootstrapped and regtested on aarch64-none-linux-gnu. OK for master? Thanks, Alex --- gcc/ChangeLog: * config/aarch64/aarch64.md (*adds__): Ensure extended operand agrees with width of extension specifier. (*subs__): Likewise. (*adds__shift_): Likewise. (*subs__shift_): Likewise. (*add__): Likewise. (*add__shft_): Likewise. (*add_uxt_shift2): Likewise. (*sub__): Likewise. (*sub__shft_): Likewise. (*sub_uxt_shift2): Likewise. (*cmp_swp__reg): Likewise. (*cmp_swp__shft_): Likewise. gcc/testsuite/ChangeLog: * gcc.target/aarch64/adds3.c: Fix test w.r.t. new syntax. * gcc.target/aarch64/cmp.c: Likewise. * gcc.target/aarch64/subs3.c: Likewise. * gcc.target/aarch64/subsp.c: Likewise. * gcc.target/aarch64/extend-syntax.c: New test. diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 9b20dd0b1a0..b1e83dfda78 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -2383,7 +2383,7 @@ (set (match_operand:GPI 0 "register_operand" "=r") (plus:GPI (ANY_EXTEND:GPI (match_dup 1)) (match_dup 2)))] "" - "adds\\t%0, %2, %1, xt" + "adds\\t%0, %2, %w1, xt" [(set_attr "type" "alus_ext")] ) @@ -2397,7 +2397,7 @@ (set (match_operand:GPI 0 "register_operand" "=r") (minus:GPI (match_dup 1) (ANY_EXTEND:GPI (match_dup 2))))] "" - "subs\\t%0, %1, %2, xt" + "subs\\t%0, %1, %w2, xt" [(set_attr "type" "alus_ext")] ) @@ -2415,7 +2415,7 @@ (match_dup 2)) (match_dup 3)))] "" - "adds\\t%0, %3, %1, xt %2" + "adds\\t%0, %3, %w1, xt %2" [(set_attr "type" "alus_ext")] ) @@ -2433,7 +2433,7 @@ (ashift:GPI (ANY_EXTEND:GPI (match_dup 2)) (match_dup 3))))] "" - "subs\\t%0, %1, %2, xt %3" + "subs\\t%0, %1, %w2, xt %3" [(set_attr "type" "alus_ext")] ) @@ -2549,7 +2549,7 @@ (plus:GPI (ANY_EXTEND:GPI (match_operand:ALLX 1 "register_operand" "r")) (match_operand:GPI 2 "register_operand" "r")))] "" - "add\\t%0, %2, %1, xt" + "add\\t%0, %2, %w1, xt" [(set_attr "type" "alu_ext")] ) @@ -2571,7 +2571,7 @@ (match_operand 2 "aarch64_imm3" "Ui3")) (match_operand:GPI 3 "register_operand" "r")))] "" - "add\\t%0, %3, %1, xt %2" + "add\\t%0, %3, %w1, xt %2" [(set_attr "type" "alu_ext")] ) @@ -2819,7 +2819,7 @@ "* operands[3] = GEN_INT (aarch64_uxt_size (INTVAL(operands[2]), INTVAL (operands[3]))); - return \"add\t%0, %4, %1, uxt%e3 %2\";" + return \"add\t%0, %4, %w1, uxt%e3 %2\";" [(set_attr "type" "alu_ext")] ) @@ -3305,7 +3305,7 @@ (ANY_EXTEND:GPI (match_operand:ALLX 2 "register_operand" "r"))))] "" - "sub\\t%0, %1, %2, xt" + "sub\\t%0, %1, %w2, xt" [(set_attr "type" "alu_ext")] ) @@ -3328,7 +3328,7 @@ (match_operand:ALLX 2 "register_operand" "r")) (match_operand 3 "aarch64_imm3" "Ui3"))))] "" - "sub\\t%0, %1, %2, xt %3" + "sub\\t%0, %1, %w2, xt %3" [(set_attr "type" "alu_ext")] ) @@ -3607,7 +3607,7 @@ "* operands[3] = GEN_INT (aarch64_uxt_size (INTVAL (operands[2]), INTVAL (operands[3]))); - return \"sub\t%0, %4, %1, uxt%e3 %2\";" + return \"sub\t%0, %4, %w1, uxt%e3 %2\";" [(set_attr "type" "alu_ext")] ) @@ -4054,7 +4054,7 @@ (match_operand:ALLX 0 "register_operand" "r")) (match_operand:GPI 1 "register_operand" "r")))] "" - "cmp\\t%1, %0, xt" + "cmp\\t%1, %w0, xt" [(set_attr "type" "alus_ext")] ) @@ -4066,7 +4066,7 @@ (match_operand 1 "aarch64_imm3" "Ui3")) (match_operand:GPI 2 "register_operand" "r")))] "" - "cmp\\t%2, %0, xt %1" + "cmp\\t%2, %w0, xt %1" [(set_attr "type" "alus_ext")] ) diff --git a/gcc/testsuite/gcc.target/aarch64/adds3.c b/gcc/testsuite/gcc.target/aarch64/adds3.c index c5518bdcaf2..e938c8049cf 100644 --- a/gcc/testsuite/gcc.target/aarch64/adds3.c +++ b/gcc/testsuite/gcc.target/aarch64/adds3.c @@ -58,4 +58,4 @@ int main () return 0; } -/* { dg-final { scan-assembler-times "adds\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, sxtw" 2 } } */ +/* { dg-final { scan-assembler-times "adds\tx\[0-9\]+, x\[0-9\]+, w\[0-9\]+, sxtw" 2 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/cmp.c b/gcc/testsuite/gcc.target/aarch64/cmp.c index ee57dd283bf..a6487a4f77a 100644 --- a/gcc/testsuite/gcc.target/aarch64/cmp.c +++ b/gcc/testsuite/gcc.target/aarch64/cmp.c @@ -58,4 +58,5 @@ cmp_di_test4 (int a, s64 b, s64 c) } /* { dg-final { scan-assembler-times "cmp\tw\[0-9\]+, w\[0-9\]+" 2 } } */ -/* { dg-final { scan-assembler-times "cmp\tx\[0-9\]+, x\[0-9\]+" 4 } } */ +/* { dg-final { scan-assembler-times "cmp\tx\[0-9\]+, x\[0-9\]+" 2 } } */ +/* { dg-final { scan-assembler-times "cmp\tx\[0-9\]+, w\[0-9\]+, sxtw" 2 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/extend-syntax.c b/gcc/testsuite/gcc.target/aarch64/extend-syntax.c new file mode 100644 index 00000000000..23fa9f4ffc5 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/extend-syntax.c @@ -0,0 +1,120 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +// Hits *add_uxtdi_shift2 (*add_uxt_shift2). +/* +** add1: +** add x0, x0, w1, uxtw 3 +** ret +*/ +unsigned long long *add1(unsigned long long *p, unsigned x) +{ + return p + x; +} + +// Hits *add_zero_extendsi_di (*add__). +/* +** add2: +** add x0, x0, w1, uxtw +** ret +*/ +unsigned long long add2(unsigned long long x, unsigned y) +{ + return x + y; +} + +// Hits *add_extendsi_shft_di (*add__shft_). +/* +** add3: +** add x0, x0, w1, sxtw 3 +** ret +*/ +double *add3(double *p, int x) +{ + return p + x; +} + +// Hits *sub_zero_extendsi_di (*sub__). +/* +** sub1: +** sub x0, x0, w1, uxtw +** ret +*/ +unsigned long long sub1(unsigned long long x, unsigned n) +{ + return x - n; +} + +// Hits *sub_uxtdi_shift2 (*sub_uxt_shift2). +/* +** sub2: +** sub x0, x0, w1, uxtw 3 +** ret +*/ +double *sub2(double *x, unsigned n) +{ + return x - n; +} + +// Hits *sub_extendsi_shft_di (*sub__shft_). +/* +** sub3: +** sub x0, x0, w1, sxtw 3 +** ret +*/ +double *sub3(double *p, int n) +{ + return p - n; +} + +// Hits *adds_zero_extendsi_di (*adds__). +int adds1(unsigned long long x, unsigned y) +{ + /* { dg-final { scan-assembler-times "adds\tx\[0-9\]+, x\[0-9\]+, w\[0-9\]+, uxtw" 1 } } */ + unsigned long long l = x + y; + return !!l; +} + +// Hits *adds_extendsi_shift_di (*adds__shift_). +int adds2(long long x, int y) +{ + /* { dg-final { scan-assembler-times "adds\tx\[0-9\]+, x\[0-9\]+, w\[0-9\]+, sxtw 3" 1 } } */ + long long t = x + ((long long)y << 3); + return !!t; +} + +// Hits *subs_zero_extendsi_di (*subs__). +unsigned long long z; +int subs1(unsigned long long x, unsigned y) +{ + /* { dg-final { scan-assembler-times "subs\tx\[0-9\]+, x\[0-9\]+, w\[0-9\]+, uxtw" 1 } } */ + unsigned long long t = x - y; + z = t; + return !!t; +} + +// Hits *subs_extendsi_shift_di (*subs__shift_). +unsigned long long *w; +int subs2(unsigned long long *x, int y) +{ + /* { dg-final { scan-assembler-times "subs\tx\[0-9\]+, x\[0-9\]+, w\[0-9\]+, sxtw 3" 1 } } */ + unsigned long long *t = x - y; + w = t; + return !!t; +} + +// Hits *cmp_swp_zero_extendsi_regdi (*cmp_swp__reg). +int cmp(unsigned long long x, unsigned y) +{ + /* { dg-final { scan-assembler-times "cmp\tx\[0-9\]+, w\[0-9\]+, uxtw" 1 } } */ + return !!(x - y); +} + +// Hits *cmp_swp_extendsi_shft_di (*cmp_swp__shft_). +int cmp2(unsigned long long x, int y) +{ + /* { dg-final { scan-assembler-times "cmp\tx\[0-9\]+, w\[0-9\]+, sxtw 3" 1 } } */ + return x == ((unsigned long long)y << 3); +} + +/* { dg-final { check-function-bodies "**" "" "" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/subs3.c b/gcc/testsuite/gcc.target/aarch64/subs3.c index 59581bf1ab7..0470a3bde34 100644 --- a/gcc/testsuite/gcc.target/aarch64/subs3.c +++ b/gcc/testsuite/gcc.target/aarch64/subs3.c @@ -58,4 +58,4 @@ int main () return 0; } -/* { dg-final { scan-assembler-times "subs\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, sxtw" 2 } } */ +/* { dg-final { scan-assembler-times "subs\tx\[0-9\]+, x\[0-9\]+, w\[0-9\]+, sxtw" 2 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/subsp.c b/gcc/testsuite/gcc.target/aarch64/subsp.c index 6ef6b2c90ae..341b83dca86 100644 --- a/gcc/testsuite/gcc.target/aarch64/subsp.c +++ b/gcc/testsuite/gcc.target/aarch64/subsp.c @@ -16,4 +16,4 @@ f2 (int *x, int y) } /* { dg-final { scan-assembler "sub\tsp, sp, x\[0-9\]*\n" } } */ -/* { dg-final { scan-assembler "sub\tsp, sp, x\[0-9\]*, sxtw 4\n" } } */ +/* { dg-final { scan-assembler "sub\tsp, sp, w\[0-9\]*, sxtw 4\n" } } */