From patchwork Mon Jan 4 12:11:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1422050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=JaGbqSVx; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8ZGx5jv9z9sVr for ; Mon, 4 Jan 2021 23:11:19 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E690038708D3; Mon, 4 Jan 2021 12:11:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E690038708D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1609762277; bh=QRQJIUowzY0uDyrfm8e5uhuNn4cnltEV9GC1DLK0C7c=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=JaGbqSVxmrDQc1UW4yvP+yawbmHsipQCXymZICl24xLpeyxplR8zHXi7+xNI2UjC2 i/Npr0TayNnlCMQl8yBzNKWffGEEXzUPN8UQKBoXlkKRoRez/X8gOgwYCBQULJJohF Xea5syDcjIB2OWOw9+XoN9CfNmQoRjPDNLL/aP80= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60060.outbound.protection.outlook.com [40.107.6.60]) by sourceware.org (Postfix) with ESMTPS id A42A838708C2 for ; Mon, 4 Jan 2021 12:11:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A42A838708C2 Received: from DB9PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:10:1da::28) by DB7PR08MB3562.eurprd08.prod.outlook.com (2603:10a6:10:49::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22; Mon, 4 Jan 2021 12:11:11 +0000 Received: from DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1da:cafe::e7) by DB9PR05CA0023.outlook.office365.com (2603:10a6:10:1da::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.19 via Frontend Transport; Mon, 4 Jan 2021 12:11:11 +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 DB5EUR03FT018.mail.protection.outlook.com (10.152.20.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.21 via Frontend Transport; Mon, 4 Jan 2021 12:11:11 +0000 Received: ("Tessian outbound 39646a0fd094:v71"); Mon, 04 Jan 2021 12:11:11 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 76eae316829eeb88 X-CR-MTA-TID: 64aa7808 Received: from c7b061ab555f.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C0DBF339-A450-4F76-8E8C-FEADD6B210F1.1; Mon, 04 Jan 2021 12:11:05 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c7b061ab555f.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 04 Jan 2021 12:11:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bLmsUx0sO/+jIUHC8dxxovJ3Fzu6mNCvLesIWaAY2XMHXeDwA3jSkAwcOGMtzFx5wuJ1lMJJ+PaGn33xzDhh3M24iXy5wxzC0EtNoZL/laXJDc/ABsuPN4UQ7l67Sc5MXIiEMeK9jCxfbYNTgAkj4BdqR/iZ+fpnLbW4UQMrUVW9O3TECx9tD5GmciskREi2J1DHMGxVBJk4QjeA2KwOZykqfM7THkHiKcEMHfetfGezuJ+2QQLQ2tnYcf7dOtMkthPVSp2k6xZjC0eyrX7l4tDhhY35giEitNPS4Koch7lsULv76EsNzBp30RsIMmAB+Jgxev6jA53g+Yy4L9eAdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QRQJIUowzY0uDyrfm8e5uhuNn4cnltEV9GC1DLK0C7c=; b=AmxDenMmYj0Jsp3ZMGnQMu5gdtSoP1ihYcNKcCTEKfukq6dUdJcPLyTvo16mE1ztwL9fB3osDr/xs9Rnjjh20tFTTje16f3VU/YwgDrhubZ5zutvDlzJXDFjF8604G6ygJGybMLuP2CV00s82mPpmSGVkRHAAmhZbugfIgZkE2EQMc7Vnq+m8tN+6iYISIr/7NLXR+ugaRSPMlcDyxqltYxSxMBItS+M/AOoT/7R3I1Y3nWrU2fuUoliei84RNneZWxON1kUE8LvvhKDJ/Q8EO14qRKpL7MFAO3dLh74/IB57uItMygCLGahPwxvO5kwnOtsR1iVkEfpXatXtTEWbQ== 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 VI1PR08MB3439.eurprd08.prod.outlook.com (2603:10a6:803:7d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.23; Mon, 4 Jan 2021 12:11:03 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::f937:5b3:12e1:8297]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::f937:5b3:12e1:8297%7]) with mapi id 15.20.3721.024; Mon, 4 Jan 2021 12:11:03 +0000 Date: Mon, 4 Jan 2021 12:11:00 +0000 To: gcc-patches@gcc.gnu.org Subject: [RFC] AArch64: Have RTL patterns recognize DI extracts from vectors at offset 0 as no-op. Message-ID: Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [217.140.106.53] X-ClientProxiedBy: LO4P123CA0237.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::8) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.53) by LO4P123CA0237.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Mon, 4 Jan 2021 12:11:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 19de5f62-0814-477c-9063-08d8b0a9d39a X-MS-TrafficTypeDiagnostic: VI1PR08MB3439:|DB7PR08MB3562: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XztF3/kUD9De2YVMJCWkLWyhNn9iMb74defb3wuPcfQdcRNV5fvf+bLcNNkXyynCc9NjFTpC73mzOX3lUDesdyDBoPwU6ds3XtAjBCSxrWso8CGdnEx18GwiPqolWJqglyISPUNSHJ1pUcv33EINmWaD6Fk5SMlwnUKVjgOnCDjtMYGk2l2M/EcCWknR0lwuXNu20kVDGaVz20fcfus6sZa9airTZZbj6nupKf7eLB0nTMNFTdYSp0GlFjSMPM9DqzlxPQNR42LUCwE8O9wZBFJsu5+e1jsE7PLhwdxA/DE1m/3tmtbHF6/FEBHdPLKuluV9p7ufJ6ZfurIdfuLfxrclvvJr2SIwYIMUj7Cv9Bri1K7qTe6LF0ks5zd42SuqnEqU4f72vjIFPvXNcwaQzeQMCnTsbtHpOkxIwY2qm8evV3VivrD6fwauDqOP5rLKAuOLqhknq8uQutK+9Ly56w== 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)(346002)(39860400002)(376002)(136003)(396003)(55016002)(16526019)(44832011)(186003)(2906002)(7696005)(52116002)(83380400001)(44144004)(33964004)(956004)(6916009)(2616005)(86362001)(26005)(66556008)(478600001)(36756003)(5660300002)(8886007)(235185007)(66946007)(66476007)(8936002)(66616009)(4326008)(316002)(8676002)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?S1ce2Umvnqm4H9JMJ6vXh2IOmnrL5b?= =?utf-8?q?18f5sjPgn0fu9eJxhLDjrnr4PAUxVnXJZnP95SGFJ9lt0TUIVEvucB+zcOnJ05Ygj?= =?utf-8?q?iE9NdoOMVxQ5djbzROyrO0vXW7iZbeqtpp1rJotvHpSI1YfZrgXwu1JpYuFAQsOWz?= =?utf-8?q?JdlF6xUGEBYDOED8hY9gAhPXrWs3m5H/ecGtBb9QErQJymcynaIRm1EDcNC3t2WIC?= =?utf-8?q?J05bhFTgwvUYRFDUXJ6i2RQGyFuo2v+0cswUC1DS+nfCWgunMKtpgESu2LJ0wEB1e?= =?utf-8?q?AXO5QeXVtDyF6nUCEvXfII5Mwf9Pt66aUI53gLV96w4j5DEuapoV+V21xwO7MMDmU?= =?utf-8?q?eBZIOocfiHor0HFSsjZus8MeIWIIMnE3bUOjcFD/n3qjtJtMIqfvhsA1XDJpmbm7C?= =?utf-8?q?/1o7id/K4iyM75tnC+e3Ck4uMas2oQ0F9pAk2KVyvFuNBscxFm9qB+egiXIF5+6BK?= =?utf-8?q?o1HMlymwSdm65Ra9qrNPu5BaJqN6WvYMu4Xv7nW+FpJxKzjoBDWq+rMpkhAtRF340?= =?utf-8?q?Zedw+qucp+M6SUlidMsiVqeT2uwIASBfR4Bsc0n39G9SlIlwHjsbjXCH7hLmEVE+J?= =?utf-8?q?aqSMDo8FM3n7r/g+hjKIRncNNoiD+8tQDhcnfR81nVxMXWzyCE6TIsMTK/j4ub1g8?= =?utf-8?q?W99FVeUv/EXPejFIsOitLHnoOuS88t9oI9urC4FaOtgCLZI0ip0I9M2/atNzZjbyj?= =?utf-8?q?iDU84tNMU4zwW/HYfTcxd1o/jADFMvqWfoYuLDsrAMiHAvpD4NXEYtgavp4aOr4+H?= =?utf-8?q?U44MQn2s4GmN+rQJJOSsRQSuXq00UBEACs5qXpXihXLcBvBE1VyjVwcaDYV8nPMwq?= =?utf-8?q?H+6IKH8ugyBIWM/qGMYVz9HPKjYWHxzhF5PEfMuaAjhcSbyqt1AZd4Z5nWoppTbC7?= =?utf-8?q?9svTgsWj1KZyCh6J8XoweLbkMONusaJeGcsA1ZM95G0sGKOOphSV9SgRtJsFsd5PT?= =?utf-8?q?zhcWKoJB2dF+yWtGQgd?= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3439 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: DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 58a4613f-0e14-484b-4335-08d8b0a9ce64 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kSntwnm2hc7KGqHKdjWUK3NJAVImIeHDcgbiY67273RUBSfgekVdQTsiP4/vulq7t/vPGPy3NDxtTjRc/YdeCgQavggIJv9KalaaYD5zzSpWbQQRRSNCfAojR8YG/fDEG1EcOvN2GPJ67v3XWezueqyVJF39i/n7m397+PBLfTOMd6boFmhjAAecV4MK4zmKFomSCjrWLTYRcWsYwzJI3rpq5awArw93LFPZBiHnmVRwnjHYDGkCKzLwNqckgguDpRhFnQbHk0OW4NV97yXnhp8STMFaMTez835tHW1o3oehDwoTtYjsjNeLxqVT1my5MpNn2AmqivL9OO1Zfs2QgSUkX+IvWfvtuGUTdBv/5J7Ih2z1T1uHXuQp0rMYtXcv5lYcBYpfCVonEg9AVWsLiv3siWVwcbNEcpjmxpSswjvkwex/bCiJO+Vaq/RRE7kOrIzzlO9O0ble3JWRpeDM0vFfKsruJYHTwIQbSzZlWDuJTLhxdfb0bULfMJ6K+/mR 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)(346002)(396003)(136003)(39860400002)(376002)(46966006)(5660300002)(2906002)(316002)(36756003)(4326008)(86362001)(83380400001)(8936002)(44832011)(7696005)(235185007)(8676002)(478600001)(2616005)(47076005)(70206006)(82740400003)(956004)(70586007)(6916009)(8886007)(66616009)(186003)(33964004)(336012)(44144004)(26005)(55016002)(356005)(16526019)(82310400003)(81166007)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2021 12:11:11.8948 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19de5f62-0814-477c-9063-08d8b0a9d39a 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: DB5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3562 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina Cc: Richard.Earnshaw@arm.com, nd@arm.com, richard.sandiford@arm.com, Marcus.Shawcroft@arm.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi All, I have been looking into a class of problems where GCC is not recognizing that a subreg of lane 0 (using little-endian as example) of a vector register and passing that to an instruction. As an example consider poly64_t testcase (uint8x16_t input, poly64x2_t mask) { poly64_t prodL = vmull_p64((poly64_t)vgetq_lane_p64((poly64x2_t)input, 0), vgetq_lane_p64(mask, 0)); poly64_t prodH = vmull_high_p64((poly64x2_t)input, mask); return prodL + prodH; } Where we generate testcase: dup d2, v0.d[0] dup d3, v1.d[0] pmull2 v0.1q, v0.2d, v1.2d pmull v2.1q, v2.1d, v3.1d add d0, d2, d0 fmov x0, d0 ret whereas it should have been, which clang generates: testcase: pmull v2.1q, v0.1d, v1.1d pmull2 v0.1q, v0.2d, v1.2d add v0.2d, v0.2d, v2.2d fmov x0, d0 ret Now this can be naively solved by just adding the RTL patterns for the vec_selects as the example in the patch, but this doesn't solve the overall problem and I am wondering how to best do this. One approach would be to extend combine's noop detection in noop_move_p to recognize these cases. The downside here is that the conversion becomes implicit in the rtl. i.e. you'll see a SET of a V2DI but a use of DI for that same register. I'm not sure the semantics of RTL allow such implicit uses? The second approach I can think of is to extend reload to recognize these no-ops and give the same register and mark the extract as unused such that DSE cleans it up. But there's probably a better approach I didn't think of :) Thanks, Tamar gcc/ChangeLog: * config/aarch64/aarch64-simd.md (*aarch64_crypto_pmullv2di): Example RTL. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pmull_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 05d18f8bd3ac09c56c82dc73cff855315eb302b7..7bdb93869dbbedc786575b5f89f39c4c6d0d76d0 100644 diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 05d18f8bd3ac09c56c82dc73cff855315eb302b7..7bdb93869dbbedc786575b5f89f39c4c6d0d76d0 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -7231,6 +7231,20 @@ (define_insn "aarch64_crypto_pmulldi" [(set_attr "type" "crypto_pmull")] ) +(define_insn "*aarch64_crypto_pmullv2di" + [(set (match_operand:TI 0 "register_operand" "=w") + (unspec:TI [(vec_select:DI + (match_operand:V2DI 1 "register_operand" "w") + (parallel [ + (match_operand:SI 2 "const_int_operand" "Z")])) + (match_operand:DI 3 "register_operand" "w")] + UNSPEC_PMULL))] + "TARGET_SIMD && TARGET_AES" + "pmull\\t%0.1q, %1.1d, %3.1d" + [(set_attr "type" "crypto_pmull")] +) + + (define_insn "aarch64_crypto_pmullv2di" [(set (match_operand:TI 0 "register_operand" "=w") (unspec:TI [(match_operand:V2DI 1 "register_operand" "w") diff --git a/gcc/testsuite/gcc.target/aarch64/pmull_2.c b/gcc/testsuite/gcc.target/aarch64/pmull_2.c new file mode 100644 index 0000000000000000000000000000000000000000..d9d47518fab2b582329b6332e3a9c7d97c148192 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pmull_2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv8-a+crypto -O3" } */ + +#include "arm_neon.h" + +poly64_t +testcase (uint8x16_t input, poly64x2_t mask) +{ + poly64_t prodL = vmull_p64((poly64_t)vgetq_lane_p64((poly64x2_t)input, 0), + vgetq_lane_p64(mask, 0)); + poly64_t prodH = vmull_high_p64((poly64x2_t)input, mask); + return prodL + prodH; +} + +/* { dg-final { scan-assembler-times "pmull\\tv" 1 } } */