From patchwork Wed Jun 19 17:39:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 252631 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BB5E12C00B1 for ; Thu, 20 Jun 2013 03:39:23 +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:subject:content-type; q= dns; s=default; b=ZaR+oWLxr9M9PxfX8uY66QZu4G9qkCtIsVad9t9kXmqk+L gyuljooPJmqoRurDQNaxZ/Qui4nOVXh9+0qj/RlsUA6auJuWuYUFGM5ynWAmcPId LNEw+4M07MfPRAreuk4sINEkXPPsqzxVUdSVQ8e1pDXd+v3uB0H0/ChOepHZ8= 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:content-type; s= default; bh=E5LcVHhSlj9nhngAOvBxB4RU+zs=; b=iZQvmczW03Jz+0rT2YdH UG4Go82+uie6ILGYxYqPPILibqsZJI7oXWaFp9L29UelxLU+av2hzXr4J6pNyEVG 99hJ3QnXZr222xjXRkqr0w+JYFm67f0Pa2Csnle03fQoAzFi5xpJObcECOfw7b/6 FCI038aNFRfLgWQ7VfmgC6w= Received: (qmail 547 invoked by alias); 19 Jun 2013 17:39:17 -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 534 invoked by uid 89); 19 Jun 2013 17:39:16 -0000 X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 19 Jun 2013 17:39:15 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UpMLh-0006Ul-8w from Bernd_Schmidt@mentor.com for gcc-patches@gcc.gnu.org; Wed, 19 Jun 2013 10:39:13 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 19 Jun 2013 10:39:12 -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.2.247.3; Wed, 19 Jun 2013 18:39:10 +0100 Message-ID: <51C1ECB7.5030804@codesourcery.com> Date: Wed, 19 Jun 2013 19:39:03 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130522 Thunderbird/17.0.6 MIME-Version: 1.0 To: GCC Patches Subject: CALL_INSN_FUNCTION_USAGE fix, PR52773 X-Virus-Found: No This is bug that triggers on m68k. The loop unroller creates a MULT expression and tries to force it into a register, which causes a libcall to be generated. Since args are pushed we create a (use (mem (plus virtual_outgoing_args scratch))) in CALL_INSN_FUNCTION_USAGE. Since we're past vregs, the virtual_outgoing_args rtx survives to reload, which blows up. Fixed by just using stack_pointer_rtx, since we use a scratch anyway rather than a known offset. I also noticed that we actually add two of these USEs, so I've fixed that as well. Bootstrapped and tested on x86_64-linux, ok? Bernd diff --git a/gcc/calls.c b/gcc/calls.c index cdab8e0..db38b73 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -3603,6 +3603,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, int reg_parm_stack_space = 0; int needed; rtx before_call; + bool have_push_fusage; tree tfom; /* type_for_mode (outmode, 0) */ #ifdef REG_PARM_STACK_SPACE @@ -3956,6 +3957,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, /* Push the args that need to be pushed. */ + have_push_fusage = false; + /* ARGNUM indexes the ARGVEC array in the order in which the arguments are to be pushed. */ for (count = 0; count < nargs; count++, argnum += inc) @@ -4046,14 +4049,19 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, if (argblock) use = plus_constant (Pmode, argblock, argvec[argnum].locate.offset.constant); + else if (have_push_fusage) + continue; else - /* When arguments are pushed, trying to tell alias.c where - exactly this argument is won't work, because the - auto-increment causes confusion. So we merely indicate - that we access something with a known mode somewhere on - the stack. */ - use = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx, - gen_rtx_SCRATCH (Pmode)); + { + /* When arguments are pushed, trying to tell alias.c where + exactly this argument is won't work, because the + auto-increment causes confusion. So we merely indicate + that we access something with a known mode somewhere on + the stack. */ + use = gen_rtx_PLUS (Pmode, stack_pointer_rtx, + gen_rtx_SCRATCH (Pmode)); + have_push_fusage = true; + } use = gen_rtx_MEM (argvec[argnum].mode, use); use = gen_rtx_USE (VOIDmode, use); call_fusage = gen_rtx_EXPR_LIST (VOIDmode, use, call_fusage); diff --git a/gcc/testsuite/gcc.c-torture/compile/pr52773.c b/gcc/testsuite/gcc.c-torture/compile/pr52773.c new file mode 100644 index 0000000..8daa5ee --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr52773.c @@ -0,0 +1,16 @@ +/* pr52773.c */ + +struct s { + short x; + short _pad[2]; +}; + +static short mat_a_x; + +void transform(const struct s *src, struct s *dst, int n) +{ + int i; + + for (i = 0; i < n; ++i) + dst[i].x = (src[i].x * mat_a_x) >> 6; +}