Message ID | 20210929162001.GA31867@arm.com |
---|---|
State | Committed |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2B35385802A for <patchwork@sourceware.org>; Wed, 29 Sep 2021 16:23:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2B35385802A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632932614; bh=3GZPMRa5Z5sRUQKhiuQjrG9ROvqSL+OotmnoqSacgCE=; h=Date:To:Subject:In-Reply-To:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=C9EqXkKlQtset7QRAO6+iVKwuahKMucHHH6kQCJ5K/Pwzi3kulooJRqwZYZqhOW6Q Xh8OBZsqKA/WXcA3Fazxgvgh1/xXgabyrPYhMojb+mBoZPNDsU+q5tGUQacTrI+rys 3DtP5a45Cn8K7Bew88/EtbYfW0ypkF2uPQEEKoM4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40041.outbound.protection.outlook.com [40.107.4.41]) by sourceware.org (Postfix) with ESMTPS id 095FB3858406 for <gcc-patches@gcc.gnu.org>; Wed, 29 Sep 2021 16:20:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 095FB3858406 Received: from AM4PR05CA0011.eurprd05.prod.outlook.com (2603:10a6:205::24) by AM6PR08MB4311.eurprd08.prod.outlook.com (2603:10a6:20b:b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.18; Wed, 29 Sep 2021 16:20:20 +0000 Received: from AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:205:0:cafe::34) by AM4PR05CA0011.outlook.office365.com (2603:10a6:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Wed, 29 Sep 2021 16:20:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.33.187.114) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.33.187.114 as permitted sender) receiver=protection.outlook.com; client-ip=63.33.187.114; helo=64aa7808-outbound-2.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-2.mta.getcheckrecipient.com (63.33.187.114) by AM5EUR03FT023.mail.protection.outlook.com (10.152.16.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Wed, 29 Sep 2021 16:20:20 +0000 Received: ("Tessian outbound ac52c8afb262:v103"); Wed, 29 Sep 2021 16:20:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cec3cc4d40e2053e X-CR-MTA-TID: 64aa7808 Received: from 661a67355e49.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C5CA813C-3F11-4785-B1DA-258DC9234266.1; Wed, 29 Sep 2021 16:20:08 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 661a67355e49.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 29 Sep 2021 16:20:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TbsJSMq22vmL/saRzfHj3gW0ooH4P5Ogxs1+zWTI37xUVDgGqXpzao2B0JCjP3flklhyJi2TVocSLjs2scjJ9v+h0QhBp6595ST8SEcyOhnh9UnCKP5q4RHCok67Jwa3omTGNqsATuD7m/S7Nq0o/oggZY91QnEbSAMidQylwqXoTAbBQumoWmA7jbTCZ2vlwCkCPXYH5ncbSkqi/ftYaD9XGItm1pJAPth/qpQEzJwrvFgcNbf0PUCVCLTl1g9cIcgKRlb5zE4d62Zf+NKwBWJEDs9tpnRmOYxXNfPOGTo+myoTPdfBWt9uQJoZu6VIbZfOtsHdP+3Mq/a6EuECHQ== 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; bh=3GZPMRa5Z5sRUQKhiuQjrG9ROvqSL+OotmnoqSacgCE=; b=fUCeWh1AuyKjIjfz+HRNW9ydoYv72+9P3TwXZYrjcmUAJxQjcwvkCHBkudXUeeicKmisvBiVoLn89UFYBEchfnZhFsfpT+AeLetO9UB3ODuFjio3wF1h60Pode2d1KlUXS/i27+aOFt5mMzA1Gzohs9AjJKJLBotiygm6oO3NJNpd3dWSkWQoOYXa/kDKcV/f2f7TIQ+yD4R4pQcjWc65Ydfzd5DTXJHZS4Gj3CKkMz+haE6rDuKxzzIl/D6uLqSsF8Jpcg4joRz9yjgFLYpBlsemVtSo/brGBXIcsVhN4KXEw8ikdKqw4atS5sXHT/kEd2Nd5BVRw6A81inbL96WQ== 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 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 VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by VI1PR0801MB1728.eurprd08.prod.outlook.com (2603:10a6:800:54::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.20; Wed, 29 Sep 2021 16:20:05 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bd45:5ad5:f666:272a]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bd45:5ad5:f666:272a%5]) with mapi id 15.20.4544.022; Wed, 29 Sep 2021 16:20:05 +0000 Date: Wed, 29 Sep 2021 17:20:02 +0100 To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt Message-ID: <20210929162001.GA31867@arm.com> Content-Type: multipart/mixed; boundary="7AUc2qLy4jB3hD7Z" Content-Disposition: inline In-Reply-To: <patch-14899-tamar@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-ClientProxiedBy: LO2P265CA0387.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:f::15) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 Received: from arm.com (217.140.106.55) by LO2P265CA0387.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Wed, 29 Sep 2021 16:20:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a47fec62-7c62-42bc-7b0a-08d98365085d X-MS-TrafficTypeDiagnostic: VI1PR0801MB1728:|AM6PR08MB4311: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: <AM6PR08MB43115BE58B5F5E3DAC6DDE2CFFA99@AM6PR08MB4311.eurprd08.prod.outlook.com> x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WAxX8B8OR5+jErmV06zmyqRYwLpRBJAy8f8IvcOACXznHefDK6BD1BAtaE2xEUAnL44xrEArWGorv293Ss7YpvDUXdV8P0kMbQI+2N2BpoAlLfMEfe3sqVK31hGOMixCllYRJvH7IchAHQUjq3cEMe31JeABg3uMA7v/vVp1EOtxDAaHBt56k7zx/LxQQup9wztDZL/60A32mkxyaHN1d0Leo9odFi6v7nzmtEbSuLcTbh0b0YkrINA0uo/4SBZwWxWGFpunPzR3zmKZ/hFl2XvunTwEumkG7D1PPjmTSN3i4HLUa3GzjW9f7jUuG2+KDozxHXj4fKGC0vHdIDyxJo3d+9IgT61F0A27wA+hgmx223GEwVV6orj/fe3gaINvc1ZRUQGvshrhDM5cgQ2xcp6tBC9jyUToEq+zrPOby6HeoUckHuH57S88JH4WS464zZWrHt6uFu5Gk1UFokZOsRuT1DkltVZVcwTEAVqj3LJKsLhFNs1FS24t8HqGnFmn+W3I4QR8j4dbz77mrmHOrosf75Kxu/FMYDuXkko3Qxfu/EpbJxiVnUgCvyDbaB5DYNHDXPCv8IGUJx5J+Lr8xC/PqdQWC15rbbM/UKrHUVid7CsvgGA6+YI7UJeYA0xu+p/uMsNWDS5Se09ZcHIY5+ZUdDi0ABn+QhHwjbGefnX0UvTkYCgxHBhEA25x0yuvCQtIsbWL4gBDRcYMTnCSIEQF0blicMv79Ws7m0IGPAUWiYYzZqy4whJKX1S0JzwWDBCqsge+T3KwdnrpPr5xjWpxRBk/TFf8hQDCbPXWnnglf/DQ9rgWgU9iD84vdHFL 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:(4636009)(366004)(44144004)(7696005)(1076003)(36756003)(316002)(66946007)(33656002)(186003)(26005)(66556008)(52116002)(8676002)(5660300002)(33964004)(38100700002)(38350700002)(508600001)(66616009)(8886007)(8936002)(66476007)(6916009)(55016002)(235185007)(2616005)(4743002)(44832011)(4326008)(2906002)(86362001)(956004)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1728 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: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a602b144-f79a-4d55-485d-08d98364ff33 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SyaZCfhJvnnUhq/K0YCcWhpjosElZs66hakp1S7v0+Z4yXTwZbPmDUN2twPLO9Btw4Y0ttmU+LLFfxKZMPTUdCUcdVHQLuHT8IHbS4eft0x5R0ZXevuW5Pgks14JeeTgIYp7CjfrPRMWbhJzGvpsHkDOGJXdEwhCHbtJnD81nuyQ1/IxR2MLZRtTcM6eAJ3xblK4EWRQJeXApoCm/qmjI1/futMDNStbLX28HNKY5rAoK4ogenWfhrviZDeagfpUNkb3hwVkE4W9gIBVXk8LzYzl/3gzQ7qjSR6u5MmqTOIFq7WSNn0A+YrPC1L/Y+EGvkOBamJ32HQKyG7MiF1RzeMOO2tyquojx4TJggXSBMBuEfzl5IKEv/ociaSmB8wwdAkmkX/fqB8QwFyxUnh7NRk/HgThymttVCCoJZ284KiIMO7NYp0BmiRSiyx60gO9yaB92Z4tXXs9J9pHpbNaK9gR766G9f0tepRK/wSwaIQVE07akGfv58lU8WSoZz+Z3UHI4MtZq857Y45L07r/4TxCaRN+qAPq3EG4saEVuJwAPdGDN7Nu6SN5eMIx17xtHQt4M4FdKRDr85OwfS4djjjBOTVU+BNXqmd4MssZBLpVh66sxu5tpb1T4h2X/RGOBBGF0ffhtLwWBNT9mVUiSBNQhwK0gYJkpT+vlu/TtYFZx2tm5b7T086OS5d/O7SqIMl7Z92sjc6oiUU3lN0WWS0ZqFyjGTKBTYdn6TEL1qWuqPwDJe1BOXNIdQWmitPnhImSQ96EJBjpchfrbU4TlvF1h5CetoxEQmhrUHQwgoQjrDTgCh/sFw5JQZrnBouO X-Forefront-Antispam-Report: CIP:63.33.187.114; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-2.mta.getcheckrecipient.com; PTR:ec2-63-33-187-114.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(8676002)(4326008)(508600001)(55016002)(6916009)(81166007)(82310400003)(4743002)(44832011)(956004)(8936002)(33964004)(8886007)(1076003)(2616005)(186003)(33656002)(235185007)(44144004)(26005)(66616009)(36860700001)(356005)(70586007)(70206006)(7696005)(36756003)(336012)(86362001)(5660300002)(316002)(2906002)(47076005)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2021 16:20:20.2966 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a47fec62-7c62-42bc-7b0a-08d98365085d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.33.187.114]; Helo=[64aa7808-outbound-2.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4311 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Tamar Christina via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Tamar Christina <tamar.christina@arm.com> Cc: Richard.Earnshaw@arm.com, nd@arm.com, richard.sandiford@arm.com, Marcus.Shawcroft@arm.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
AArch64 Optimize truncation, shifts and bitmask comparisons
|
|
Commit Message
Tamar Christina
Sept. 29, 2021, 4:20 p.m. UTC
Hi All, This optimizes signed right shift by BITSIZE-1 into a cmlt operation which is more optimal because generally compares have a higher throughput than shifts. On AArch64 the result of the shift would have been either -1 or 0 which is the results of the compare. i.e. void e (int * restrict a, int *b, int n) { for (int i = 0; i < n; i++) b[i] = a[i] >> 31; } now generates: .L4: ldr q0, [x0, x3] cmlt v0.4s, v0.4s, #0 str q0, [x1, x3] add x3, x3, 16 cmp x4, x3 bne .L4 instead of: .L4: ldr q0, [x0, x3] sshr v0.4s, v0.4s, 31 str q0, [x1, x3] add x3, x3, 16 cmp x4, x3 bne .L4 Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_simd_ashr<mode>): Add case cmp case. * config/aarch64/constraints.md (D1): New. gcc/testsuite/ChangeLog: * gcc.target/aarch64/shl-combine-2.c: New test. --- inline copy of patch -- diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 300bf001b59ca7fa197c580b10adb7f70f20d1e0..19b2d0ad4dab4d5742698297ded861228ee22007 100644 --
Comments
> -----Original Message----- > From: Tamar Christina <Tamar.Christina@arm.com> > Sent: Wednesday, September 29, 2021 5:20 PM > To: gcc-patches@gcc.gnu.org > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > <Richard.Sandiford@arm.com> > Subject: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt > > Hi All, > > This optimizes signed right shift by BITSIZE-1 into a cmlt operation which is > more optimal because generally compares have a higher throughput than > shifts. > > On AArch64 the result of the shift would have been either -1 or 0 which is the > results of the compare. > > i.e. > > void e (int * restrict a, int *b, int n) > { > for (int i = 0; i < n; i++) > b[i] = a[i] >> 31; > } > > now generates: > > .L4: > ldr q0, [x0, x3] > cmlt v0.4s, v0.4s, #0 > str q0, [x1, x3] > add x3, x3, 16 > cmp x4, x3 > bne .L4 > > instead of: > > .L4: > ldr q0, [x0, x3] > sshr v0.4s, v0.4s, 31 > str q0, [x1, x3] > add x3, x3, 16 > cmp x4, x3 > bne .L4 > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? This should be okay (either a win or neutral) for Arm Cortex and Neoverse cores so I'm tempted to not ask for a CPU-specific tunable to guard it to keep the code clean. Andrew, would this change be okay from a Thunder X line perspective? Thanks, Kyrill > > Thanks, > Tamar > > gcc/ChangeLog: > > * config/aarch64/aarch64-simd.md (aarch64_simd_ashr<mode>): > Add case cmp > case. > * config/aarch64/constraints.md (D1): New. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/shl-combine-2.c: New test. > > --- inline copy of patch -- > diff --git a/gcc/config/aarch64/aarch64-simd.md > b/gcc/config/aarch64/aarch64-simd.md > index > 300bf001b59ca7fa197c580b10adb7f70f20d1e0..19b2d0ad4dab4d574269829 > 7ded861228ee22007 100644 > --- a/gcc/config/aarch64/aarch64-simd.md > +++ b/gcc/config/aarch64/aarch64-simd.md > @@ -1127,12 +1127,14 @@ (define_insn "aarch64_simd_lshr<mode>" > ) > > (define_insn "aarch64_simd_ashr<mode>" > - [(set (match_operand:VDQ_I 0 "register_operand" "=w") > - (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w") > - (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > "Dr")))] > + [(set (match_operand:VDQ_I 0 "register_operand" "=w,w") > + (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w,w") > + (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > "D1,Dr")))] > "TARGET_SIMD" > - "sshr\t%0.<Vtype>, %1.<Vtype>, %2" > - [(set_attr "type" "neon_shift_imm<q>")] > + "@ > + cmlt\t%0.<Vtype>, %1.<Vtype>, #0 > + sshr\t%0.<Vtype>, %1.<Vtype>, %2" > + [(set_attr "type" "neon_compare<q>,neon_shift_imm<q>")] > ) > > (define_insn "*aarch64_simd_sra<mode>" > diff --git a/gcc/config/aarch64/constraints.md > b/gcc/config/aarch64/constraints.md > index > 3b49b452119c49320020fa9183314d9a25b92491..18630815ffc13f2168300a89 > 9db69fd428dfb0d6 100644 > --- a/gcc/config/aarch64/constraints.md > +++ b/gcc/config/aarch64/constraints.md > @@ -437,6 +437,14 @@ (define_constraint "Dl" > (match_test "aarch64_simd_shift_imm_p (op, GET_MODE (op), > true)"))) > > +(define_constraint "D1" > + "@internal > + A constraint that matches vector of immediates that is bits(mode)-1." > + (and (match_code "const,const_vector") > + (match_test "aarch64_const_vec_all_same_in_range_p (op, > + GET_MODE_UNIT_BITSIZE (mode) - 1, > + GET_MODE_UNIT_BITSIZE (mode) - 1)"))) > + > (define_constraint "Dr" > "@internal > A constraint that matches vector of immediates for right shifts." > diff --git a/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..bdfe35d09ffccc7928947c9e > 57f1034f7ca2c798 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > @@ -0,0 +1,12 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +void e (int * restrict a, int *b, int n) > +{ > + for (int i = 0; i < n; i++) > + b[i] = a[i] >> 31; > +} > + > +/* { dg-final { scan-assembler-times {\tcmlt\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\tsshr\t} } } */ > + > > > --
On Thu, Sep 30, 2021 at 2:28 AM Kyrylo Tkachov via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > -----Original Message----- > > From: Tamar Christina <Tamar.Christina@arm.com> > > Sent: Wednesday, September 29, 2021 5:20 PM > > To: gcc-patches@gcc.gnu.org > > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > > <Richard.Sandiford@arm.com> > > Subject: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt > > > > Hi All, > > > > This optimizes signed right shift by BITSIZE-1 into a cmlt operation which is > > more optimal because generally compares have a higher throughput than > > shifts. > > > > On AArch64 the result of the shift would have been either -1 or 0 which is the > > results of the compare. > > > > i.e. > > > > void e (int * restrict a, int *b, int n) > > { > > for (int i = 0; i < n; i++) > > b[i] = a[i] >> 31; > > } > > > > now generates: > > > > .L4: > > ldr q0, [x0, x3] > > cmlt v0.4s, v0.4s, #0 > > str q0, [x1, x3] > > add x3, x3, 16 > > cmp x4, x3 > > bne .L4 > > > > instead of: > > > > .L4: > > ldr q0, [x0, x3] > > sshr v0.4s, v0.4s, 31 > > str q0, [x1, x3] > > add x3, x3, 16 > > cmp x4, x3 > > bne .L4 > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > > > Ok for master? > > This should be okay (either a win or neutral) for Arm Cortex and Neoverse cores so I'm tempted to not ask for a CPU-specific tunable to guard it to keep the code clean. > Andrew, would this change be okay from a Thunder X line perspective? I don't know about ThunderX2 but here are the details for ThunderX1 (and OcteonX1) and OcteonX2: The sshr and cmlt are handled the same in the pipeline as far as I can tell. Thanks, Andrew > Thanks, > Kyrill > > > > > Thanks, > > Tamar > > > > gcc/ChangeLog: > > > > * config/aarch64/aarch64-simd.md (aarch64_simd_ashr<mode>): > > Add case cmp > > case. > > * config/aarch64/constraints.md (D1): New. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/aarch64/shl-combine-2.c: New test. > > > > --- inline copy of patch -- > > diff --git a/gcc/config/aarch64/aarch64-simd.md > > b/gcc/config/aarch64/aarch64-simd.md > > index > > 300bf001b59ca7fa197c580b10adb7f70f20d1e0..19b2d0ad4dab4d574269829 > > 7ded861228ee22007 100644 > > --- a/gcc/config/aarch64/aarch64-simd.md > > +++ b/gcc/config/aarch64/aarch64-simd.md > > @@ -1127,12 +1127,14 @@ (define_insn "aarch64_simd_lshr<mode>" > > ) > > > > (define_insn "aarch64_simd_ashr<mode>" > > - [(set (match_operand:VDQ_I 0 "register_operand" "=w") > > - (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w") > > - (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > > "Dr")))] > > + [(set (match_operand:VDQ_I 0 "register_operand" "=w,w") > > + (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w,w") > > + (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > > "D1,Dr")))] > > "TARGET_SIMD" > > - "sshr\t%0.<Vtype>, %1.<Vtype>, %2" > > - [(set_attr "type" "neon_shift_imm<q>")] > > + "@ > > + cmlt\t%0.<Vtype>, %1.<Vtype>, #0 > > + sshr\t%0.<Vtype>, %1.<Vtype>, %2" > > + [(set_attr "type" "neon_compare<q>,neon_shift_imm<q>")] > > ) > > > > (define_insn "*aarch64_simd_sra<mode>" > > diff --git a/gcc/config/aarch64/constraints.md > > b/gcc/config/aarch64/constraints.md > > index > > 3b49b452119c49320020fa9183314d9a25b92491..18630815ffc13f2168300a89 > > 9db69fd428dfb0d6 100644 > > --- a/gcc/config/aarch64/constraints.md > > +++ b/gcc/config/aarch64/constraints.md > > @@ -437,6 +437,14 @@ (define_constraint "Dl" > > (match_test "aarch64_simd_shift_imm_p (op, GET_MODE (op), > > true)"))) > > > > +(define_constraint "D1" > > + "@internal > > + A constraint that matches vector of immediates that is bits(mode)-1." > > + (and (match_code "const,const_vector") > > + (match_test "aarch64_const_vec_all_same_in_range_p (op, > > + GET_MODE_UNIT_BITSIZE (mode) - 1, > > + GET_MODE_UNIT_BITSIZE (mode) - 1)"))) > > + > > (define_constraint "Dr" > > "@internal > > A constraint that matches vector of immediates for right shifts." > > diff --git a/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > new file mode 100644 > > index > > 0000000000000000000000000000000000000000..bdfe35d09ffccc7928947c9e > > 57f1034f7ca2c798 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > @@ -0,0 +1,12 @@ > > +/* { dg-do assemble } */ > > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > > + > > +void e (int * restrict a, int *b, int n) > > +{ > > + for (int i = 0; i < n; i++) > > + b[i] = a[i] >> 31; > > +} > > + > > +/* { dg-final { scan-assembler-times {\tcmlt\t} 1 } } */ > > +/* { dg-final { scan-assembler-not {\tsshr\t} } } */ > > + > > > > > > --
> -----Original Message----- > From: Andrew Pinski <pinskia@gmail.com> > Sent: Monday, October 11, 2021 8:56 PM > To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com> > Cc: Tamar Christina <Tamar.Christina@arm.com>; gcc-patches@gcc.gnu.org; > apinski@marvell.com; Richard Earnshaw <Richard.Earnshaw@arm.com>; nd > <nd@arm.com>; Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Richard > Sandiford <Richard.Sandiford@arm.com> > Subject: Re: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt > > On Thu, Sep 30, 2021 at 2:28 AM Kyrylo Tkachov via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > -----Original Message----- > > > From: Tamar Christina <Tamar.Christina@arm.com> > > > Sent: Wednesday, September 29, 2021 5:20 PM > > > To: gcc-patches@gcc.gnu.org > > > Cc: nd <nd@arm.com>; Richard Earnshaw > <Richard.Earnshaw@arm.com>; > > > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > > > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > > > <Richard.Sandiford@arm.com> > > > Subject: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt > > > > > > Hi All, > > > > > > This optimizes signed right shift by BITSIZE-1 into a cmlt operation which > is > > > more optimal because generally compares have a higher throughput than > > > shifts. > > > > > > On AArch64 the result of the shift would have been either -1 or 0 which is > the > > > results of the compare. > > > > > > i.e. > > > > > > void e (int * restrict a, int *b, int n) > > > { > > > for (int i = 0; i < n; i++) > > > b[i] = a[i] >> 31; > > > } > > > > > > now generates: > > > > > > .L4: > > > ldr q0, [x0, x3] > > > cmlt v0.4s, v0.4s, #0 > > > str q0, [x1, x3] > > > add x3, x3, 16 > > > cmp x4, x3 > > > bne .L4 > > > > > > instead of: > > > > > > .L4: > > > ldr q0, [x0, x3] > > > sshr v0.4s, v0.4s, 31 > > > str q0, [x1, x3] > > > add x3, x3, 16 > > > cmp x4, x3 > > > bne .L4 > > > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > > > > > Ok for master? > > > > This should be okay (either a win or neutral) for Arm Cortex and Neoverse > cores so I'm tempted to not ask for a CPU-specific tunable to guard it to keep > the code clean. > > Andrew, would this change be okay from a Thunder X line perspective? > > I don't know about ThunderX2 but here are the details for ThunderX1 > (and OcteonX1) and OcteonX2: > The sshr and cmlt are handled the same in the pipeline as far as I can tell. > Thanks for the info. This patch is ok. Kyrill > Thanks, > Andrew > > > > > Thanks, > > Kyrill > > > > > > > > Thanks, > > > Tamar > > > > > > gcc/ChangeLog: > > > > > > * config/aarch64/aarch64-simd.md (aarch64_simd_ashr<mode>): > > > Add case cmp > > > case. > > > * config/aarch64/constraints.md (D1): New. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * gcc.target/aarch64/shl-combine-2.c: New test. > > > > > > --- inline copy of patch -- > > > diff --git a/gcc/config/aarch64/aarch64-simd.md > > > b/gcc/config/aarch64/aarch64-simd.md > > > index > > > > 300bf001b59ca7fa197c580b10adb7f70f20d1e0..19b2d0ad4dab4d574269829 > > > 7ded861228ee22007 100644 > > > --- a/gcc/config/aarch64/aarch64-simd.md > > > +++ b/gcc/config/aarch64/aarch64-simd.md > > > @@ -1127,12 +1127,14 @@ (define_insn "aarch64_simd_lshr<mode>" > > > ) > > > > > > (define_insn "aarch64_simd_ashr<mode>" > > > - [(set (match_operand:VDQ_I 0 "register_operand" "=w") > > > - (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w") > > > - (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > > > "Dr")))] > > > + [(set (match_operand:VDQ_I 0 "register_operand" "=w,w") > > > + (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w,w") > > > + (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > > > "D1,Dr")))] > > > "TARGET_SIMD" > > > - "sshr\t%0.<Vtype>, %1.<Vtype>, %2" > > > - [(set_attr "type" "neon_shift_imm<q>")] > > > + "@ > > > + cmlt\t%0.<Vtype>, %1.<Vtype>, #0 > > > + sshr\t%0.<Vtype>, %1.<Vtype>, %2" > > > + [(set_attr "type" "neon_compare<q>,neon_shift_imm<q>")] > > > ) > > > > > > (define_insn "*aarch64_simd_sra<mode>" > > > diff --git a/gcc/config/aarch64/constraints.md > > > b/gcc/config/aarch64/constraints.md > > > index > > > > 3b49b452119c49320020fa9183314d9a25b92491..18630815ffc13f2168300a89 > > > 9db69fd428dfb0d6 100644 > > > --- a/gcc/config/aarch64/constraints.md > > > +++ b/gcc/config/aarch64/constraints.md > > > @@ -437,6 +437,14 @@ (define_constraint "Dl" > > > (match_test "aarch64_simd_shift_imm_p (op, GET_MODE (op), > > > true)"))) > > > > > > +(define_constraint "D1" > > > + "@internal > > > + A constraint that matches vector of immediates that is bits(mode)-1." > > > + (and (match_code "const,const_vector") > > > + (match_test "aarch64_const_vec_all_same_in_range_p (op, > > > + GET_MODE_UNIT_BITSIZE (mode) - 1, > > > + GET_MODE_UNIT_BITSIZE (mode) - 1)"))) > > > + > > > (define_constraint "Dr" > > > "@internal > > > A constraint that matches vector of immediates for right shifts." > > > diff --git a/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > > b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > > new file mode 100644 > > > index > > > > 0000000000000000000000000000000000000000..bdfe35d09ffccc7928947c9e > > > 57f1034f7ca2c798 > > > --- /dev/null > > > +++ b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > > @@ -0,0 +1,12 @@ > > > +/* { dg-do assemble } */ > > > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } > */ > > > + > > > +void e (int * restrict a, int *b, int n) > > > +{ > > > + for (int i = 0; i < n; i++) > > > + b[i] = a[i] >> 31; > > > +} > > > + > > > +/* { dg-final { scan-assembler-times {\tcmlt\t} 1 } } */ > > > +/* { dg-final { scan-assembler-not {\tsshr\t} } } */ > > > + > > > > > > > > > --
Thanks, Just archiving a version with more tests as requested. I will assume the OK still stands. Regards, Tamar > -----Original Message----- > From: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com> > Sent: Tuesday, October 12, 2021 1:19 PM > To: Andrew Pinski <pinskia@gmail.com> > Cc: Tamar Christina <Tamar.Christina@arm.com>; gcc-patches@gcc.gnu.org; > apinski@marvell.com; Richard Earnshaw <Richard.Earnshaw@arm.com>; nd > <nd@arm.com>; Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Richard > Sandiford <Richard.Sandiford@arm.com> > Subject: RE: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt > > > > > -----Original Message----- > > From: Andrew Pinski <pinskia@gmail.com> > > Sent: Monday, October 11, 2021 8:56 PM > > To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com> > > Cc: Tamar Christina <Tamar.Christina@arm.com>; > > gcc-patches@gcc.gnu.org; apinski@marvell.com; Richard Earnshaw > > <Richard.Earnshaw@arm.com>; nd <nd@arm.com>; Marcus Shawcroft > > <Marcus.Shawcroft@arm.com>; Richard Sandiford > > <Richard.Sandiford@arm.com> > > Subject: Re: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt > > > > On Thu, Sep 30, 2021 at 2:28 AM Kyrylo Tkachov via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > > > > -----Original Message----- > > > > From: Tamar Christina <Tamar.Christina@arm.com> > > > > Sent: Wednesday, September 29, 2021 5:20 PM > > > > To: gcc-patches@gcc.gnu.org > > > > Cc: nd <nd@arm.com>; Richard Earnshaw > > <Richard.Earnshaw@arm.com>; > > > > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Kyrylo Tkachov > > > > <Kyrylo.Tkachov@arm.com>; Richard Sandiford > > > > <Richard.Sandiford@arm.com> > > > > Subject: [PATCH 3/7]AArch64 Add pattern for sshr to cmlt > > > > > > > > Hi All, > > > > > > > > This optimizes signed right shift by BITSIZE-1 into a cmlt > > > > operation which > > is > > > > more optimal because generally compares have a higher throughput > > > > than shifts. > > > > > > > > On AArch64 the result of the shift would have been either -1 or 0 > > > > which is > > the > > > > results of the compare. > > > > > > > > i.e. > > > > > > > > void e (int * restrict a, int *b, int n) { > > > > for (int i = 0; i < n; i++) > > > > b[i] = a[i] >> 31; > > > > } > > > > > > > > now generates: > > > > > > > > .L4: > > > > ldr q0, [x0, x3] > > > > cmlt v0.4s, v0.4s, #0 > > > > str q0, [x1, x3] > > > > add x3, x3, 16 > > > > cmp x4, x3 > > > > bne .L4 > > > > > > > > instead of: > > > > > > > > .L4: > > > > ldr q0, [x0, x3] > > > > sshr v0.4s, v0.4s, 31 > > > > str q0, [x1, x3] > > > > add x3, x3, 16 > > > > cmp x4, x3 > > > > bne .L4 > > > > > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > > > > > > > Ok for master? > > > > > > This should be okay (either a win or neutral) for Arm Cortex and > > > Neoverse > > cores so I'm tempted to not ask for a CPU-specific tunable to guard it > > to keep the code clean. > > > Andrew, would this change be okay from a Thunder X line perspective? > > > > I don't know about ThunderX2 but here are the details for ThunderX1 > > (and OcteonX1) and OcteonX2: > > The sshr and cmlt are handled the same in the pipeline as far as I can tell. > > > > Thanks for the info. > This patch is ok. > Kyrill > > > Thanks, > > Andrew > > > > > > > > > Thanks, > > > Kyrill > > > > > > > > > > > Thanks, > > > > Tamar > > > > > > > > gcc/ChangeLog: > > > > > > > > * config/aarch64/aarch64-simd.md (aarch64_simd_ashr<mode>): > > > > Add case cmp > > > > case. > > > > * config/aarch64/constraints.md (D1): New. > > > > > > > > gcc/testsuite/ChangeLog: > > > > > > > > * gcc.target/aarch64/shl-combine-2.c: New test. > > > > > > > > --- inline copy of patch -- > > > > diff --git a/gcc/config/aarch64/aarch64-simd.md > > > > b/gcc/config/aarch64/aarch64-simd.md > > > > index > > > > > > 300bf001b59ca7fa197c580b10adb7f70f20d1e0..19b2d0ad4dab4d574269829 > > > > 7ded861228ee22007 100644 > > > > --- a/gcc/config/aarch64/aarch64-simd.md > > > > +++ b/gcc/config/aarch64/aarch64-simd.md > > > > @@ -1127,12 +1127,14 @@ (define_insn "aarch64_simd_lshr<mode>" > > > > ) > > > > > > > > (define_insn "aarch64_simd_ashr<mode>" > > > > - [(set (match_operand:VDQ_I 0 "register_operand" "=w") > > > > - (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w") > > > > - (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > > > > "Dr")))] > > > > + [(set (match_operand:VDQ_I 0 "register_operand" "=w,w") > > > > + (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" > "w,w") > > > > + (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" > > > > "D1,Dr")))] > > > > "TARGET_SIMD" > > > > - "sshr\t%0.<Vtype>, %1.<Vtype>, %2" > > > > - [(set_attr "type" "neon_shift_imm<q>")] > > > > + "@ > > > > + cmlt\t%0.<Vtype>, %1.<Vtype>, #0 sshr\t%0.<Vtype>, %1.<Vtype>, > > > > + %2" > > > > + [(set_attr "type" "neon_compare<q>,neon_shift_imm<q>")] > > > > ) > > > > > > > > (define_insn "*aarch64_simd_sra<mode>" > > > > diff --git a/gcc/config/aarch64/constraints.md > > > > b/gcc/config/aarch64/constraints.md > > > > index > > > > > > 3b49b452119c49320020fa9183314d9a25b92491..18630815ffc13f2168300a89 > > > > 9db69fd428dfb0d6 100644 > > > > --- a/gcc/config/aarch64/constraints.md > > > > +++ b/gcc/config/aarch64/constraints.md > > > > @@ -437,6 +437,14 @@ (define_constraint "Dl" > > > > (match_test "aarch64_simd_shift_imm_p (op, GET_MODE (op), > > > > true)"))) > > > > > > > > +(define_constraint "D1" > > > > + "@internal > > > > + A constraint that matches vector of immediates that is bits(mode)-1." > > > > + (and (match_code "const,const_vector") > > > > + (match_test "aarch64_const_vec_all_same_in_range_p (op, > > > > + GET_MODE_UNIT_BITSIZE (mode) - 1, > > > > + GET_MODE_UNIT_BITSIZE (mode) - 1)"))) > > > > + > > > > (define_constraint "Dr" > > > > "@internal > > > > A constraint that matches vector of immediates for right shifts." > > > > diff --git a/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > > > b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > > > new file mode 100644 > > > > index > > > > > > 0000000000000000000000000000000000000000..bdfe35d09ffccc7928947c9e > > > > 57f1034f7ca2c798 > > > > --- /dev/null > > > > +++ b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c > > > > @@ -0,0 +1,12 @@ > > > > +/* { dg-do assemble } */ > > > > +/* { dg-options "-O3 --save-temps > > > > +--param=vect-epilogues-nomask=0" } > > */ > > > > + > > > > +void e (int * restrict a, int *b, int n) { > > > > + for (int i = 0; i < n; i++) > > > > + b[i] = a[i] >> 31; > > > > +} > > > > + > > > > +/* { dg-final { scan-assembler-times {\tcmlt\t} 1 } } */ > > > > +/* { dg-final { scan-assembler-not {\tsshr\t} } } */ > > > > + > > > > > > > > > > > > --
diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 300bf001b59ca7fa197c580b10adb7f70f20d1e0..19b2d0ad4dab4d5742698297ded861228ee22007 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -1127,12 +1127,14 @@ (define_insn "aarch64_simd_lshr<mode>" ) (define_insn "aarch64_simd_ashr<mode>" - [(set (match_operand:VDQ_I 0 "register_operand" "=w") - (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w") - (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" "Dr")))] + [(set (match_operand:VDQ_I 0 "register_operand" "=w,w") + (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w,w") + (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" "D1,Dr")))] "TARGET_SIMD" - "sshr\t%0.<Vtype>, %1.<Vtype>, %2" - [(set_attr "type" "neon_shift_imm<q>")] + "@ + cmlt\t%0.<Vtype>, %1.<Vtype>, #0 + sshr\t%0.<Vtype>, %1.<Vtype>, %2" + [(set_attr "type" "neon_compare<q>,neon_shift_imm<q>")] ) (define_insn "*aarch64_simd_sra<mode>" diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md index 3b49b452119c49320020fa9183314d9a25b92491..18630815ffc13f2168300a899db69fd428dfb0d6 100644 --- a/gcc/config/aarch64/constraints.md +++ b/gcc/config/aarch64/constraints.md @@ -437,6 +437,14 @@ (define_constraint "Dl" (match_test "aarch64_simd_shift_imm_p (op, GET_MODE (op), true)"))) +(define_constraint "D1" + "@internal + A constraint that matches vector of immediates that is bits(mode)-1." + (and (match_code "const,const_vector") + (match_test "aarch64_const_vec_all_same_in_range_p (op, + GET_MODE_UNIT_BITSIZE (mode) - 1, + GET_MODE_UNIT_BITSIZE (mode) - 1)"))) + (define_constraint "Dr" "@internal A constraint that matches vector of immediates for right shifts." diff --git a/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c new file mode 100644 index 0000000000000000000000000000000000000000..bdfe35d09ffccc7928947c9e57f1034f7ca2c798 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/shl-combine-2.c @@ -0,0 +1,12 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +void e (int * restrict a, int *b, int n) +{ + for (int i = 0; i < n; i++) + b[i] = a[i] >> 31; +} + +/* { dg-final { scan-assembler-times {\tcmlt\t} 1 } } */ +/* { dg-final { scan-assembler-not {\tsshr\t} } } */ +