From patchwork Tue Aug 15 16:25:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 801667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460390-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Swmv3kY+"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xWybG27Dpz9sPm for ; Wed, 16 Aug 2017 02:28:42 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=KgtGTmlQpAn3mpjZ+xjobDKWIS5zxp2PbY8vj0uS8+Ws7qGEkD6Me G5ld3/UNgBEHLG/rzCYEVodCUPJnUl0Fkx2ZlyYVULGbz5VXiG/WbAR2MysdV61y VUzb8+h61keNlPkk5Zh+qPly78X8pzqpO2wAVpUHqLHKDj4HLzoFsc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=default; bh=+wOBD573ZSIlwhpl8BxX3wx2iv8=; b=Swmv3kY+r7PzVKPuHRNgUlU1/VKN zwWSj93yLhA6IDeU+WuU/+KqJTWBL+4WDZ/fP86Y21jJsUF9RH2eWDB4sOxXN6fv +qYb0uw2PmdwJvyPT/S6tj7LAKMyoXLLpNob/68EjjabshTccPULZWmpyPG1ntaS Q2hupDywiw9+ivk= Received: (qmail 126765 invoked by alias); 15 Aug 2017 16:27:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 126243 invoked by uid 89); 15 Aug 2017 16:26:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=inefficiencies X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0043.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Aug 2017 16:26:05 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by VI1PR08MB2670.eurprd08.prod.outlook.com (10.175.245.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.17; Tue, 15 Aug 2017 16:25:40 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a%18]) with mapi id 15.01.1341.020; Tue, 15 Aug 2017 16:25:40 +0000 From: Wilco Dijkstra To: GCC Patches , James Greenhalgh CC: nd Subject: Re: [PATCH][AArch64] Improve addressing of TI/TFmode Date: Tue, 15 Aug 2017 16:25:40 +0000 Message-ID: References: , In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB2670; 6:GA7fHCXVM1tzlj2hNOhjA5uMTltMUc0kcn0XrtOk1gI7rQhLnUh2sh1ql+tJTljKg9pNsnF3A88tDzpC3o7N+Ma5DkNBuBPQ4b9IKpbShOFKeqv2wSSaDRuQvllUk2SqH5cibCEjWoDw+4w+NQjE64WOzI3mQjZCmYRfvaz2ESl2Og6mAp/4ssJThHJoEaFob1OB9cx1EGTWI11nxa7pZUF9StkI7XY/b8+QG7XIGFvDgRkUPoBAMe4lklUtijXQApQ94hMU+pC29lIW7/3GY4oFEukryrKkOMRiVUmdVUU/sCQKzg6bGR85iQV0tWXEvuSs1D25KQjG7p8Q4QkdCw==; 5:HKMahsmGBakCQnSiyknEPp6LVeA6tOGd9YsIplwtUmPHoA0e32Mx/f0aE4C4iQW7jCW2+cGVhBuM+GD2BZdPhV0GtPZtaesAdOrbS+YsrgmUkys1A5KCQ65xalKwZaFbFGr7YS0Ja97ZlifyRCJNXg==; 24:W1faq086rKf+S4WqgZ0SIVe7k/SqnG+FWjiX+OtFg+vBLL5DxNnGLJylg6h48nCh1sdo9jZcPIoypzgRJpmv8Vprac1YLetEp23IG/+xzJM=; 7:94anHWv750pd41lZuETO8jUOq9yvdbcGktnUEf7iB9Ks/hMARkdp4DLP4kUS9hPE/orgiXOBIHrJQrwfgv4ZqmyMVTWInvOfUTW+bpl9onPfHGXKT23wSsirkrsVdrqr8FCo6Sl/WAaHyELOFOE5FHGZ3CR+SZchRM2iGe8gZMS6XXHZQvr7Ga04JgUJzwoG69XGOlYvJ2tueMosWFX3OBVHDFMJqtLoAQwiCE4t3h4= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 7dbee34a-fee2-41f4-1751-08d4e3fa44d0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VI1PR08MB2670; x-ms-traffictypediagnostic: VI1PR08MB2670: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917)(22074186197030)(183786458502308); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR08MB2670; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR08MB2670; x-forefront-prvs: 04004D94E2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(189002)(54534003)(199003)(377424004)(53936002)(305945005)(3846002)(3660700001)(2900100001)(7736002)(86362001)(575784001)(2950100002)(7696004)(966005)(478600001)(66066001)(5250100002)(6506006)(33656002)(8936002)(97736004)(189998001)(53546010)(2906002)(81156014)(102836003)(6116002)(3280700002)(8676002)(81166006)(229853002)(68736007)(105586002)(101416001)(74316002)(50986999)(54356999)(6436002)(76176999)(25786009)(14454004)(106356001)(6306002)(6246003)(6636002)(9686003)(5660300001)(4326008)(72206003)(55016002)(99286003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB2670; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Aug 2017 16:25:40.0337 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2670 ping From: Wilco Dijkstra Sent: 20 July 2017 13:49 To: GCC Patches; James Greenhalgh Cc: nd Subject: [PATCH][AArch64] Improve addressing of TI/TFmode     In  https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01125.html Jiong pointed out some addressing inefficiencies due to a recent change in regcprop (https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00775.html). This patch improves aarch64_legitimize_address_displacement to split unaligned offsets of TImode and TFmode accesses.  The resulting code is better and no longer relies on the original regcprop optimization. For the test we now produce:         add     x1, sp, 4         stp     xzr, xzr, [x1, 24] rather than:         mov     x1, sp         add     x1, x1, 28         stp     xzr, xzr, [x1] OK for commit? ChangeLog: 2017-06-20  Wilco Dijkstra          * config/aarch64/aarch64.c (aarch64_legitimize_address_displacement):         Improve unaligned TImode/TFmode base/offset split. testsuite         * gcc.target/aarch64/ldp_stp_unaligned_2.c: New file. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 90f248025a4fa928ebac657b689010f74dd100b5..208fdbe7262a93ee8caada2868a8d447de619c6e 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -4705,15 +4705,17 @@ aarch64_legitimate_address_p (machine_mode mode, rtx x,  /* Split an out-of-range address displacement into a base and offset.     Use 4KB range for 1- and 2-byte accesses and a 16KB range otherwise     to increase opportunities for sharing the base address of different sizes. -   For unaligned accesses and TI/TF mode use the signed 9-bit range.  */ +   Unaligned accesses use the signed 9-bit range, TImode/TFmode use +   the intersection of signed scaled 7-bit and signed 9-bit offset.  */  static bool  aarch64_legitimize_address_displacement (rtx *disp, rtx *off, machine_mode mode)  {    HOST_WIDE_INT offset = INTVAL (*disp);    HOST_WIDE_INT base = offset & ~(GET_MODE_SIZE (mode) < 4 ? 0xfff : 0x3ffc);   -  if (mode == TImode || mode == TFmode -      || (offset & (GET_MODE_SIZE (mode) - 1)) != 0) +  if (mode == TImode || mode == TFmode) +    base = (offset + 0x100) & ~0x1f8; +  else if ((offset & (GET_MODE_SIZE (mode) - 1)) != 0)      base = (offset + 0x100) & ~0x1ff;      *off = GEN_INT (base); diff --git a/gcc/testsuite/gcc.target/aarch64/ldp_stp_unaligned_2.c b/gcc/testsuite/gcc.target/aarch64/ldp_stp_unaligned_2.c new file mode 100644 index 0000000000000000000000000000000000000000..1e46755a39a0b97fa7af704086f82ffd5a216fb4 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/ldp_stp_unaligned_2.c @@ -0,0 +1,18 @@ +/* { dg-options "-O2 -fomit-frame-pointer" } */ + +/* Check that we split unaligned LDP/STP into base and aligned offset.  */ + +typedef struct +{ +  int a, b, c, d, e; +} S; + +void foo (S *); + +void test (int x) +{ +  S s = { .a = x }; +  foo (&s); +} + +/* { dg-final { scan-assembler-not "mov\tx\[0-9\]+, sp" } } */