From patchwork Thu Dec 18 20:52:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 422656 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 C895F140082 for ; Fri, 19 Dec 2014 07:52:14 +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:subject:content-type; q= dns; s=default; b=vPMnjjSmJqyeBxS76OUvudOCW5/Yl+Yzf3tS0C0pHb4seL yhutudhp0yn2RzrR7tz+fVZGxK+WxoqmJIdu6JEeQZV43CMZUA/LBSXiNvlKi3eu 3fpuqQRX5goZobFf8j84B4qnQI4ugNaWyImumOE5S4c22R54P9BZgLohyLNHY= 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=ZtRQf/W84GkqxeVDg3F3E5LxPxc=; b=I8fj5YEbMCr/XOKV3qat ZkQxPKSeeZcSM1dnKUOmwatBaZwK+NaA22dfqf2+PWOhV5j5yvtVb+HQdj3e0sN2 dVj3qQjYybWoGq4hqRaH3UidUe39ik9Z5+Qk8o461aC8YFDWMHtzKjYU6X1gB5nB Rx/aIj5Cuac2PiaRQtyeBsc= Received: (qmail 11100 invoked by alias); 18 Dec 2014 20:52:07 -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 11089 invoked by uid 89); 18 Dec 2014 20:52:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 18 Dec 2014 20:52:05 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBIKq3dH014685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 18 Dec 2014 15:52:04 -0500 Received: from VMBP.local (vpn-58-85.rdu2.redhat.com [10.10.58.85]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBIKq2MD017918 for ; Thu, 18 Dec 2014 15:52:02 -0500 Message-ID: <54933E72.6070702@redhat.com> Date: Thu, 18 Dec 2014 15:52:02 -0500 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: GCC Patches Subject: patch to solve PR64291 X-IsSubscribed: yes The following patch solves https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64291 It is a bug in a new rematerialization subpass of LRA. The patch was bootstrapped on x86/x86-64. Committed as rev. 218874. 2014-12-18 Vladimir Makarov PR rtl-optimization/64291 * lra-remat.c (bad_for_rematerialization_p): Add UNPSEC_VLOATILE. (create_cands): Process only output reload insn with potential cands. 2014-12-18 Vladimir Makarov PR rtl-optimization/64291 * testsuite/gcc.target/i386/pr64291-[12].c: New tests. Index: lra-remat.c =================================================================== --- lra-remat.c (revision 218685) +++ lra-remat.c (working copy) @@ -350,12 +350,12 @@ finish_cand_table (void) -/* Return true if X contains memory or UNSPEC. We can not just check - insn operands as memory or unspec might be not an operand itself - but contain an operand. Insn with memory access is not profitable - for rematerialization. Rematerialization of UNSPEC might result in - wrong code generation as the UNPEC effect is unknown - (e.g. generating a label). */ +/* Return true if X contains memory or some UNSPEC. We can not just + check insn operands as memory or unspec might be not an operand + itself but contain an operand. Insn with memory access is not + profitable for rematerialization. Rematerialization of UNSPEC + might result in wrong code generation as the UNPEC effect is + unknown (e.g. generating a label). */ static bool bad_for_rematerialization_p (rtx x) { @@ -363,7 +363,7 @@ bad_for_rematerialization_p (rtx x) const char *fmt; enum rtx_code code; - if (MEM_P (x) || GET_CODE (x) == UNSPEC) + if (MEM_P (x) || GET_CODE (x) == UNSPEC || GET_CODE (x) == UNSPEC_VOLATILE) return true; code = GET_CODE (x); fmt = GET_RTX_FORMAT (code); @@ -406,7 +406,7 @@ operand_to_remat (rtx_insn *insn) if (reg->regno == STACK_POINTER_REGNUM && frame_pointer_needed) return -1; else if (reg->type == OP_OUT && ! reg->subreg_p - && find_regno_note (insn, REG_UNUSED, reg->regno) == NULL) + && find_regno_note (insn, REG_UNUSED, reg->regno) == NULL) { /* We permits only one spilled reg. */ if (found_reg != NULL) @@ -508,11 +508,14 @@ create_cands (void) if ((set = single_set (insn)) != NULL && REG_P (SET_SRC (set)) && REG_P (SET_DEST (set)) - && (src_regno = REGNO (SET_SRC (set))) >= FIRST_PSEUDO_REGISTER + && ((src_regno = REGNO (SET_SRC (set))) + >= lra_constraint_new_regno_start) && (dst_regno = REGNO (SET_DEST (set))) >= FIRST_PSEUDO_REGISTER && reg_renumber[dst_regno] < 0 && (insn2 = regno_potential_cand[src_regno].insn) != NULL && BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)) + /* It is an output reload insn after insn can be + rematerialized (potential candidate). */ create_cand (insn2, regno_potential_cand[src_regno].nop, dst_regno); if (nop < 0) goto fail; Index: testsuite/gcc.target/i386/pr64291-1.c =================================================================== --- testsuite/gcc.target/i386/pr64291-1.c (revision 0) +++ testsuite/gcc.target/i386/pr64291-1.c (working copy) @@ -0,0 +1,51 @@ +/* { dg-options "-O2" } */ +/* { dg-additional-sources pr64291-2.c } */ +/* { dg-do run } */ +void f(void*,...); +void g(void*,long,long); +int nnn=0; +long test=0; + +typedef struct +{ + int _mp_size; + unsigned long *_mp_d; +} __mpz_struct; +typedef __mpz_struct mpz_t[1]; + +int main () +{ + mpz_t n, d; + long nn, dn; + unsigned long *np, *dup, *dnp, *qp; + long alloc, itch; + + f (n); + f (d); + qp = (unsigned long*)__builtin_alloca(4099*8) + 1; + dnp = (unsigned long*)__builtin_alloca (2049*8); + alloc = 1; + for (test = 0; test < 1; test++) + { + dn = d->_mp_size; + dup = d->_mp_d; + f (dnp, dup, dn); + dnp[dn - 1] |= 1UL<<63; + f (0); + nn = nnn; + np = n->_mp_d; + qp[-1] = -757136820; + qp[nn - dn + 1] = 14883681; + f (0); + if (dn >= 6) + f (0); + itch = nn + 1; + if (itch + 1> alloc) + { + g(0,alloc*8,(itch+1)*8); + alloc = itch + 1; + } + f (np, nn); + } + return 0; +} Index: testsuite/gcc.target/i386/pr64291-2.c =================================================================== --- testsuite/gcc.target/i386/pr64291-2.c (revision 0) +++ testsuite/gcc.target/i386/pr64291-2.c (working copy) @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +extern void abort (void); +void f(void*p,...){} +void g(void*p,long a,long b){if (a!=8) abort();}