From patchwork Sun Sep 16 10:52:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 184122 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]) by ozlabs.org (Postfix) with SMTP id B38902C0090 for ; Sun, 16 Sep 2012 20:53:10 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1348397592; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Mail-Followup-To:Cc:Subject:References:Date: In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=bdMngcJ/6MfidclKNJ9I jpPQsqU=; b=TNc4SNJlcNOVM6gf6aJnEdSgQvzB5KqPDU8v1C+8JvMJKXyER8Az h25PjZ2zSFrrVl+s6uTN9RKaYSGNHVuCsDQ5M27cCdbswPY1QdO9NnQhGeHjoXxB itl85Drllfquxo7LrLqBykRARuYYfuq6OOoK0U19iRd93TQd9zRMCiw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Mail-Followup-To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=SNG6AWdEz7a8HW9cm32CuCiLP3Gufz1jdp7725vUuXbgD4Hf+H7n3g2SSrXwj1 2fGMHbY24EVQzlX2/wSa03Na2sYDjv2SOD9jHXxDCBF8dCPzSmcbRJECXm50Mhuw 1BBdEC8AUyAgGQzaQZTKjTTsfsSVzUxeS8Nh4db8K5onc=; Received: (qmail 26429 invoked by alias); 16 Sep 2012 10:53:06 -0000 Received: (qmail 26420 invoked by uid 22791); 16 Sep 2012 10:53:05 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_BG X-Spam-Check-By: sourceware.org Received: from mail-wi0-f179.google.com (HELO mail-wi0-f179.google.com) (209.85.212.179) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 16 Sep 2012 10:52:52 +0000 Received: by wibhq4 with SMTP id hq4so1091414wib.8 for ; Sun, 16 Sep 2012 03:52:51 -0700 (PDT) Received: by 10.180.84.164 with SMTP id a4mr9316093wiz.12.1347792770940; Sun, 16 Sep 2012 03:52:50 -0700 (PDT) Received: from localhost ([2.26.188.227]) by mx.google.com with ESMTPS id hv8sm15440371wib.0.2012.09.16.03.52.47 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 16 Sep 2012 03:52:49 -0700 (PDT) From: Richard Sandiford To: Eric Botcazou Mail-Followup-To: Eric Botcazou , gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Cc: gcc-patches@gcc.gnu.org Subject: Re: Finish up PR rtl-optimization/44194 References: <201209121737.16110.ebotcazou@adacore.com> Date: Sun, 16 Sep 2012 11:52:56 +0100 In-Reply-To: <201209121737.16110.ebotcazou@adacore.com> (Eric Botcazou's message of "Wed, 12 Sep 2012 17:37:15 +0200") Message-ID: <87392i2q9j.fsf@talisman.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 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 Eric Botcazou writes: > This is the PR about the useless spilling to memory of structures that are > returned in registers. It was essentially addressed last year by Easwaran with > an enhancement of the RTL DSE pass, but Easwaran also noted that we still spill > to memory in the simplest cases, e.g. gcc.dg/pr44194-1.c, because expand_call > creates a temporary on the stack to store the value returned in registers... > > The attached patch solves this problem by copying the value into pseudos > instead by means of emit_group_move_into_temps. This is sufficient to get rid > of the remaining memory accesses for gcc.dg/pr44194-1.c on x86-64 for example, > but not on strict-alignment platforms like SPARC64. Thanks for doing this. It'll obviously help n32 and n64 long doubles too. I hit one problem building libgfortran for mips64-linux-gnu. The calls.c change was: Index: calls.c =================================================================== --- calls.c (revision 191198) +++ calls.c (working copy) @@ -3272,16 +3272,8 @@ expand_call (tree exp, rtx target, int i else if (GET_CODE (valreg) == PARALLEL) { if (target == 0) - { - /* This will only be assigned once, so it can be readonly. */ - tree nt = build_qualified_type (rettype, - (TYPE_QUALS (rettype) - | TYPE_QUAL_CONST)); - - target = assign_temp (nt, 1, 1); - } - - if (! rtx_equal_p (target, valreg)) + target = emit_group_move_into_temps (valreg); + else if (!rtx_equal_p (target, valreg)) emit_group_store (target, valreg, rettype, int_size_in_bytes (rettype)); /* We can not support sibling calls for this case. */ sibcall_failure = 1; But if we're trying to use a sibcall, we go through this loop twice, and the second iteration has to cope with a PARALLEL target created by the first. How about the patch below? Tested on mips64-linux-gnu, where a full testrun looked good. In some ways it's a bit silly to emit anything at all in the first iteration, given that we then go on to set sibcall_failure. It's not the kind of loop we can just continue out of though. Also, your patch probably means that we only need to set sibcall_failure for the emit_group_store case, although I've not tested that. Richard gcc/ * calls.c (expand_call): Use emit_group_move for PARALLEL->PARALLEL moves. Index: gcc/calls.c =================================================================== --- gcc/calls.c 2012-09-15 11:15:46.000000000 +0100 +++ gcc/calls.c 2012-09-15 11:15:46.522857695 +0100 @@ -3273,7 +3273,13 @@ expand_call (tree exp, rtx target, int i { if (target == 0) target = emit_group_move_into_temps (valreg); - else if (!rtx_equal_p (target, valreg)) + else if (rtx_equal_p (target, valreg)) + ; + else if (GET_CODE (target) == PARALLEL) + /* Handle the result of a emit_group_move_into_temps + call in the previous pass. */ + emit_group_move (target, valreg); + else emit_group_store (target, valreg, rettype, int_size_in_bytes (rettype));