From patchwork Wed Nov 9 12:58:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 81479 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp180217qge; Wed, 9 Nov 2016 04:59:46 -0800 (PST) X-Received: by 10.98.79.193 with SMTP id f62mr33127162pfj.149.1478696386584; Wed, 09 Nov 2016 04:59:46 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t129si42082485pgc.171.2016.11.09.04.59.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Nov 2016 04:59:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-440844-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-440844-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-440844-patch=linaro.org@gcc.gnu.org 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:content-type:mime-version; q=dns; s=default; b=kQHridaYOB6qn9D0po0A5aPgEZHvWvdQAGvRYUtYt8NkQv09m8 PE1JnBlRHy/57JIFukO/cWUrJ4WGVb/HxfHgN0F746f5l/Xab4gN2po3r/o+WNA5 WtIVe6+qYX3PEm+hYDvl8EU7GcJcFn5VKlVLSkdGGcwmaZMgXL7cDhS3E= 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:content-type:mime-version; s= default; bh=W5ySEGaDF4WDaku96ue9dAe3gds=; b=ZVKLrV99I+97LNY90yr9 WabCJrgIQkjt9l34CdsgWrLohN7FASsntBA/23e08XSZXqVamjnAK4OTv8gf1Lkm AyLCbk4R1ETzJzJNQcXnHi2d6FwRlogICIivfXefQOsEOqg2y3tM7IbHjvKLMpIy vfXVFsp2aL+c+PL95tCdL9I= Received: (qmail 59150 invoked by alias); 9 Nov 2016 12:59:23 -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 59114 invoked by uid 89); 9 Nov 2016 12:59:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_05, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS, URI_NOVOWEL autolearn=no version=3.3.2 spammy=1978, Hx-spam-relays-external:sk:snt004-, HX-HELO:sk:SNT004-, H*RU:sk:snt004- X-HELO: SNT004-OMC4S10.hotmail.com Received: from snt004-omc4s10.hotmail.com (HELO SNT004-OMC4S10.hotmail.com) (65.55.90.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Nov 2016 12:59:12 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com ([65.55.90.199]) by SNT004-OMC4S10.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Wed, 9 Nov 2016 04:59:11 -0800 Received: from HE1EUR02FT037.eop-EUR02.prod.protection.outlook.com (10.152.10.55) by HE1EUR02HT046.eop-EUR02.prod.protection.outlook.com (10.152.10.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.3; Wed, 9 Nov 2016 12:58:59 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.10.52) by HE1EUR02FT037.mail.protection.outlook.com (10.152.10.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.3 via Frontend Transport; Wed, 9 Nov 2016 12:58:59 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) with mapi id 15.01.0721.008; Wed, 9 Nov 2016 12:58:59 +0000 From: Bernd Edlinger To: GCC Patches CC: Kyrill Tkachov , Richard Earnshaw , Wilco Dijkstra Subject: [PATCH, ARM] Enable ldrd/strd peephole rules unconditionally Date: Wed, 9 Nov 2016 12:58:58 +0000 Message-ID: authentication-results: foss.arm.com; dkim=none (message not signed) header.d=none; foss.arm.com; dmarc=none action=none header.from=hotmail.de; x-incomingtopheadermarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:2496; Count:37 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [rNF9wSMu48qxRooJWrjazxaWk6mi/o14] x-incomingheadercount: 37 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; HE1EUR02HT046; 7:YRMYlREUJrUEsYulMKhx3OTFuD3wpi//cEBpgwWXfr20w/mTWiqm6MKCavjylMgrhSKKJ2ltIN7Ty/V9Vn+pB1qhzKkxDJl0FF8uNb0471DR0eKrXzMAhiWjV/G9PL/A6eOAhGCJopXOwy460RrdnZYHZmmYvwUxt9VCe4kvWvQU+B1TVbP8wld1ttUs79PSbrZY/9pjMDZ6W/hLybQrhy9/f1WoRaMCSuKHw0xDn7kRopZQ7+V0TPMzhH9C0aHjtlF/2XeG2wCPYc1XvGp8cglGDzTwGiYxkjo5tTc2iiVfY5C+OGelEgxbVVKvgCIY5Zp+4RDHCIZQn80ANu/vVbBqmB13fl6lkExL9HmRvWc= x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1EUR02HT046; H:AM4PR0701MB2162.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 8e2f3088-7834-49e1-5a23-08d408a02bec x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1EUR02HT046; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(102415365)(82015046); SRVR:HE1EUR02HT046; BCL:0; PCL:0; RULEID:; SRVR:HE1EUR02HT046; x-forefront-prvs: 0121F24F22 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2016 12:58:58.9170 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR02HT046 Hi! This patch enables the ldrd/strd peephole rules unconditionally. It is meant to fix cases, where the patch to reduce the sha512 stack usage splits ldrd/strd instructions into separate ldr/str insns, but is technically independent from the other patch: See https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00523.html It was necessary to change check_effective_target_arm_prefer_ldrd_strd to retain the true prefer_ldrd_strd tuning flag. Bootstrapped and reg-tested on arm-linux-gnueabihf. Is it OK for trunk? Thanks Bernd. 2016-11-02 Bernd Edlinger PR target/77308 * config/arm/arm.md (*thumb2_ldrd, *thumb2_ldrd_base, *thumb2_ldrd_base_neg, *thumb2_strd, *thumb2_strd_base, *thumb2_strd_base_neg): Recognize insn regardless of current_tune->prefer_ldrd_strd. * config/arm/ldrdstrd.md: Enable all ldrd/strd peephole rules whenever possible. testsuite: 2016-11-02 Bernd Edlinger PR target/77308 * gcc.target/arm/pr53447-5.c: New test. * lib/target-supports.exp (check_effective_target_arm_prefer_ldrd_strd): Adjust. Index: gcc/config/arm/arm.md =================================================================== --- gcc/config/arm/arm.md (revision 241816) +++ gcc/config/arm/arm.md (working copy) @@ -11636,7 +11636,6 @@ (mem:SI (plus:SI (match_dup 1) (match_operand:SI 4 "const_int_operand" ""))))] "TARGET_LDRD && TARGET_THUMB2 && reload_completed - && current_tune->prefer_ldrd_strd && ((INTVAL (operands[2]) + 4) == INTVAL (operands[4])) && (operands_ok_ldrd_strd (operands[0], operands[3], operands[1], INTVAL (operands[2]), @@ -11653,7 +11652,6 @@ (mem:SI (plus:SI (match_dup 1) (const_int 4))))] "TARGET_LDRD && TARGET_THUMB2 && reload_completed - && current_tune->prefer_ldrd_strd && (operands_ok_ldrd_strd (operands[0], operands[2], operands[1], 0, false, true))" "ldrd%?\t%0, %2, [%1]" @@ -11668,7 +11666,6 @@ (set (match_operand:SI 2 "s_register_operand" "=r") (mem:SI (match_dup 1)))] "TARGET_LDRD && TARGET_THUMB2 && reload_completed - && current_tune->prefer_ldrd_strd && (operands_ok_ldrd_strd (operands[0], operands[2], operands[1], -4, false, true))" "ldrd%?\t%0, %2, [%1, #-4]" @@ -11684,7 +11681,6 @@ (match_operand:SI 3 "const_int_operand" ""))) (match_operand:SI 4 "s_register_operand" "r"))] "TARGET_LDRD && TARGET_THUMB2 && reload_completed - && current_tune->prefer_ldrd_strd && ((INTVAL (operands[1]) + 4) == INTVAL (operands[3])) && (operands_ok_ldrd_strd (operands[2], operands[4], operands[0], INTVAL (operands[1]), @@ -11701,7 +11697,6 @@ (const_int 4))) (match_operand:SI 2 "s_register_operand" "r"))] "TARGET_LDRD && TARGET_THUMB2 && reload_completed - && current_tune->prefer_ldrd_strd && (operands_ok_ldrd_strd (operands[1], operands[2], operands[0], 0, false, false))" "strd%?\t%1, %2, [%0]" @@ -11716,7 +11711,6 @@ (set (mem:SI (match_dup 0)) (match_operand:SI 2 "s_register_operand" "r"))] "TARGET_LDRD && TARGET_THUMB2 && reload_completed - && current_tune->prefer_ldrd_strd && (operands_ok_ldrd_strd (operands[1], operands[2], operands[0], -4, false, false))" "strd%?\t%1, %2, [%0, #-4]" Index: gcc/config/arm/ldrdstrd.md =================================================================== --- gcc/config/arm/ldrdstrd.md (revision 241816) +++ gcc/config/arm/ldrdstrd.md (working copy) @@ -29,9 +29,7 @@ (match_operand:SI 2 "memory_operand" "")) (set (match_operand:SI 1 "arm_general_register_operand" "") (match_operand:SI 3 "memory_operand" ""))] - "TARGET_LDRD - && current_tune->prefer_ldrd_strd - && !optimize_function_for_size_p (cfun)" + "TARGET_LDRD" [(const_int 0)] { if (!gen_operands_ldrd_strd (operands, true, false, false)) @@ -63,9 +61,7 @@ (match_operand:SI 0 "arm_general_register_operand" "")) (set (match_operand:SI 3 "memory_operand" "") (match_operand:SI 1 "arm_general_register_operand" ""))] - "TARGET_LDRD - && current_tune->prefer_ldrd_strd - && !optimize_function_for_size_p (cfun)" + "TARGET_LDRD" [(const_int 0)] { if (!gen_operands_ldrd_strd (operands, false, false, false)) @@ -102,9 +98,7 @@ (match_operand:SI 5 "const_int_operand" "")) (set (match_operand:SI 3 "memory_operand" "") (match_dup 1))] - "TARGET_LDRD - && current_tune->prefer_ldrd_strd - && !optimize_function_for_size_p (cfun)" + "TARGET_LDRD" [(const_int 0)] { if (!gen_operands_ldrd_strd (operands, false, true, false)) @@ -147,10 +141,8 @@ (match_dup 0)) (set (match_operand:SI 3 "memory_operand" "") (match_dup 1))] - "TARGET_LDRD - && current_tune->prefer_ldrd_strd - && !optimize_function_for_size_p (cfun)" - [(const_int 0)] + "TARGET_LDRD" + [(const_int 0)] { if (!gen_operands_ldrd_strd (operands, false, true, false)) FAIL; @@ -197,8 +189,6 @@ [(match_operand 6 "arm_general_register_operand" "") (match_operand 7 "arm_general_register_operand" "") ]))] "TARGET_LDRD && TARGET_ARM - && current_tune->prefer_ldrd_strd - && !optimize_function_for_size_p (cfun) && ( ((rtx_equal_p(operands[0], operands[6])) && (rtx_equal_p(operands[1], operands[7]))) ||((rtx_equal_p(operands[0], operands[7])) && (rtx_equal_p(operands[1], operands[6])))) && (peep2_reg_dead_p (3, operands[0]) || rtx_equal_p (operands[0], operands[4])) @@ -231,8 +221,6 @@ (match_operand 7 "arm_general_register_operand" "") ])) (clobber (reg:CC CC_REGNUM))])] "TARGET_LDRD && TARGET_ARM - && current_tune->prefer_ldrd_strd - && !optimize_function_for_size_p (cfun) && ( ((rtx_equal_p(operands[0], operands[6])) && (rtx_equal_p(operands[1], operands[7]))) ||((rtx_equal_p(operands[0], operands[7])) && (rtx_equal_p(operands[1], operands[6])))) && (peep2_reg_dead_p (3, operands[0]) || rtx_equal_p (operands[0], operands[4])) Index: gcc/testsuite/gcc.target/arm/pr53447-5.c =================================================================== --- gcc/testsuite/gcc.target/arm/pr53447-5.c (revision 0) +++ gcc/testsuite/gcc.target/arm/pr53447-5.c (working copy) @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -mthumb" } */ +/* { dg-require-effective-target arm_thumb2_ok } */ + +void foo(long long* p) +{ + p[1] |= 0x100000001; + p[2] &= 0x100000001; + p[3] ^= 0x100000001; + p[4] += 0x100000001; + p[5] -= 0x100000001; + p[6] = ~p[6]; + p[7] <<= 5; + p[8] >>= 5; + p[9] -= p[10]; +} + +/* { dg-final { scan-assembler-times "ldrd" 10 } } */ +/* { dg-final { scan-assembler-times "strd" 9 } } */ Index: gcc/testsuite/gb/target-supports.exp --- gcc/testsuite/lib/target-supports.exp (revision 241816) +++ gcc/testsuite/lib/target-supports.exp (working copy) @@ -4317,7 +4317,7 @@ } return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly { - void foo (int *p) { p[0] = 1; p[1] = 0;} + void foo (void) { __asm__ ("" ::: "r4", "r5"); } } "-O2 -mthumb" ] }