From patchwork Thu Apr 23 19:08:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 464030 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 D87841400DE for ; Fri, 24 Apr 2015 05:08:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=urr2jTXo; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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=JoFFez0NQ9zZbboie3kLiCBQzYXH/Jm2qLflrF5+GWTo49 mDBzA7uQkzgoEi0YfC0jAaYO5d44JF6+6BJoBG25FB29THTQtkmGqihBw2C1as5g WqnBPAUx3bScCfrxA5q34Jz9uiA2VKOlPzaZ1+EUFyUHGCavNVRpMdDZpYMnI= 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=bCcFbY9nUr1BhuLwTXhPqGDqxfo=; b=urr2jTXozdLA5Q36Cb6m M02KOX3GOwmygk/HcPDJ7uSJ2wtqUZM0sS/uO4E+SOi33fHJFJK87ytoLOBIPvRU 8VAcOQSwrPbzyB21QXde7hXpPfqETCqOtD+R/bDtPSsTvRbHKXOtqK76WQi92z2Z dk3kPXKGPFRvbGf2FpOvnxI= Received: (qmail 41142 invoked by alias); 23 Apr 2015 19:08:35 -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 41073 invoked by uid 89); 23 Apr 2015 19:08:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no 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, 23 Apr 2015 19:08:33 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E00C38EB2B for ; Thu, 23 Apr 2015 19:08:31 +0000 (UTC) Received: from topor.usersys.redhat.com (unused-10-15-17-214.yyz.redhat.com [10.15.17.214]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3NJ8V7N018566 for ; Thu, 23 Apr 2015 15:08:31 -0400 Message-ID: <5539432F.9050400@redhat.com> Date: Thu, 23 Apr 2015 15:08:31 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gcc-patches Subject: patch for PR65805 was backported to gcc-5 branch X-IsSubscribed: yes The following patch was backported to gcc-5 branch. The patch was bootstrapped on x86-64. Committed as rev. 222383. 2015-04-23 Vladimir Makarov Backport from trunk r222223. 2015-04-19 Vladimir Makarov PR rtl-optimization/65805 * lra-eliminations.c (lra_eliminate_regs_1): Add new assert. Don't use difference of offset and previous offset if update_sp_offset is non-zero. (eliminate_regs_in_insn): Ditto. * lra-spills.c (remove_pseudos): Exchange 4th and 6th args in lra_eliminate_regs_1 call. * lra-constraints.c (get_equiv_with_elimination): Ditto. Index: lra-eliminations.c =================================================================== --- lra-eliminations.c (revision 222220) +++ lra-eliminations.c (working copy) @@ -318,7 +318,9 @@ get_elimination (rtx reg) substitution if UPDATE_P, or the full offset if FULL_P, or otherwise zero. If FULL_P, we also use the SP offsets for elimination to SP. If UPDATE_P, use UPDATE_SP_OFFSET for updating - offsets of register elimnable to SP. + offsets of register elimnable to SP. If UPDATE_SP_OFFSET is + non-zero, don't use difference of the offset and the previous + offset. MEM_MODE is the mode of an enclosing MEM. We need this to know how much to adjust a register for, e.g., PRE_DEC. Also, if we are @@ -341,7 +343,8 @@ lra_eliminate_regs_1 (rtx_insn *insn, rt const char *fmt; int copied = 0; - gcc_assert (!update_p || !full_p); + lra_assert (!update_p || !full_p); + lra_assert (update_sp_offset == 0 || (!subst_p && update_p && !full_p)); if (! current_function_decl) return x; @@ -366,11 +369,14 @@ lra_eliminate_regs_1 (rtx_insn *insn, rt { rtx to = subst_p ? ep->to_rtx : ep->from_rtx; - if (update_p) - return plus_constant (Pmode, to, - ep->offset - ep->previous_offset - + (ep->to_rtx == stack_pointer_rtx - ? update_sp_offset : 0)); + if (update_sp_offset != 0) + { + if (ep->to_rtx == stack_pointer_rtx) + return plus_constant (Pmode, to, update_sp_offset); + return to; + } + else if (update_p) + return plus_constant (Pmode, to, ep->offset - ep->previous_offset); else if (full_p) return plus_constant (Pmode, to, ep->offset @@ -395,16 +401,15 @@ lra_eliminate_regs_1 (rtx_insn *insn, rt if (! update_p && ! full_p) return gen_rtx_PLUS (Pmode, to, XEXP (x, 1)); - - offset = (update_p - ? ep->offset - ep->previous_offset - + (ep->to_rtx == stack_pointer_rtx - ? update_sp_offset : 0) - : ep->offset); + + if (update_sp_offset != 0) + offset = ep->to_rtx == stack_pointer_rtx ? update_sp_offset : 0; + else + offset = (update_p + ? ep->offset - ep->previous_offset : ep->offset); if (full_p && insn != NULL_RTX && ep->to_rtx == stack_pointer_rtx) offset -= lra_get_insn_recog_data (insn)->sp_offset; - if (CONST_INT_P (XEXP (x, 1)) - && INTVAL (XEXP (x, 1)) == -offset) + if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) == -offset) return to; else return gen_rtx_PLUS (Pmode, to, @@ -451,12 +456,18 @@ lra_eliminate_regs_1 (rtx_insn *insn, rt { rtx to = subst_p ? ep->to_rtx : ep->from_rtx; - if (update_p) + if (update_sp_offset != 0) + { + if (ep->to_rtx == stack_pointer_rtx) + return plus_constant (Pmode, + gen_rtx_MULT (Pmode, to, XEXP (x, 1)), + update_sp_offset * INTVAL (XEXP (x, 1))); + return gen_rtx_MULT (Pmode, to, XEXP (x, 1)); + } + else if (update_p) return plus_constant (Pmode, gen_rtx_MULT (Pmode, to, XEXP (x, 1)), - (ep->offset - ep->previous_offset - + (ep->to_rtx == stack_pointer_rtx - ? update_sp_offset : 0)) + (ep->offset - ep->previous_offset) * INTVAL (XEXP (x, 1))); else if (full_p) { @@ -889,11 +900,12 @@ remove_reg_equal_offset_note (rtx insn, If REPLACE_P is false, just update the offsets while keeping the base register the same. If FIRST_P, use the sp offset for - elimination to sp. Otherwise, use UPDATE_SP_OFFSET for this. - Attach the note about used elimination for insns setting frame - pointer to update elimination easy (without parsing already - generated elimination insns to find offset previously used) in - future. */ + elimination to sp. Otherwise, use UPDATE_SP_OFFSET for this. If + UPDATE_SP_OFFSET is non-zero, don't use difference of the offset + and the previous offset. Attach the note about used elimination + for insns setting frame pointer to update elimination easy (without + parsing already generated elimination insns to find offset + previously used) in future. */ void eliminate_regs_in_insn (rtx_insn *insn, bool replace_p, bool first_p, @@ -940,6 +952,10 @@ eliminate_regs_in_insn (rtx_insn *insn, rtx src = SET_SRC (old_set); rtx off = remove_reg_equal_offset_note (insn, ep->to_rtx); + /* We should never process such insn with non-zero + UPDATE_SP_OFFSET. */ + lra_assert (update_sp_offset == 0); + if (off != NULL_RTX || src == ep->to_rtx || (GET_CODE (src) == PLUS @@ -1026,7 +1042,8 @@ eliminate_regs_in_insn (rtx_insn *insn, if (! replace_p) { - offset += (ep->offset - ep->previous_offset); + if (update_sp_offset == 0) + offset += (ep->offset - ep->previous_offset); if (ep->to_rtx == stack_pointer_rtx) { if (first_p) Index: lra-spills.c =================================================================== --- lra-spills.c (revision 222220) +++ lra-spills.c (working copy) @@ -461,7 +461,7 @@ remove_pseudos (rtx *loc, rtx_insn *insn { rtx x = lra_eliminate_regs_1 (insn, pseudo_slots[i].mem, GET_MODE (pseudo_slots[i].mem), - 0, false, false, true); + false, false, 0, true); *loc = x != pseudo_slots[i].mem ? x : copy_rtx (x); } return; Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 222220) +++ lra-constraints.c (working copy) @@ -533,7 +533,7 @@ get_equiv_with_elimination (rtx x, rtx_i if (x == res || CONSTANT_P (res)) return res; return lra_eliminate_regs_1 (insn, res, GET_MODE (res), - 0, false, false, true); + false, false, 0, true); } /* Set up curr_operand_mode. */