From patchwork Sun Jul 13 12:18:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 369401 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 108A5140170 for ; Sun, 13 Jul 2014 22:18:53 +1000 (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:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=q/OlqMgSzJk+0Jv5I /VmYIVRDc+VXfKKJE2kfPTwivPFUMVokmSMCLpcm/fAnmteeMnDNA8OoergNBsyV a5M5yR0XFKJs7fSSiGGCsMLhhmwwrA8pWXwDtcGHJvZbReqwJVptM6m1hXP8Z+Us UatJwU3dXml/k8YtwYRzv/0lqw= 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:cc:subject:references :in-reply-to:content-type; s=default; bh=cQnoskGT0dhJmyI1qmnPoVo xTgQ=; b=AZBlLb3NzJMMYWp8t7LEKIMd5O3q56mFEJWDYNwRQu67X/9SqUrfgx3 SBdUHP1Dk7Zex20u1/HiEWLkAAf9rPzIXOMWMHW5iOK6035TnF1zqasuhUv8UI4A ZiEIhdKxpKHZeyzsFoxRUGBcwwH4+mJqn+0OV9usQM+2+PTZNHEg= Received: (qmail 22436 invoked by alias); 13 Jul 2014 12:18:42 -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 22361 invoked by uid 89); 13 Jul 2014 12:18:41 -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 relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Jul 2014 12:18:37 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1X6Ijf-0005A1-UD from Tom_deVries@mentor.com ; Sun, 13 Jul 2014 05:18:31 -0700 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 13 Jul 2014 05:18:31 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.2.247.3; Sun, 13 Jul 2014 13:18:30 +0100 Message-ID: <53C27913.8010602@mentor.com> Date: Sun, 13 Jul 2014 14:18:27 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Richard Henderson CC: Jan Hubicka , Eric Botcazou , , Subject: Re: -fuse-caller-save - Collect register usage information References: <534ED7BC.50300@mentor.com> <878uqwgjoe.fsf@talisman.default> <535BABD1.8050208@mentor.com> <1426417.RtLpSRnsYv@polaris> <537A1583.7020702@mentor.com> <53A27162.7070208@redhat.com> <53A30A69.7060905@mentor.com> <53A30F3B.5000801@redhat.com> <20140619193606.GA32714@kam.mff.cuni.cz> <53A33DDF.5050508@redhat.com> In-Reply-To: <53A33DDF.5050508@redhat.com> On 19-06-14 21:45, Richard Henderson wrote: > On 06/19/2014 12:36 PM, Jan Hubicka wrote: >>> On 06/19/2014 09:06 AM, Tom de Vries wrote: >>>> >>>> 2014-06-19 Tom de Vries >>>> >>>> * final.c (collect_fn_hard_reg_usage): Don't save function_used_regs if >>>> it contains all call_used_regs. >>> >>> Ok. >> >> When we now have way to represent different reg usages for functions, what would be best >> way to make local functions to default into saving some SSE registers on x86/x86-64? > > I wouldn't do that at all. Leave all sse registers call-clobbered. This way > you don't need to have different entry points (or one possibly less efficient > entry point) when a function is used both locally and globally. > > What I would investigate is how to use this hard reg usage data in the register > allocator. If we know that the callee only uses xmm0-xmm4, then we can keep > xmm5-xmm15 live across the call. > AFAIU, what you describe here already works. This patch contains a version of the fuse-caller-save test with xmm registers. The callee bar only uses xmm0, and caller foo keeps xmm1 live across the call. OK for trunk? Thanks, - Tom 2014-07-13 Tom de Vries * gcc.target/i386/fuse-caller-save-xmm-run.c: New test. * gcc.target/i386/fuse-caller-save-xmm.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm-run.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm-run.c new file mode 100644 index 0000000..17385fa --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm-run.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -msse -fuse-caller-save" } */ + +typedef double v2df __attribute__((vector_size (16))); + +static v2df __attribute__((noinline)) +bar (v2df a) +{ + return a + (v2df){ 3.0, 3.0 }; +} + +v2df __attribute__((noinline)) +foo (v2df y) +{ + return y + bar (y); +} + +int +main (void) +{ + int success; + union { + v2df v; + double d[2]; + } u; + + u.v = foo ((v2df){ 5.0, 5.0}); + success = (u.d[0] == 13.0 + && u.d[1] == 13.0); + + return !success; +} + + diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c new file mode 100644 index 0000000..de1ca63 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse -fuse-caller-save" } */ + +typedef double v2df __attribute__((vector_size (16))); + +static v2df __attribute__((noinline)) +bar (v2df a) +{ + return a + (v2df){ 3.0, 3.0 }; +} + +v2df __attribute__((noinline)) +foo (v2df y) +{ + return y + bar (y); +} + +int +main (void) +{ + int success; + union { + v2df v; + double d[2]; + } u; + + u.v = foo ((v2df){ 5.0, 5.0}); + success = (u.d[0] == 13.0 + && u.d[1] == 13.0); + + return !success; +} + +/* { dg-final { scan-assembler-not "movaps\t%xmm1, \\(%rsp\\)" } } */ +/* { dg-final { scan-assembler-not "movapd\t\\(%rsp\\), %xmm1" } } */ +/* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 16" 1 } } */ +/* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 32" 1 } } */ +