From patchwork Fri Dec 6 00:34:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 297498 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5F0D72C009D for ; Fri, 6 Dec 2013 11:34:59 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=QKefE0YBYTrmAWOac 5W08a7QHQl1NTAn+pZfxUSrJpSnN0RthZsBc6NWc4mGZMKRcb9dhxJHiceVgS6+a jdPJ0b/Q3w3wW/Dma3XXfUdavK3rpXw09niGBhu+B78kpLvnSiHbeXtRHPdIIpHw AsM1DTABuS6mLwrDjBL032DeoI= 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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=NprPjyMJoy9TBcyO8G74HWi ZPdw=; b=ukG04Z63PfsvWPOE8Tx8h/fkQOAVI8IqcmEjGL4FQHBo5LkwuvBoSmQ Dfl+buGMLfpuR3HqA2WUCRYHnUJMvsRStdL6mLmCbL1aWkcEMAeXeyvPsvC1MDbg 20h84ROdvgBYwB5s2PFgh/RnaUTQES5GXBt6n3gT0NOBwZDNda2I= Received: (qmail 6669 invoked by alias); 6 Dec 2013 00:34:51 -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 6658 invoked by uid 89); 6 Dec 2013 00:34:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Dec 2013 00:34:48 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VojNI-0006Em-QM from Tom_deVries@mentor.com ; Thu, 05 Dec 2013 16:34:32 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 5 Dec 2013 16:34:32 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Fri, 6 Dec 2013 00:34:30 +0000 Message-ID: <52A11B94.8000000@mentor.com> Date: Fri, 6 Dec 2013 01:34:28 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Tom de Vries , gcc-patches , Subject: Re: [PATCH][10/10] -fuse-caller-save - Add test-case References: <20130330171215.890B6421213@build1-lucid-cs> <87r4hwgun0.fsf@talisman.default> In-Reply-To: <87r4hwgun0.fsf@talisman.default> On 27-04-13 12:01, Richard Sandiford wrote: > Tom de Vries writes: >> +/* { dg-do run } */ >> +/* { dg-options "-fuse-caller-save -save-temps" } */ >> +/* { dg-skip-if "" { *-*-* } { "*" } { "-Os" } } */ >> +/* Testing -fuse-caller-save optimization option. */ >> + >> +static int __attribute__((noinline)) >> +bar (int x) >> +{ >> + return x + 3; >> +} >> + >> +int __attribute__((noinline)) >> +foo (int y) >> +{ >> + return y + bar (y); >> +} >> + >> +int >> +main (void) >> +{ >> + return !(foo (5) == 13); >> +} >> + >> +/* Check that there are only 2 stack-saves: r31 in main and foo. */ >> + >> +/* Variant not mips16. Check that there only 2 sw/sd. */ >> +/* { dg-final { scan-assembler-times "(?n)s\[wd\]\t\\\$.*,.*\\(\\\$sp\\)" 2 { target { ! mips16 } } } } */ >> + >> +/* Variant not mips16, Subvariant micromips. Additionally check there's no >> + swm. */ >> +/* { dg-final { scan-assembler-times "(?n)swm\t\\\$.*,.*\\(\\\$sp\\)" 0 {target micromips } } } */ >> + >> +/* Variant mips16. The save can save 1 or more registers, check that only 1 is >> + saved, twice in total. */ >> +/* { dg-final { scan-assembler-times "(?n)save\t\[0-9\]*,\\\$\[^,\]*\$" 2 { target mips16 } } } */ >> + >> +/* Check that the first caller-save register is unused. */ >> +/* { dg-final { scan-assembler-not "(\\\$16)" } } */ > > Sorry to ask, but I think it would be better to split this up into > a compile test and a run test. The run test shouldn't be skipped at -Os. > It should probably also go somewhere more general than gcc.target/mips. > Richard, Done. There's now run test gcc.dg/fuse-caller-save.c and compile test gcc.target/mips/fuse-caller-save.c. > I've tried to avoid conditional scan-assemblers in gcc.target/mips > whereever possible. The directory has been set up so that you can force > any subtarget you like, so that (for example) -mips16 output is tested > by every run, not just things like mips-sim/-mips16. > > In this case I think that means using NOCOMPRESSION to force the > functions to use the standard ISA encoding and making the scan-assemblers > test only for that. Done. > Since you've already done the work :-), bonus points > for creating two copies, one for micromips (dg-options "-micromips ...") > and one for mips16 (dg-options "-mips16 ..."). That's certainly not a > requirement though. > I've left that out for now. OK for stage1? Thanks, - Tom > Thanks, > Richard > 2013-12-04 Radovan Obradovic Tom de Vries * gcc.target/mips/mips.exp: Add use-caller-save to -ffoo/-fno-foo options. * gcc.dg/fuse-caller-save.c: New test. * gcc.target/mips/fuse-caller-save.c: Same. diff --git a/gcc/testsuite/gcc.dg/fuse-caller-save.c b/gcc/testsuite/gcc.dg/fuse-caller-save.c new file mode 100644 index 0000000..561a66d --- /dev/null +++ b/gcc/testsuite/gcc.dg/fuse-caller-save.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-fuse-caller-save" } */ +/* Testing -fuse-caller-save optimization option. */ + +static int __attribute__((noinline)) +bar (int x) +{ + return x + 3; +} + +int __attribute__((noinline)) +foo (int y) +{ + return y + bar (y); +} + +int +main (void) +{ + return !(foo (5) == 13); +} diff --git a/gcc/testsuite/gcc.target/mips/fuse-caller-save.c b/gcc/testsuite/gcc.target/mips/fuse-caller-save.c new file mode 100644 index 0000000..212ca45 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/fuse-caller-save.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-fuse-caller-save" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-Os" } } */ +/* Testing -fuse-caller-save optimization option. */ + +static int __attribute__((noinline)) NOCOMPRESSION +bar (int x) +{ + return x + 3; +} + +int __attribute__((noinline)) NOCOMPRESSION +foo (int y) +{ + return y + bar (y); +} + +int NOCOMPRESSION +main (void) +{ + return !(foo (5) == 13); +} + +/* Check that there are only 2 stack-saves: r31 in main and foo. */ + +/* Check that there only 2 sw/sd. */ +/* { dg-final { scan-assembler-times "(?n)s\[wd\]\t\\\$.*,.*\\(\\\$sp\\)" 2 } } */ + +/* Check that the first caller-save register is unused. */ +/* { dg-final { scan-assembler-not "(\\\$16)" } } */ diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp index 1f0d0d6..5bfadec 100644 --- a/gcc/testsuite/gcc.target/mips/mips.exp +++ b/gcc/testsuite/gcc.target/mips/mips.exp @@ -305,6 +305,7 @@ foreach option { tree-vectorize unroll-all-loops unroll-loops + use-caller-save } { lappend mips_option_groups $option "-f(no-|)$option" }