From patchwork Wed Oct 1 22:34:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 395698 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 DCB0614016B for ; Thu, 2 Oct 2014 08:34:26 +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=kQ0F2dXBy0l6l3oBs0DwPR7dWGc+4gOSWrtInV/RfvryCm VSE8WDl1OPB12gmKyBBUKOm31F2E0W4LbtBYdT7T7wwnCCUXkUWxjdD3LlNVXxsN yy+Fo5DxbeValDjD4DNsMaCscoVb0/Q06vcOOQEOXeHjPkVToKm0sPyXSMOi4= 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=UNx2nlK22kWlUTDuCA56dvG7/Vw=; b=TLV7+MabIm9VnvDB98Mg y4yqNbFr3MQ+jEhNMbJ2cbOla1VO+1O29e1n0rN15f2un2JuVbavkRJrwC/44gkY IZabML+DW1dz1XWlLXTHNIS8EUh5OhwrE1BLLxxwCec8kpJ+iXGvhk0Pkv9YPwwF znISGIT9wiKvXZy+ymNb3aQ= Received: (qmail 28776 invoked by alias); 1 Oct 2014 22:34:20 -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 28765 invoked by uid 89); 1 Oct 2014 22:34:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS 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; Wed, 01 Oct 2014 22:34:18 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s91MYHYP022401 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 1 Oct 2014 18:34:17 -0400 Received: from stumpy.slc.redhat.com (ovpn-113-81.phx2.redhat.com [10.3.113.81]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s91MYHwZ027724 for ; Wed, 1 Oct 2014 18:34:17 -0400 Message-ID: <542C8168.4030409@redhat.com> Date: Wed, 01 Oct 2014 16:34:16 -0600 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: RFA: RTL typesafety improvements for ira.c X-IsSubscribed: yes This was inspired by a discussion with Felix who was making changes in this area. Basically this promotes the "init_insns" field within struct equivalence from an rtx to an rtx_insn_list. The only thing that's really interesting here is the old code exploits the fact that we could put any RTX in the list by shoving const0_rtx into the init_insns list as a marker to indicate we've already determined the relevant pseudo must not have an equivalence. Thus we could have the following objects in the init_insns field: NULL const0_rtx INSN_LIST ... This patch uses INSN_LIST (NULL_RTX, NULL) as the special marker. Thus the only two things that would exist in the init_insns field would be NULL or an INSN_LIST. Goodness. Rather than stash away the special marker INSN_LIST into a global variable or something similar, we instead to do a two step check for the marker. First verify that the insn_list field is non-NULL, then look at the first insn in the list and see if that is NULL. Bootstrapped and regression tested on i686-unknown-linux-gnu and x86_64-unknown-linux-gnu. Ok for the trunk? Jeff * ira.c (struct equivalence): Promote INIT_INSNs field to an rtx_insn_list. Add comments. (no_equiv): Promote LIST to an rtx_insn_list. Update testing for and creating the special marker. Use methods to extract the insn and next pointers. (update_equiv_regs): Update test for special marker in the INIT_INSNs list. diff --git a/gcc/ira.c b/gcc/ira.c index ad0e463..231cfc5 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -2890,8 +2890,16 @@ struct equivalence e.g. by reload. */ rtx replacement; rtx *src_p; - /* The list of each instruction which initializes this register. */ - rtx init_insns; + + /* The list of each instruction which initializes this register. + + NULL indicates we know nothing about this register's equivalence + properties. + + An INSN_LIST with a NULL insn indicates this pseudo is already + known to not have a valid equivalence. */ + rtx_insn_list *init_insns; + /* Loop depth is used to recognize equivalences which appear to be present within the same loop (or in an inner loop). */ int loop_depth; @@ -3242,15 +3250,15 @@ no_equiv (rtx reg, const_rtx store ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED) { int regno; - rtx list; + rtx_insn_list *list; if (!REG_P (reg)) return; regno = REGNO (reg); list = reg_equiv[regno].init_insns; - if (list == const0_rtx) + if (list && list->insn () == NULL) return; - reg_equiv[regno].init_insns = const0_rtx; + reg_equiv[regno].init_insns = gen_rtx_INSN_LIST (VOIDmode, NULL_RTX, NULL); reg_equiv[regno].replacement = NULL_RTX; /* This doesn't matter for equivalences made for argument registers, we should keep their initialization insns. */ @@ -3258,9 +3266,9 @@ no_equiv (rtx reg, const_rtx store ATTRIBUTE_UNUSED, return; ira_reg_equiv[regno].defined_p = false; ira_reg_equiv[regno].init_insns = NULL; - for (; list; list = XEXP (list, 1)) + for (; list; list = list->next ()) { - rtx insn = XEXP (list, 0); + rtx insn = list->insn (); remove_note (insn, find_reg_note (insn, REG_EQUIV, NULL_RTX)); } } @@ -3437,7 +3445,8 @@ update_equiv_regs (void) if (!REG_P (dest) || (regno = REGNO (dest)) < FIRST_PSEUDO_REGISTER - || reg_equiv[regno].init_insns == const0_rtx + || (reg_equiv[regno].init_insns + && reg_equiv[regno].init_insns->insn () == NULL) || (targetm.class_likely_spilled_p (reg_preferred_class (regno)) && MEM_P (src) && ! reg_equiv[regno].is_arg_equivalence)) { @@ -3608,8 +3617,8 @@ update_equiv_regs (void) && (regno = REGNO (src)) >= FIRST_PSEUDO_REGISTER && REG_BASIC_BLOCK (regno) >= NUM_FIXED_BLOCKS && DF_REG_DEF_COUNT (regno) == 1 - && reg_equiv[regno].init_insns != 0 - && reg_equiv[regno].init_insns != const0_rtx + && reg_equiv[regno].init_insns != NULL + && reg_equiv[regno].init_insns->insn () != NULL && ! find_reg_note (XEXP (reg_equiv[regno].init_insns, 0), REG_EQUIV, NULL_RTX) && ! contains_replace_regs (XEXP (dest, 0)) @@ -3728,7 +3737,7 @@ update_equiv_regs (void) delete_insn (equiv_insn); reg_equiv[regno].init_insns - = XEXP (reg_equiv[regno].init_insns, 1); + = reg_equiv[regno].init_insns->next (); ira_reg_equiv[regno].init_insns = NULL; bitmap_set_bit (cleared_regs, regno);