Message ID | 20210929162024.GA1924@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 EFB89385842B for <patchwork@sourceware.org>; Wed, 29 Sep 2021 16:24:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFB89385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632932674; bh=zVGYh3/jTiKzrYE0cJZVArZD/IWtxT/GjJa8uXVec2I=; 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=hkOSjnvehLb2WE1tFqK3x+seXcDcJ4X3Fz30crs4bEGKcsuSjRSkYV5LYr4RQ1/jr HbSaoD3CrOQ8KMB/Xti/XZeAzdhnfXFqG7toeRNlmxTsVEzWYt7Z6Kx/q/FHFAb+4Z UdrCgVBSl1d12+UYqBNrWBzMQZbgNR7H4VvNW5Gk= 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-eopbgr40066.outbound.protection.outlook.com [40.107.4.66]) by sourceware.org (Postfix) with ESMTPS id DBB0B385803C for <gcc-patches@gcc.gnu.org>; Wed, 29 Sep 2021 16:20:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DBB0B385803C Received: from AM5PR1001CA0032.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::45) by PAXPR08MB6432.eurprd08.prod.outlook.com (2603:10a6:102:154::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Wed, 29 Sep 2021 16:20:51 +0000 Received: from VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::3d) by AM5PR1001CA0032.outlook.office365.com (2603:10a6:206:2::45) 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:50 +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=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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT032.mail.protection.outlook.com (10.152.18.121) 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:51 +0000 Received: ("Tessian outbound a492f2284909:v103"); Wed, 29 Sep 2021 16:20:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 955c5197002cc50b X-CR-MTA-TID: 64aa7808 Received: from b4fd40df80de.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A121A1A7-8B60-477E-8A71-840D1FDFA6FF.1; Wed, 29 Sep 2021 16:20:38 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b4fd40df80de.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 29 Sep 2021 16:20:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJXm8HsT71CkN3vI2MdczigpyL/B8GywLJ/5W0/eJA/l4g2tyhMgkJdN6pG5rizpQB8/YNX1ejhWwikw4JT76dIJui5fPCBfz2St8GlPfytokheqjyCfGE2FgGmY5srMTc7DBF2w6lwXHGn8uo3EooBgZOfrFfGx7brk849vxfburXJEovSgiwirdJDfwrXIfafCSwgz5Jb9fWL7qroc/dQpo+339Mz2pxZJGyRcH3G+6ThgJxZ5IkXi4iPvwdjpPM8k6m3ROMjIHdYEh9V1WCXjlTItLZI1abKaRhVuhyMsk+3vBuzFvH+LoxUoocXEbJW31hRRP25QThfPuo7dZw== 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=zVGYh3/jTiKzrYE0cJZVArZD/IWtxT/GjJa8uXVec2I=; b=aStZDo11pd3e5Sam4mQpQQyIYhUMEK5vAAdD9yM3QP0MA0XQVPFztHyE95sMg0z1UuBdfLW6Yd6tEwQ220UKtxkUjc2eUfYn4ss6lsBrpdLmM7QzFpk6Bj/KGUFLbCETGFcWJ50WSwiNUNFir8ygEXHAoBukWq+vN1RZmL9uC1uAWvb6Ok5YQDshXUz3G27yx2lx72+e4AsXLMLHyBrLPfDtFefxbOwgp9r6jEKNzKrUA+BWxnzwzKusrGbMVseKk9HxYsFaCm5k/AeT5Y3O4nVw/YLN1nwwcv9g482pl0NQ1earEZgIBAKcbDNpGxUSPWxcEEpjjZg57rRlhr0Y4w== 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:35 +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:35 +0000 Date: Wed, 29 Sep 2021 17:20:27 +0100 To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/7]AArch64 Add pattern xtn+xtn2 to uzp2 Message-ID: <20210929162024.GA1924@arm.com> Content-Type: multipart/mixed; boundary="jI8keyz6grp/JLjh" Content-Disposition: inline In-Reply-To: <patch-14899-tamar@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-ClientProxiedBy: SA0PR11CA0112.namprd11.prod.outlook.com (2603:10b6:806:d1::27) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 Received: from arm.com (217.140.106.55) by SA0PR11CA0112.namprd11.prod.outlook.com (2603:10b6:806:d1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.13 via Frontend Transport; Wed, 29 Sep 2021 16:20:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b927e56f-812c-41dd-875e-08d983651ada X-MS-TrafficTypeDiagnostic: VI1PR0801MB1728:|PAXPR08MB6432: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: <PAXPR08MB6432862953F551BAEAB9F6D2FFA99@PAXPR08MB6432.eurprd08.prod.outlook.com> x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ZnE+SlrXhBKrcSFNCl8bNAnGMJgFVjRYGn9g62OI7iF8IQ/3bZamA00DykW/vIx30tJnkgzSdjFXA/tqNLZyEmCU2BQREcKJye/oaXFr2aP/Jv7bk/IMiD1yECJfgOAi23Eu5mfxegpJWAd5HInpbeVK97XAvILvXLj9abcfQFLWDQs6QvrV0nEMxV/Zl6Sk6Qh/ZxNdG9tx1aXp7HnGOOa9c3EzJX1JgDuFSwMYKg2Ra1x+FAib0/y5swlieyQFu/M/lfLfNm7lHjJhQrIC7AurOsze0YdbaFyq+n2YisXlnuWsKiHCrpSHM99Z040gll4KAfn8LNln6dSSCk/h5lFYwE9SzanKViO61sxNkEa5cVnvn8HH5gX+tOfWFIUlhoOBRDLAcPCffH4blLPRpMib5yvD9efKBDW3ZMBWX7xDxpfjsfeiC0pikTOGNhxcVzNgEXf8YI4XXk8rHeWEaQ17dpHc9xT4ix573Ho9och7hdqGVpXeoQm3GtfZOMlwBURdbmru9AYcMUKsL36cPgrBkneYv8oZZcah6eKe0izZHQHO89tcY/N0YDUALik5NVeKaS31FHzpbvvmWD/9RDUy/2VQbGHazo4DKZx3+TlohwXX5FruG3URpyqn7+A2I2U/szvLUe5K5MEaZ0Cn0Hn0rENPALZauRxRIUbvDI1/e3Dva88Pv2vxS/cKT66Rv9vcSkXo8b06G6iAVv0hGa7yskWOsRjOfMDrdOrQVL8uqnuiVgV6fOx1SEpFUgAhcHaoBpwy2ubUkW952x7YsxvlNrHlrLMn0vrAn05w963eNa/IlrSHuS2+Xsf865pMMdZ+wfP7UzOMBbl4Tf6Wd8twRExMlyojFvyk/YL7ra8= 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)(6666004)(52116002)(8676002)(5660300002)(33964004)(38100700002)(38350700002)(508600001)(66616009)(8886007)(8936002)(83380400001)(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: VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 86cc4b79-747d-47c1-4fd8-08d983651167 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gP0AaDiEp2OvTWyYg0FxYwhUBor7unCb7eQowJHrQ5nWq/xkPsijdZElrwjigeM5HQPwwiHmvWE1tWKXbc/7cRV5ssxYTUU835VahD/5Y0q+Pu14R1j4TBPViRrvl38+Q8AzDg6uSooyhYErL2Qmd/zV7mK2aXmh5X761p3wlWeL30SqwGXxtCs6CNYCzKU751zkZ1X4ZmKAbnO6QWIyqaK4UJGZBVnucUCFBuHgRgGzlVXXC8GYjgOibj0QadkENgooI3Hdcb5JotTdCAlKtnuwFijVmAExNw0ccd4vpKWqnQqVJqmszlLK38Bu+aJGxaLTMkYAgVBEPQF0KzfMhbZOmKKa69bprK1KBcUNAsqyQBKvjS2imTazgJ+Aa50tGp6WlAixik/G9lJqjz8WmzjjlMeQeYFmk0byTFzKMa6cFtfsZiQZA/2LvfOKSTS2P37nQKz5Iq4t3tVjC81phgk2qakspICbuaNvdu8LBPpgn4E40UZB0bDlh1ITBjjiDcIwxNMmXJd/S+l84ZdPwuAsjFAnzqQR6n3IUtg0X0cNpBgYdwGnHunYS0XhuLDVswysoLpQz9JHOiVAp/UZ5FPYo/lcSqpEkVuC2jKy2UCCUKex63oiVptniRsftwVV0p3fpAqw+tK6d/3m9pnIjYhLv2rIZTzFhcn7J3tK3MFdHKkcvFC13eSIP+VIVwtJicwdnEYJjAtgcVREqhDI+oNtLtm8yIFIAnS88U2tpr1n6BIdEJ6WlGBwv4UQy/qFutJVTYMG1TsbXfWd4ujo2xXaIsynTwEuT2uAU0z+/u8V3rkf+sbu53pP0iRk3NmhjLDc3WbXah4g+bjmAOWL4Y1AZfzpMx0dUgnO80bY0y4= 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)(46966006)(36840700001)(55016002)(6666004)(7696005)(186003)(81166007)(33656002)(36756003)(8886007)(4326008)(86362001)(8676002)(8936002)(356005)(66616009)(70206006)(316002)(70586007)(26005)(6916009)(2906002)(5660300002)(956004)(336012)(44832011)(36860700001)(508600001)(2616005)(235185007)(47076005)(44144004)(33964004)(1076003)(82310400003)(4743002)(83380400001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2021 16:20:51.3751 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b927e56f-812c-41dd-875e-08d983651ada 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: VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6432 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_NUMSUBJECT, 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 turns truncate operations with a hi/lo pair into a single permute of half the bit size of the input and just ignoring the top bits (which are truncated out). i.e. void d2 (short * restrict a, int *b, int n) { for (int i = 0; i < n; i++) a[i] = b[i]; } now generates: .L4: ldp q0, q1, [x3] add x3, x3, 32 uzp1 v0.8h, v0.8h, v1.8h str q0, [x5], 16 cmp x4, x3 bne .L4 instead of .L4: ldp q0, q1, [x3] add x3, x3, 32 xtn v0.4h, v0.4s xtn2 v0.8h, v1.4s str q0, [x5], 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_narrow_trunc<mode>): New. * config/aarch64/iterators.md (VNARROWSIMD, Vnarrowsimd): New. gcc/testsuite/ChangeLog: * gcc.target/aarch64/xtn-combine-1.c: New test. * gcc.target/aarch64/narrow_high_combine.c: Update case. --- inline copy of patch -- diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 36396ef236e8c476d5e2f1acee80dc54ec5ebe4e..33e3301d229366022a5b9481b6c3ae8f8d93f9e2 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 4/7]AArch64 Add pattern xtn+xtn2 to uzp2 > > Hi All, > > This turns truncate operations with a hi/lo pair into a single permute of half > the bit size of the input and just ignoring the top bits (which are truncated > out). > > i.e. > > void d2 (short * restrict a, int *b, int n) > { > for (int i = 0; i < n; i++) > a[i] = b[i]; > } > > now generates: > > .L4: > ldp q0, q1, [x3] > add x3, x3, 32 > uzp1 v0.8h, v0.8h, v1.8h > str q0, [x5], 16 > cmp x4, x3 > bne .L4 > > instead of > > .L4: > ldp q0, q1, [x3] > add x3, x3, 32 > xtn v0.4h, v0.4s > xtn2 v0.8h, v1.4s > str q0, [x5], 16 > cmp x4, x3 > bne .L4 > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? > Ok. Thanks, Kyrill > Thanks, > Tamar > > gcc/ChangeLog: > > * config/aarch64/aarch64-simd.md > (*aarch64_narrow_trunc<mode>): New. > * config/aarch64/iterators.md (VNARROWSIMD, Vnarrowsimd): > New. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/xtn-combine-1.c: New test. > * gcc.target/aarch64/narrow_high_combine.c: Update case. > > --- inline copy of patch -- > diff --git a/gcc/config/aarch64/aarch64-simd.md > b/gcc/config/aarch64/aarch64-simd.md > index > 36396ef236e8c476d5e2f1acee80dc54ec5ebe4e..33e3301d229366022a5b9481 > b6c3ae8f8d93f9e2 100644 > --- a/gcc/config/aarch64/aarch64-simd.md > +++ b/gcc/config/aarch64/aarch64-simd.md > @@ -1753,6 +1753,18 @@ (define_expand "aarch64_xtn2<mode>" > } > ) > > +(define_insn "*aarch64_narrow_trunc<mode>" > + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") > + (vec_concat:<VNARROWQ2> > + (truncate:<VNARROWQ> > + (match_operand:VQN 1 "register_operand" "w")) > + (truncate:<VNARROWQ> > + (match_operand:VQN 2 "register_operand" "w"))))] > + "TARGET_SIMD" > + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" > + [(set_attr "type" "neon_permute<q>")] > +) > + > ;; Packing doubles. > > (define_expand "vec_pack_trunc_<mode>" > diff --git a/gcc/config/aarch64/iterators.md > b/gcc/config/aarch64/iterators.md > index > 8dbeed3b0d4a44cdc17dd333ed397b39a33f386a..95b385c0c9405fe95fcd072 > 62a9471ab13d5488e 100644 > --- a/gcc/config/aarch64/iterators.md > +++ b/gcc/config/aarch64/iterators.md > @@ -270,6 +270,14 @@ (define_mode_iterator VDQHS [V4HI V8HI V2SI > V4SI]) > ;; Advanced SIMD modes for H, S and D types. > (define_mode_iterator VDQHSD [V4HI V8HI V2SI V4SI V2DI]) > > +;; Modes for which we can narrow the element and increase the lane counts > +;; to preserve the same register size. > +(define_mode_attr VNARROWSIMD [(V4HI "V8QI") (V8HI "V16QI") (V4SI > "V8HI") > + (V2SI "V4HI") (V2DI "V4SI")]) > + > +(define_mode_attr Vnarrowsimd [(V4HI "v8qi") (V8HI "v16qi") (V4SI "v8hi") > + (V2SI "v4hi") (V2DI "v4si")]) > + > ;; Advanced SIMD and scalar integer modes for H and S. > (define_mode_iterator VSDQ_HSI [V4HI V8HI V2SI V4SI HI SI]) > > diff --git a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > index > 50ecab002a3552d37a5cc0d8921f42f6c3dba195..fa61196d3644caa48b12151e > 12b15dfeab8c7e71 100644 > --- a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > +++ b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > @@ -225,7 +225,8 @@ TEST_2_UNARY (vqmovun, uint32x4_t, int64x2_t, > s64, u32) > /* { dg-final { scan-assembler-times "\\tuqshrn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqrshrn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tuqrshrn2\\tv" 6} } */ > -/* { dg-final { scan-assembler-times "\\txtn2\\tv" 12} } */ > +/* { dg-final { scan-assembler-times "\\txtn2\\tv" 6} } */ > +/* { dg-final { scan-assembler-times "\\tuzp1\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tuqxtn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqxtn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqxtun2\\tv" 6} } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..ed655cc970a602da4ace78d > c8dbd64ab18b0d4ab > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > @@ -0,0 +1,12 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +void d2 (short * restrict a, int *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > > > --
Hi All, This is a new version with BE support and more tests. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: * config/aarch64/aarch64-simd.md (*aarch64_narrow_trunc<mode>_le): (*aarch64_narrow_trunc<mode>_be): New. * config/aarch64/iterators.md (VNARROWSIMD, Vnarrowsimd): New. gcc/testsuite/ChangeLog: * gcc.target/aarch64/narrow_high_combine.c: Update case. * gcc.target/aarch64/xtn-combine-1.c: New test. * gcc.target/aarch64/xtn-combine-2.c: New test. * gcc.target/aarch64/xtn-combine-3.c: New test. * gcc.target/aarch64/xtn-combine-4.c: New test. * gcc.target/aarch64/xtn-combine-5.c: New test. * gcc.target/aarch64/xtn-combine-6.c: New test. --- inline copy of patch --- diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 0b340b49fa06684b80d0b78cb712e49328ca92d5..8435dece660a12aa747c4a489fbbda5bc0f83a86 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -1753,6 +1753,30 @@ (define_expand "aarch64_xtn2<mode>" } ) +(define_insn "*aarch64_narrow_trunc<mode>_le" + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") + (vec_concat:<VNARROWQ2> + (truncate:<VNARROWQ> + (match_operand:VQN 1 "register_operand" "w")) + (truncate:<VNARROWQ> + (match_operand:VQN 2 "register_operand" "w"))))] + "TARGET_SIMD && !BYTES_BIG_ENDIAN" + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" + [(set_attr "type" "neon_permute<q>")] +) + +(define_insn "*aarch64_narrow_trunc<mode>_be" + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") + (vec_concat:<VNARROWQ2> + (truncate:<VNARROWQ> + (match_operand:VQN 2 "register_operand" "w")) + (truncate:<VNARROWQ> + (match_operand:VQN 1 "register_operand" "w"))))] + "TARGET_SIMD && BYTES_BIG_ENDIAN" + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" + [(set_attr "type" "neon_permute<q>")] +) + ;; Packing doubles. (define_expand "vec_pack_trunc_<mode>" diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 8dbeed3b0d4a44cdc17dd333ed397b39a33f386a..95b385c0c9405fe95fcd07262a9471ab13d5488e 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -270,6 +270,14 @@ (define_mode_iterator VDQHS [V4HI V8HI V2SI V4SI]) ;; Advanced SIMD modes for H, S and D types. (define_mode_iterator VDQHSD [V4HI V8HI V2SI V4SI V2DI]) +;; Modes for which we can narrow the element and increase the lane counts +;; to preserve the same register size. +(define_mode_attr VNARROWSIMD [(V4HI "V8QI") (V8HI "V16QI") (V4SI "V8HI") + (V2SI "V4HI") (V2DI "V4SI")]) + +(define_mode_attr Vnarrowsimd [(V4HI "v8qi") (V8HI "v16qi") (V4SI "v8hi") + (V2SI "v4hi") (V2DI "v4si")]) + ;; Advanced SIMD and scalar integer modes for H and S. (define_mode_iterator VSDQ_HSI [V4HI V8HI V2SI V4SI HI SI]) diff --git a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c index 50ecab002a3552d37a5cc0d8921f42f6c3dba195..fa61196d3644caa48b12151e12b15dfeab8c7e71 100644 --- a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c +++ b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c @@ -225,7 +225,8 @@ TEST_2_UNARY (vqmovun, uint32x4_t, int64x2_t, s64, u32) /* { dg-final { scan-assembler-times "\\tuqshrn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqrshrn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tuqrshrn2\\tv" 6} } */ -/* { dg-final { scan-assembler-times "\\txtn2\\tv" 12} } */ +/* { dg-final { scan-assembler-times "\\txtn2\\tv" 6} } */ +/* { dg-final { scan-assembler-times "\\tuzp1\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tuqxtn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqxtn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqxtun2\\tv" 6} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c new file mode 100644 index 0000000000000000000000000000000000000000..14e0414cd1478f1cb7b17766aa8d4451c5659977 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN signed +#define TYPE1 char +#define TYPE2 short + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c new file mode 100644 index 0000000000000000000000000000000000000000..c259010442bca4ba008706e47b3ffcc50a910b52 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN signed +#define TYPE1 short +#define TYPE2 int + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c new file mode 100644 index 0000000000000000000000000000000000000000..9a2065f65101f82ebe33519840919f9606192c43 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN signed +#define TYPE1 int +#define TYPE2 long long + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c new file mode 100644 index 0000000000000000000000000000000000000000..77c3dce12049989d344e4652bd593de2e846ae25 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN unsigned +#define TYPE1 char +#define TYPE2 short + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c new file mode 100644 index 0000000000000000000000000000000000000000..ae30e864ed7a239c40522423d7493ddd33830cc8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN unsigned +#define TYPE1 short +#define TYPE2 int + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c new file mode 100644 index 0000000000000000000000000000000000000000..882f3d333e2cc42e964d880de5b58c505ec8b122 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN unsigned +#define TYPE1 int +#define TYPE2 long long + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */
> -----Original Message----- > From: Tamar Christina <Tamar.Christina@arm.com> > Sent: Tuesday, October 12, 2021 5:25 PM > To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>; gcc-patches@gcc.gnu.org > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Richard Sandiford > <Richard.Sandiford@arm.com> > Subject: RE: [PATCH 4/7]AArch64 Add pattern xtn+xtn2 to uzp2 > > Hi All, > > This is a new version with BE support and more tests. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? +(define_insn "*aarch64_narrow_trunc<mode>_le" + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") + (vec_concat:<VNARROWQ2> + (truncate:<VNARROWQ> + (match_operand:VQN 1 "register_operand" "w")) + (truncate:<VNARROWQ> + (match_operand:VQN 2 "register_operand" "w"))))] + "TARGET_SIMD && !BYTES_BIG_ENDIAN" + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" + [(set_attr "type" "neon_permute<q>")] +) + +(define_insn "*aarch64_narrow_trunc<mode>_be" + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") + (vec_concat:<VNARROWQ2> + (truncate:<VNARROWQ> + (match_operand:VQN 2 "register_operand" "w")) + (truncate:<VNARROWQ> + (match_operand:VQN 1 "register_operand" "w"))))] + "TARGET_SIMD && BYTES_BIG_ENDIAN" + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" + [(set_attr "type" "neon_permute<q>")] +) + Hmmm these patterns are identical in what they match they just have the effect of printing operands 1 and 2 in a different order. Perhaps it's more compact to change the output template into a BYTES_BIG_ENDIAN ? "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>"" : uzp1\\t%0.<V2ntype>, %2.<V2ntype>, %1.<V2ntype>" and avoid having a second at all? Thanks, Kyrill > > Thanks, > Tamar > > gcc/ChangeLog: > > * config/aarch64/aarch64-simd.md > (*aarch64_narrow_trunc<mode>_le): > (*aarch64_narrow_trunc<mode>_be): New. > * config/aarch64/iterators.md (VNARROWSIMD, Vnarrowsimd): > New. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/narrow_high_combine.c: Update case. > * gcc.target/aarch64/xtn-combine-1.c: New test. > * gcc.target/aarch64/xtn-combine-2.c: New test. > * gcc.target/aarch64/xtn-combine-3.c: New test. > * gcc.target/aarch64/xtn-combine-4.c: New test. > * gcc.target/aarch64/xtn-combine-5.c: New test. > * gcc.target/aarch64/xtn-combine-6.c: New test. > > --- inline copy of patch --- > > diff --git a/gcc/config/aarch64/aarch64-simd.md > b/gcc/config/aarch64/aarch64-simd.md > index > 0b340b49fa06684b80d0b78cb712e49328ca92d5..8435dece660a12aa747c4a4 > 89fbbda5bc0f83a86 100644 > --- a/gcc/config/aarch64/aarch64-simd.md > +++ b/gcc/config/aarch64/aarch64-simd.md > @@ -1753,6 +1753,30 @@ (define_expand "aarch64_xtn2<mode>" > } > ) > > +(define_insn "*aarch64_narrow_trunc<mode>_le" > + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") > + (vec_concat:<VNARROWQ2> > + (truncate:<VNARROWQ> > + (match_operand:VQN 1 "register_operand" "w")) > + (truncate:<VNARROWQ> > + (match_operand:VQN 2 "register_operand" "w"))))] > + "TARGET_SIMD && !BYTES_BIG_ENDIAN" > + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" > + [(set_attr "type" "neon_permute<q>")] > +) > + > +(define_insn "*aarch64_narrow_trunc<mode>_be" > + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") > + (vec_concat:<VNARROWQ2> > + (truncate:<VNARROWQ> > + (match_operand:VQN 2 "register_operand" "w")) > + (truncate:<VNARROWQ> > + (match_operand:VQN 1 "register_operand" "w"))))] > + "TARGET_SIMD && BYTES_BIG_ENDIAN" > + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" > + [(set_attr "type" "neon_permute<q>")] > +) > + > ;; Packing doubles. > > (define_expand "vec_pack_trunc_<mode>" > diff --git a/gcc/config/aarch64/iterators.md > b/gcc/config/aarch64/iterators.md > index > 8dbeed3b0d4a44cdc17dd333ed397b39a33f386a..95b385c0c9405fe95fcd072 > 62a9471ab13d5488e 100644 > --- a/gcc/config/aarch64/iterators.md > +++ b/gcc/config/aarch64/iterators.md > @@ -270,6 +270,14 @@ (define_mode_iterator VDQHS [V4HI V8HI V2SI > V4SI]) > ;; Advanced SIMD modes for H, S and D types. > (define_mode_iterator VDQHSD [V4HI V8HI V2SI V4SI V2DI]) > > +;; Modes for which we can narrow the element and increase the lane counts > +;; to preserve the same register size. > +(define_mode_attr VNARROWSIMD [(V4HI "V8QI") (V8HI "V16QI") (V4SI > "V8HI") > + (V2SI "V4HI") (V2DI "V4SI")]) > + > +(define_mode_attr Vnarrowsimd [(V4HI "v8qi") (V8HI "v16qi") (V4SI "v8hi") > + (V2SI "v4hi") (V2DI "v4si")]) > + > ;; Advanced SIMD and scalar integer modes for H and S. > (define_mode_iterator VSDQ_HSI [V4HI V8HI V2SI V4SI HI SI]) > > diff --git a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > index > 50ecab002a3552d37a5cc0d8921f42f6c3dba195..fa61196d3644caa48b12151e > 12b15dfeab8c7e71 100644 > --- a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > +++ b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > @@ -225,7 +225,8 @@ TEST_2_UNARY (vqmovun, uint32x4_t, int64x2_t, > s64, u32) > /* { dg-final { scan-assembler-times "\\tuqshrn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqrshrn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tuqrshrn2\\tv" 6} } */ > -/* { dg-final { scan-assembler-times "\\txtn2\\tv" 12} } */ > +/* { dg-final { scan-assembler-times "\\txtn2\\tv" 6} } */ > +/* { dg-final { scan-assembler-times "\\tuzp1\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tuqxtn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqxtn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqxtun2\\tv" 6} } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..14e0414cd1478f1cb7b1776 > 6aa8d4451c5659977 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN signed > +#define TYPE1 char > +#define TYPE2 short > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..c259010442bca4ba008706e > 47b3ffcc50a910b52 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN signed > +#define TYPE1 short > +#define TYPE2 int > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..9a2065f65101f82ebe33519 > 840919f9606192c43 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN signed > +#define TYPE1 int > +#define TYPE2 long long > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..77c3dce12049989d344e465 > 2bd593de2e846ae25 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN unsigned > +#define TYPE1 char > +#define TYPE2 short > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..ae30e864ed7a239c4052242 > 3d7493ddd33830cc8 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN unsigned > +#define TYPE1 short > +#define TYPE2 int > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..882f3d333e2cc42e964d880 > de5b58c505ec8b122 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN unsigned > +#define TYPE1 int > +#define TYPE2 long long > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */
> > Hmmm these patterns are identical in what they match they just have the > effect of printing operands 1 and 2 in a different order. > Perhaps it's more compact to change the output template into a > BYTES_BIG_ENDIAN ? > "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>"" : > uzp1\\t%0.<V2ntype>, %2.<V2ntype>, %1.<V2ntype>" > and avoid having a second at all? > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: * config/aarch64/aarch64-simd.md (*aarch64_narrow_trunc<mode>): New. * config/aarch64/iterators.md (VNARROWSIMD, Vnarrowsimd): New. gcc/testsuite/ChangeLog: * gcc.target/aarch64/narrow_high_combine.c: Update case. * gcc.target/aarch64/xtn-combine-1.c: New test. * gcc.target/aarch64/xtn-combine-2.c: New test. * gcc.target/aarch64/xtn-combine-3.c: New test. * gcc.target/aarch64/xtn-combine-4.c: New test. * gcc.target/aarch64/xtn-combine-5.c: New test. * gcc.target/aarch64/xtn-combine-6.c: New test. --- inline copy of patch --- diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 0b340b49fa06684b80d0b78cb712e49328ca92d5..b0dda554466149817a7828dbf4e0ed372a91872b 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -1753,6 +1753,23 @@ (define_expand "aarch64_xtn2<mode>" } ) +(define_insn "*aarch64_narrow_trunc<mode>" + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") + (vec_concat:<VNARROWQ2> + (truncate:<VNARROWQ> + (match_operand:VQN 1 "register_operand" "w")) + (truncate:<VNARROWQ> + (match_operand:VQN 2 "register_operand" "w"))))] + "TARGET_SIMD" +{ + if (!BYTES_BIG_ENDIAN) + return "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>"; + else + return "uzp1\\t%0.<V2ntype>, %2.<V2ntype>, %1.<V2ntype>"; +} + [(set_attr "type" "neon_permute<q>")] +) + ;; Packing doubles. (define_expand "vec_pack_trunc_<mode>" diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 8dbeed3b0d4a44cdc17dd333ed397b39a33f386a..95b385c0c9405fe95fcd07262a9471ab13d5488e 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -270,6 +270,14 @@ (define_mode_iterator VDQHS [V4HI V8HI V2SI V4SI]) ;; Advanced SIMD modes for H, S and D types. (define_mode_iterator VDQHSD [V4HI V8HI V2SI V4SI V2DI]) +;; Modes for which we can narrow the element and increase the lane counts +;; to preserve the same register size. +(define_mode_attr VNARROWSIMD [(V4HI "V8QI") (V8HI "V16QI") (V4SI "V8HI") + (V2SI "V4HI") (V2DI "V4SI")]) + +(define_mode_attr Vnarrowsimd [(V4HI "v8qi") (V8HI "v16qi") (V4SI "v8hi") + (V2SI "v4hi") (V2DI "v4si")]) + ;; Advanced SIMD and scalar integer modes for H and S. (define_mode_iterator VSDQ_HSI [V4HI V8HI V2SI V4SI HI SI]) diff --git a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c index 50ecab002a3552d37a5cc0d8921f42f6c3dba195..fa61196d3644caa48b12151e12b15dfeab8c7e71 100644 --- a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c +++ b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c @@ -225,7 +225,8 @@ TEST_2_UNARY (vqmovun, uint32x4_t, int64x2_t, s64, u32) /* { dg-final { scan-assembler-times "\\tuqshrn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqrshrn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tuqrshrn2\\tv" 6} } */ -/* { dg-final { scan-assembler-times "\\txtn2\\tv" 12} } */ +/* { dg-final { scan-assembler-times "\\txtn2\\tv" 6} } */ +/* { dg-final { scan-assembler-times "\\tuzp1\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tuqxtn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqxtn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqxtun2\\tv" 6} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c new file mode 100644 index 0000000000000000000000000000000000000000..14e0414cd1478f1cb7b17766aa8d4451c5659977 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN signed +#define TYPE1 char +#define TYPE2 short + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c new file mode 100644 index 0000000000000000000000000000000000000000..c259010442bca4ba008706e47b3ffcc50a910b52 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN signed +#define TYPE1 short +#define TYPE2 int + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c new file mode 100644 index 0000000000000000000000000000000000000000..9a2065f65101f82ebe33519840919f9606192c43 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN signed +#define TYPE1 int +#define TYPE2 long long + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c new file mode 100644 index 0000000000000000000000000000000000000000..77c3dce12049989d344e4652bd593de2e846ae25 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN unsigned +#define TYPE1 char +#define TYPE2 short + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c new file mode 100644 index 0000000000000000000000000000000000000000..ae30e864ed7a239c40522423d7493ddd33830cc8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN unsigned +#define TYPE1 short +#define TYPE2 int + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c new file mode 100644 index 0000000000000000000000000000000000000000..882f3d333e2cc42e964d880de5b58c505ec8b122 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +#define SIGN unsigned +#define TYPE1 int +#define TYPE2 long long + +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */
> -----Original Message----- > From: Tamar Christina <Tamar.Christina@arm.com> > Sent: Wednesday, October 13, 2021 12:06 PM > To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>; gcc-patches@gcc.gnu.org > Cc: nd <nd@arm.com>; Richard Earnshaw <Richard.Earnshaw@arm.com>; > Marcus Shawcroft <Marcus.Shawcroft@arm.com>; Richard Sandiford > <Richard.Sandiford@arm.com> > Subject: RE: [PATCH 4/7]AArch64 Add pattern xtn+xtn2 to uzp2 > > > > > Hmmm these patterns are identical in what they match they just have the > > effect of printing operands 1 and 2 in a different order. > > Perhaps it's more compact to change the output template into a > > BYTES_BIG_ENDIAN ? > > "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>"" : > > uzp1\\t%0.<V2ntype>, %2.<V2ntype>, %1.<V2ntype>" > > and avoid having a second at all? > > > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? Sorry I should have noticed earlier but... diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 8dbeed3b0d4a44cdc17dd333ed397b39a33f386a..95b385c0c9405fe95fcd07262a9471ab13d5488e 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -270,6 +270,14 @@ (define_mode_iterator VDQHS [V4HI V8HI V2SI V4SI]) ;; Advanced SIMD modes for H, S and D types. (define_mode_iterator VDQHSD [V4HI V8HI V2SI V4SI V2DI]) +;; Modes for which we can narrow the element and increase the lane counts +;; to preserve the same register size. +(define_mode_attr VNARROWSIMD [(V4HI "V8QI") (V8HI "V16QI") (V4SI "V8HI") + (V2SI "V4HI") (V2DI "V4SI")]) + +(define_mode_attr Vnarrowsimd [(V4HI "v8qi") (V8HI "v16qi") (V4SI "v8hi") + (V2SI "v4hi") (V2DI "v4si")]) + These attributes are not needed it seems. So patch is ok without this hunk. Thanks, Kyrill > > Thanks, > Tamar > > gcc/ChangeLog: > > * config/aarch64/aarch64-simd.md > (*aarch64_narrow_trunc<mode>): New. > * config/aarch64/iterators.md (VNARROWSIMD, Vnarrowsimd): > New. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/narrow_high_combine.c: Update case. > * gcc.target/aarch64/xtn-combine-1.c: New test. > * gcc.target/aarch64/xtn-combine-2.c: New test. > * gcc.target/aarch64/xtn-combine-3.c: New test. > * gcc.target/aarch64/xtn-combine-4.c: New test. > * gcc.target/aarch64/xtn-combine-5.c: New test. > * gcc.target/aarch64/xtn-combine-6.c: New test. > > --- inline copy of patch --- > > diff --git a/gcc/config/aarch64/aarch64-simd.md > b/gcc/config/aarch64/aarch64-simd.md > index > 0b340b49fa06684b80d0b78cb712e49328ca92d5..b0dda554466149817a7828 > dbf4e0ed372a91872b 100644 > --- a/gcc/config/aarch64/aarch64-simd.md > +++ b/gcc/config/aarch64/aarch64-simd.md > @@ -1753,6 +1753,23 @@ (define_expand "aarch64_xtn2<mode>" > } > ) > > +(define_insn "*aarch64_narrow_trunc<mode>" > + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") > + (vec_concat:<VNARROWQ2> > + (truncate:<VNARROWQ> > + (match_operand:VQN 1 "register_operand" "w")) > + (truncate:<VNARROWQ> > + (match_operand:VQN 2 "register_operand" "w"))))] > + "TARGET_SIMD" > +{ > + if (!BYTES_BIG_ENDIAN) > + return "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>"; > + else > + return "uzp1\\t%0.<V2ntype>, %2.<V2ntype>, %1.<V2ntype>"; > +} > + [(set_attr "type" "neon_permute<q>")] > +) > + > ;; Packing doubles. > > (define_expand "vec_pack_trunc_<mode>" > diff --git a/gcc/config/aarch64/iterators.md > b/gcc/config/aarch64/iterators.md > index > 8dbeed3b0d4a44cdc17dd333ed397b39a33f386a..95b385c0c9405fe95fcd072 > 62a9471ab13d5488e 100644 > --- a/gcc/config/aarch64/iterators.md > +++ b/gcc/config/aarch64/iterators.md > @@ -270,6 +270,14 @@ (define_mode_iterator VDQHS [V4HI V8HI V2SI > V4SI]) > ;; Advanced SIMD modes for H, S and D types. > (define_mode_iterator VDQHSD [V4HI V8HI V2SI V4SI V2DI]) > > +;; Modes for which we can narrow the element and increase the lane counts > +;; to preserve the same register size. > +(define_mode_attr VNARROWSIMD [(V4HI "V8QI") (V8HI "V16QI") (V4SI > "V8HI") > + (V2SI "V4HI") (V2DI "V4SI")]) > + > +(define_mode_attr Vnarrowsimd [(V4HI "v8qi") (V8HI "v16qi") (V4SI "v8hi") > + (V2SI "v4hi") (V2DI "v4si")]) > + > ;; Advanced SIMD and scalar integer modes for H and S. > (define_mode_iterator VSDQ_HSI [V4HI V8HI V2SI V4SI HI SI]) > > diff --git a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > index > 50ecab002a3552d37a5cc0d8921f42f6c3dba195..fa61196d3644caa48b12151e > 12b15dfeab8c7e71 100644 > --- a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > +++ b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c > @@ -225,7 +225,8 @@ TEST_2_UNARY (vqmovun, uint32x4_t, int64x2_t, > s64, u32) > /* { dg-final { scan-assembler-times "\\tuqshrn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqrshrn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tuqrshrn2\\tv" 6} } */ > -/* { dg-final { scan-assembler-times "\\txtn2\\tv" 12} } */ > +/* { dg-final { scan-assembler-times "\\txtn2\\tv" 6} } */ > +/* { dg-final { scan-assembler-times "\\tuzp1\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tuqxtn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqxtn2\\tv" 6} } */ > /* { dg-final { scan-assembler-times "\\tsqxtun2\\tv" 6} } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..14e0414cd1478f1cb7b1776 > 6aa8d4451c5659977 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN signed > +#define TYPE1 char > +#define TYPE2 short > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..c259010442bca4ba008706e > 47b3ffcc50a910b52 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-2.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN signed > +#define TYPE1 short > +#define TYPE2 int > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..9a2065f65101f82ebe33519 > 840919f9606192c43 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-3.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN signed > +#define TYPE1 int > +#define TYPE2 long long > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..77c3dce12049989d344e465 > 2bd593de2e846ae25 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-4.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN unsigned > +#define TYPE1 char > +#define TYPE2 short > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..ae30e864ed7a239c4052242 > 3d7493ddd33830cc8 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-5.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN unsigned > +#define TYPE1 short > +#define TYPE2 int > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c > b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..882f3d333e2cc42e964d880 > de5b58c505ec8b122 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-6.c > @@ -0,0 +1,16 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ > + > +#define SIGN unsigned > +#define TYPE1 int > +#define TYPE2 long long > + > +void d2 (SIGN TYPE1 * restrict a, SIGN TYPE2 *b, int n) > +{ > + for (int i = 0; i < n; i++) > + a[i] = b[i]; > +} > + > +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ > +/* { dg-final { scan-assembler-not {\txtn\t} } } */ > +/* { dg-final { scan-assembler-not {\txtn2\t} } } */
diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 36396ef236e8c476d5e2f1acee80dc54ec5ebe4e..33e3301d229366022a5b9481b6c3ae8f8d93f9e2 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -1753,6 +1753,18 @@ (define_expand "aarch64_xtn2<mode>" } ) +(define_insn "*aarch64_narrow_trunc<mode>" + [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w") + (vec_concat:<VNARROWQ2> + (truncate:<VNARROWQ> + (match_operand:VQN 1 "register_operand" "w")) + (truncate:<VNARROWQ> + (match_operand:VQN 2 "register_operand" "w"))))] + "TARGET_SIMD" + "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>" + [(set_attr "type" "neon_permute<q>")] +) + ;; Packing doubles. (define_expand "vec_pack_trunc_<mode>" diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 8dbeed3b0d4a44cdc17dd333ed397b39a33f386a..95b385c0c9405fe95fcd07262a9471ab13d5488e 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -270,6 +270,14 @@ (define_mode_iterator VDQHS [V4HI V8HI V2SI V4SI]) ;; Advanced SIMD modes for H, S and D types. (define_mode_iterator VDQHSD [V4HI V8HI V2SI V4SI V2DI]) +;; Modes for which we can narrow the element and increase the lane counts +;; to preserve the same register size. +(define_mode_attr VNARROWSIMD [(V4HI "V8QI") (V8HI "V16QI") (V4SI "V8HI") + (V2SI "V4HI") (V2DI "V4SI")]) + +(define_mode_attr Vnarrowsimd [(V4HI "v8qi") (V8HI "v16qi") (V4SI "v8hi") + (V2SI "v4hi") (V2DI "v4si")]) + ;; Advanced SIMD and scalar integer modes for H and S. (define_mode_iterator VSDQ_HSI [V4HI V8HI V2SI V4SI HI SI]) diff --git a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c index 50ecab002a3552d37a5cc0d8921f42f6c3dba195..fa61196d3644caa48b12151e12b15dfeab8c7e71 100644 --- a/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c +++ b/gcc/testsuite/gcc.target/aarch64/narrow_high_combine.c @@ -225,7 +225,8 @@ TEST_2_UNARY (vqmovun, uint32x4_t, int64x2_t, s64, u32) /* { dg-final { scan-assembler-times "\\tuqshrn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqrshrn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tuqrshrn2\\tv" 6} } */ -/* { dg-final { scan-assembler-times "\\txtn2\\tv" 12} } */ +/* { dg-final { scan-assembler-times "\\txtn2\\tv" 6} } */ +/* { dg-final { scan-assembler-times "\\tuzp1\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tuqxtn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqxtn2\\tv" 6} } */ /* { dg-final { scan-assembler-times "\\tsqxtun2\\tv" 6} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c new file mode 100644 index 0000000000000000000000000000000000000000..ed655cc970a602da4ace78dc8dbd64ab18b0d4ab --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/xtn-combine-1.c @@ -0,0 +1,12 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 --save-temps --param=vect-epilogues-nomask=0" } */ + +void d2 (short * restrict a, int *b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i]; +} + +/* { dg-final { scan-assembler-times {\tuzp1\t} 1 } } */ +/* { dg-final { scan-assembler-not {\txtn\t} } } */ +/* { dg-final { scan-assembler-not {\txtn2\t} } } */