From patchwork Thu Oct 16 09:14:15 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: 400239 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 BF9981400B8 for ; Thu, 16 Oct 2014 20:14:32 +1100 (AEDT) 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:content-type; q=dns; s=default; b=Toov9r64H/N58PGVAtx9AkyujWl3XplhVEHjlJrabaJ GBL6EGhEybBD2EqZT3uAN5XG3uJyjP4eYscj9sIJcK6f8Bu4XPlIbypRE62yoZ8T l++Q0awq3TZIEi8OzBIQFJ0p6+IQ8AnXAQPW/FYf4tMG2udEnR26T7UeJ1QNbrYU = 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:content-type; s=default; bh=q+N60A4iqwUUX0ToyEgIow/47/M=; b=qrWpxu1hOb+1rsL6G CCywz/9f8krokVcx0gqAvOGuL1AjYLtVQDxGqTl2nJSemiPtTT8l2FI3CtNZ6q7K 4T/0DC/lclZZBeVdhc2BD1nBvI7/hQqh2IB5yD85Dc9q/9HR8sEbEMz1f7BEXcNH 3pkyIMYzgY6V0Ddq1l+RRYfGC4= Received: (qmail 5344 invoked by alias); 16 Oct 2014 09:14:25 -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 5323 invoked by uid 89); 16 Oct 2014 09:14:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 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; Thu, 16 Oct 2014 09:14:22 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Xeh8V-0006GA-GP from Tom_deVries@mentor.com ; Thu, 16 Oct 2014 02:14:19 -0700 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.3.181.6; Thu, 16 Oct 2014 10:14:16 +0100 Message-ID: <543F8C67.3020402@mentor.com> Date: Thu, 16 Oct 2014 11:14:15 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: Eric Botcazou CC: GCC Patches Subject: [PATCH, PR61605, 2/2] Use fuse-caller-save info in pass_cprop_hardreg Eric, this patch is the second half of the fix for PR61605. It make sure in pass_cprop_hardreg that, if available we use the call-specific information provided by fuse-caller-save, rather than the generic regs_invalidated_by_call info. The 2 patches together allow an insn to removed from the gcc.target/i386/fuse-caller-save.c testcase, which is updated accordingly in this patch. Bootstrapped and reg-tested on x86_64. OK for trunk? Thanks, - Tom 2014-10-13 Tom de Vries PR rtl-optimization/61605 * regcprop.c (copyprop_hardreg_forward_1): Use regs_invalidated_by_this_call instead of regs_invalidated_by_call. * gcc.target/i386/fuse-caller-save.c: Update addition check. Add movl absence check. diff --git a/gcc/regcprop.c b/gcc/regcprop.c index c71de98..304820f 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -1000,6 +1000,7 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) unsigned int set_nregs = 0; unsigned int regno; rtx exp; + HARD_REG_SET regs_invalidated_by_this_call; for (exp = CALL_INSN_FUNCTION_USAGE (insn); exp; exp = XEXP (exp, 1)) { @@ -1018,8 +1019,11 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) } } + get_call_reg_set_usage (insn, + ®s_invalidated_by_this_call, + regs_invalidated_by_call); for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) - if ((TEST_HARD_REG_BIT (regs_invalidated_by_call, regno) + if ((TEST_HARD_REG_BIT (regs_invalidated_by_this_call, regno) || HARD_REGNO_CALL_PART_CLOBBERED (regno, vd->e[regno].mode)) && (regno < set_regno || regno >= set_regno + set_nregs)) kill_value_regno (regno, 1, vd); diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c index 7e2b11d..a6e8f1c 100644 --- a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c +++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c @@ -20,5 +20,13 @@ foo (int y) /* { dg-final { scan-assembler-not "push" } } */ /* { dg-final { scan-assembler-not "pop" } } */ -/* Check that addition uses dx. */ -/* { dg-final { scan-assembler-times "addl\t%\[re\]?dx, %\[re\]?ax" 1 } } */ +/* PR61605. If the first argument register and the return register differ, then + bar leaves the first argument register intact. That means in foo that the + first argument register still contains y after bar has been called, and + there's no need to copy y to a different register before the call, to be able + to use it after the call. + Check that the copy is absent. */ +/* { dg-final { scan-assembler-not "movl" { target { ! ia32 } } } } */ + +/* Check that addition uses di (in case of no copy) or dx (in case of copy). */ +/* { dg-final { scan-assembler-times "addl\t%\[re\]?d\[ix\], %\[re\]?ax" 1 } } */ -- 1.9.1