From patchwork Mon Sep 5 14:59:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 665876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3sSXvN6dT3z9s36 for ; Tue, 6 Sep 2016 00:59:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=qTaRbHP9; dkim-atps=neutral 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:mime-version:content-type; q=dns; s=default; b=jKHzQlDHrL5ciuGd0/+VVoCdG4tqNuOLH2QI3cbYCvrqpBJlmS Idy+160qB1bKom/0HOYRdjFdaAr47t+Zk/oS1FCwouD0MXUeaM6dnxDSmtjTRvra yAineDNmsGwn7CP/LDLXQ/myknSofPYUJ0uT48oiL+GrYY9Zmlxyr5hdY= 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:mime-version:content-type; s= default; bh=79AOLUUYs8KdQay8Tj3lM/Gw3oc=; b=qTaRbHP91IZzrrZuM38w vwQSTeudjLd0w3ci7GaEOeog6BaDqHBvYHTBrTCs2JEsdfaCZXvI/O0Zhewg3YqE 2zwHU+AhFYvDWHDQeMNNaMx9cwFcsUS8RMt6YMomiabsrCEuRoJ6G5A1BpvLDRUV cAr5s3XKTkt8AqFxIYn+qj0= Received: (qmail 39475 invoked by alias); 5 Sep 2016 14:59:36 -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 39466 invoked by uid 89); 5 Sep 2016 14:59:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:sk:EUR01-H, H*RU:sk:EUR01-H, 20160817, 2016-08-17 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Sep 2016 14:59:25 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp0208.outbound.protection.outlook.com [213.199.154.208]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-29-RcZwhYWVPRSYlHGT-dA5kg-1; Mon, 05 Sep 2016 15:59:21 +0100 Received: from VI1PR0801MB2031.eurprd08.prod.outlook.com (10.173.74.140) by VI1PR0801MB2029.eurprd08.prod.outlook.com (10.173.74.138) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9; Mon, 5 Sep 2016 14:59:19 +0000 Received: from VI1PR0801MB2031.eurprd08.prod.outlook.com ([10.173.74.140]) by VI1PR0801MB2031.eurprd08.prod.outlook.com ([10.173.74.140]) with mapi id 15.01.0599.010; Mon, 5 Sep 2016 14:59:18 +0000 From: Tamar Christina To: GCC Patches CC: James Greenhalgh , Richard Earnshaw , Marcus Shawcroft , nd Subject: [PATCH] Allow FP to be used as a call-saved registe Date: Mon, 5 Sep 2016 14:59:18 +0000 Message-ID: x-ms-office365-filtering-correlation-id: 14a4d838-f2e9-435a-9e69-08d3d59d3651 x-microsoft-exchange-diagnostics: 1; VI1PR0801MB2029; 20:wEz1ZCxcaIlr5ZgofZPx/+eOQUx/zEn5ErA0vdYd3yq0EKMGoT/toeXGVHQ/k0SveWp0p/3uLlWl2tPmbaAN/O/JlpmrYSsDYJ99rDAOYz6ACIj87h2+LRXVn1G/0To45xleQUzF/e8ls7WtXod1Kegya7JnlLz19gGdYYf1ESI= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB2029; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415321)(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:VI1PR0801MB2029; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB2029; x-forefront-prvs: 005671E15D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(53754006)(377424004)(199003)(189002)(8936002)(81166006)(305945005)(586003)(6116002)(2900100001)(77096005)(76576001)(68736007)(106116001)(189998001)(5660300001)(122556002)(450100001)(86362001)(8676002)(229853001)(92566002)(99936001)(87936001)(66066001)(102836003)(54356999)(101416001)(10400500002)(33656002)(50986999)(9686002)(74316002)(19580405001)(3846002)(110136002)(3660700001)(7696003)(5002640100001)(7846002)(3280700002)(106356001)(105586002)(7736002)(19580395003)(4326007)(2906002)(81156014)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB2029; H:VI1PR0801MB2031.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Sep 2016 14:59:18.5630 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2029 X-MC-Unique: RcZwhYWVPRSYlHGT-dA5kg-1 X-IsSubscribed: yes Hi All, This patch allows the FP register to be used as a call-saved register when -fomit-frame-pointer is used. The change is done in such a way that the defaults do not change. To use the FP register both -fomit-frame-pointer and -fcall-saved- need to be used. Regression ran on aarch64-none-linux-gnu and no regressions. Bootstrapped and ran regressions on `x86_64` and no regressions. A new test fp_free_1 was added to test functionality. Ok for trunk? Thanks, Tamar PS. I don't have commit rights so if OK can someone apply the patch for me. gcc/ 2016-09-01 Tamar Christina * gcc/reginfo.c (fix_register): Allow FP to be set if -fomit-frame-pointer. gcc/testsuite/ 2016-08-17 Tamar Christina * gcc.target/aarch64/fp_free_1.c: New. diff --git a/gcc/reginfo.c b/gcc/reginfo.c index 0cda6aa620098c752522add589b42631b382d9fc..ea96e236a5f76fb7ddc2c9406b7b377aa0eb3087 100644 --- a/gcc/reginfo.c +++ b/gcc/reginfo.c @@ -692,12 +692,13 @@ fix_register (const char *name, int fixed, int call_used) for (i = reg; i < reg + nregs; i++) { if ((i == STACK_POINTER_REGNUM + || ( #ifdef HARD_FRAME_POINTER_REGNUM - || i == HARD_FRAME_POINTER_REGNUM + i == HARD_FRAME_POINTER_REGNUM #else - || i == FRAME_POINTER_REGNUM + i == FRAME_POINTER_REGNUM #endif - ) + && !flag_omit_frame_pointer)) && (fixed == 0 || call_used == 0)) { switch (fixed) diff --git a/gcc/testsuite/gcc.target/aarch64/fp_free_1.c b/gcc/testsuite/gcc.target/aarch64/fp_free_1.c new file mode 100644 index 0000000000000000000000000000000000000000..79e23b13d3fb0f801e201c69286d27bac97aa013 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fp_free_1.c @@ -0,0 +1,32 @@ +/* { dg-do run { target aarch64-*-* } } */ +/* { dg-options "-O2 -fno-inline -fomit-frame-pointer -ffixed-x2 -ffixed-x3 -ffixed-x4 -ffixed-x5 -ffixed-x6 -ffixed-x7 -ffixed-x8 -ffixed-x9 -ffixed-x10 -ffixed-x11 -ffixed-x12 -ffixed-x13 -ffixed-x14 -ffixed-x15 -ffixed-x16 -ffixed-x17 -ffixed-x18 -ffixed-x19 -ffixed-x20 -ffixed-x21 -ffixed-x22 -ffixed-x23 -ffixed-x24 -ffixed-x25 -ffixed-x26 -ffixed-x27 -ffixed-x28 -ffixed-x30 -mgeneral-regs-only -fno-ipa-cp -fno-schedule-fusion -fno-peephole2 -fcall-saved-x29 -fdump-rtl-ira" } */ + +extern void abort (); + +int +dec (int a, int b) +{ + return a + b; +} + +int +cal (int a, int b) +{ + int sum1 = a * b; + int sum2 = a / b; + int sum = dec (sum1, sum2); + return a + b + sum + sum1 + sum2; +} + +int +main (int argc, char **argv) +{ + int ret = cal (2, 1); + + if (ret != 11) + abort (); + + return 0; +} + +/* { dg-final { scan-rtl-dump "assign reg 29" "ira" } } */