From patchwork Fri Oct 21 12:30:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 685076 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 3t0lQJ62ydz9t17 for ; Fri, 21 Oct 2016 23:30:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=L/KT6civ; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=DyzZSN8GTMl64L45XRIQHbwnWsjbrDBVcy8NRicSQcpB+7bq5LBJO RW3JCX1Z4AoZ1Qq19xaRdR63f3D3S8SqiUBxQn9W9r+9VLOJl4kzzaLKqDsHDelF MG9kckHvGYZCF6gofFiYmSIQthZ8JIgDb5idpiBKOtlUc8lFcf4EoY= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=default; bh=Dbyu4ea6n0m//9NmoV305OJ17sw=; b=L/KT6civKX01JtEpcye8tPxZWPIM ogkL5f8Yp0gdHUjNCkrQGhdhTKqc6pka+xx41Y4ra2t9ftNJyRWBzn5vRdjp/7v4 p25mRdCctUP9sRx7O6ReQUSIPT/vcMJheR3n81ffo98CHKrTooWDBcpxFLfmRvCS XPsHHvWPnWNv5FY= Received: (qmail 57703 invoked by alias); 21 Oct 2016 12:30:38 -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 57682 invoked by uid 89); 21 Oct 2016 12:30:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 spammy=XINT, xint, INSN, alloc_reg_note 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 ESMTP; Fri, 21 Oct 2016 12:30:36 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 275448B13C; Fri, 21 Oct 2016 12:30:35 +0000 (UTC) Received: from localhost.localdomain (vpn1-4-137.ams2.redhat.com [10.36.4.137]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9LCUXDI009827; Fri, 21 Oct 2016 08:30:34 -0400 Subject: Re: [Patch, rtl] PR middle-end/78016, keep REG_NOTE order during insn copy To: Jiong Wang , Eric Botcazou References: <1f9dd2ba-6a92-3afc-a6fb-d4be914ab239@foss.arm.com> <884b9f0d-ff3f-d214-369f-5d5631695c87@redhat.com> <70337315.mGifSNztka@polaris> <136c0e15-0545-1190-f76a-7e2865d269a5@foss.arm.com> Cc: gcc-patches@gcc.gnu.org From: Bernd Schmidt Message-ID: Date: Fri, 21 Oct 2016 14:30:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <136c0e15-0545-1190-f76a-7e2865d269a5@foss.arm.com> X-IsSubscribed: yes On 10/21/2016 02:04 PM, Jiong Wang wrote: > + /* Locate the end of existing REG_NOTES in NEW_RTX. */ > + rtx *ptail = ®_NOTES (new_rtx); > + while (*ptail != NULL_RTX) > + ptail = &XEXP (*ptail, 1); I was thinking along the lines of something like this (untested, emit-rtl.c part omitted). Eric can choose whether he likes either of these or wants something else. Bernd Index: gcc/rtl.h =================================================================== --- gcc/rtl.h (revision 241233) +++ gcc/rtl.h (working copy) @@ -3008,6 +3008,7 @@ extern rtx alloc_reg_note (enum reg_note extern void add_reg_note (rtx, enum reg_note, rtx); extern void add_int_reg_note (rtx, enum reg_note, int); extern void add_shallow_copy_of_reg_note (rtx_insn *, rtx); +extern rtx duplicate_reg_note (rtx_insn *, rtx); extern void remove_note (rtx, const_rtx); extern void remove_reg_equal_equiv_notes (rtx_insn *); extern void remove_reg_equal_equiv_notes_for_regno (unsigned int); Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c (revision 241233) +++ gcc/rtlanal.c (working copy) @@ -2304,6 +2304,21 @@ add_shallow_copy_of_reg_note (rtx_insn * add_reg_note (insn, REG_NOTE_KIND (note), XEXP (note, 0)); } +/* Duplicate NOTE and return the copy. */ +rtx +duplicate_reg_note (rtx note) +{ + rtx n; + reg_note_kind kind = REG_NOTE_KIND (note); + + if (GET_CODE (note) == INT_LIST) + return gen_rtx_INT_LIST ((machine_mode) kind, XINT (note, 0), NULL_RTX); + else if (GET_CODE (note) == EXPR_LIST) + return alloc_reg_note (kind, copy_insn_1 (XEXP (note, 0)), NULL_RTX); + else + return alloc_reg_note (kind, XEXP (note, 0), NULL_RTX); +} + /* Remove register note NOTE from the REG_NOTES of INSN. */ void Index: gcc/sel-sched-ir.c =================================================================== --- gcc/sel-sched-ir.c (revision 241233) +++ gcc/sel-sched-ir.c (working copy) @@ -5762,6 +5762,11 @@ create_copy_of_insn_rtx (rtx insn_rtx) res = create_insn_rtx_from_pattern (copy_rtx (PATTERN (insn_rtx)), NULL_RTX); + /* Locate the end of existing REG_NOTES in NEW_RTX. */ + rtx *ptail = ®_NOTES (new_rtx); + while (*ptail != NULL_RTX) + ptail = &XEXP (*ptail, 1); + /* Copy all REG_NOTES except REG_EQUAL/REG_EQUIV and REG_LABEL_OPERAND since mark_jump_label will make them. REG_LABEL_TARGETs are created there too, but are supposed to be sticky, so we copy them. */ @@ -5770,11 +5775,8 @@ create_copy_of_insn_rtx (rtx insn_rtx) && REG_NOTE_KIND (link) != REG_EQUAL && REG_NOTE_KIND (link) != REG_EQUIV) { - if (GET_CODE (link) == EXPR_LIST) - add_reg_note (res, REG_NOTE_KIND (link), - copy_insn_1 (XEXP (link, 0))); - else - add_reg_note (res, REG_NOTE_KIND (link), XEXP (link, 0)); + *ptail = duplicate_reg_note (link); + ptail = &XEXP (*ptail, 1); } return res;