From patchwork Mon Oct 15 17:39:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 191614 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]) by ozlabs.org (Postfix) with SMTP id 69DA82C00A8 for ; Tue, 16 Oct 2012 04:39:20 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1350927561; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=tJkm+Pl JZ/5RnB7/t1/cWyjsSMY=; b=EzfeSEjOmmXuWXmJFa5fcp/X5cRDwrlyscfGWVm hKNvtdo1ZEl7CCjCR3Rk+vHLe/bVJ3oPcbZX5B7H2wlwTzvEXo7Ke0oC2eKf/4Jd k+IF4fj3HCsmzl0shhHRs9ikSQ1Bk4V9d2RsQZnJS60l8cRvZMHLCbkwPADPj1hH ZDbw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=SOFFQI4D3dwKzzxPxQIxXUcC5o0d042ymcEicYigQo6IW6FTG4lTxJ476Dk4R6 5sY3FhInIP1O77G5n6pwUosXLZTJtamZoCWSNv9bi7Pc6V3iOfZ1LelThufQyFBE G+i+yOV2HPKTYb+i5KSEDFzPCu0uqac9qFyVfl8EvZLKI=; Received: (qmail 20279 invoked by alias); 15 Oct 2012 17:39:12 -0000 Received: (qmail 20248 invoked by uid 22791); 15 Oct 2012 17:39:10 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Oct 2012 17:39:05 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9FHd5Wa000738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Oct 2012 13:39:05 -0400 Received: from Mair.local (vpn-8-90.rdu.redhat.com [10.11.8.90]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FHd3WY010854 for ; Mon, 15 Oct 2012 13:39:04 -0400 Message-ID: <507C4A38.3000005@redhat.com> Date: Mon, 15 Oct 2012 13:39:04 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: GCC Patches Subject: [lra] patch to revert a code from previous patch. X-IsSubscribed: yes 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 After committing a patch yesterday to implement proposals from a review, I found that GCC crashes on SPEC2000 gap. LRA is trying to find a mode of operand (const_int 1) in *lea_general_1 insn and can not find it as the operand and insn template operand has VOIDmode. There are still cases when context lookup is necessary to find a mode of the operand. So I am reversing the change I did yesterday. The patch is committed as rev. 192462. 2012-10-15 Vladimir Makarov * lra-int.h (lra_get_mode): Remove. * lra-constraints.c (find_mode, get_op_mode): New functions. (match_reload): Use get_op_mode instead of lra_get_mode. (process_alt_operands, curr_insn_transform): Ditto. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 192455) +++ lra-constraints.c (working copy) @@ -876,6 +876,65 @@ bitmap_head lra_bound_pseudos; (reg_class_size [(C)] == 1 \ || (reg_class_size [(C)] >= 1 && targetm.class_likely_spilled_p (C))) +/* Return mode of WHAT inside of WHERE whose mode of the context is + OUTER_MODE. If WHERE does not contain WHAT, return VOIDmode. */ +static enum machine_mode +find_mode (rtx *where, enum machine_mode outer_mode, rtx *what) +{ + int i, j; + enum machine_mode mode; + rtx x; + const char *fmt; + enum rtx_code code; + + if (where == what) + return outer_mode; + if (*where == NULL_RTX) + return VOIDmode; + x = *where; + code = GET_CODE (x); + outer_mode = GET_MODE (x); + fmt = GET_RTX_FORMAT (code); + for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) + { + if (fmt[i] == 'e') + { + if ((mode = find_mode (&XEXP (x, i), outer_mode, what)) != VOIDmode) + return mode; + } + else if (fmt[i] == 'E') + { + for (j = XVECLEN (x, i) - 1; j >= 0; j--) + if ((mode = find_mode (&XVECEXP (x, i, j), outer_mode, what)) + != VOIDmode) + return mode; + } + } + return VOIDmode; +} + +/* Return mode for operand NOP of the current insn. */ +static inline enum machine_mode +get_op_mode (int nop) +{ + rtx *loc; + enum machine_mode mode; + bool md_first_p = asm_noperands (PATTERN (curr_insn)) < 0; + + /* Take mode from the machine description first. */ + if (md_first_p && (mode = curr_static_id->operand[nop].mode) != VOIDmode) + return mode; + loc = curr_id->operand_loc[nop]; + /* Take mode from the operand second. */ + mode = GET_MODE (*loc); + if (mode != VOIDmode) + return mode; + if (! md_first_p && (mode = curr_static_id->operand[nop].mode) != VOIDmode) + return mode; + /* Here is a very rare case. Take mode from the context. */ + return find_mode (&PATTERN (curr_insn), VOIDmode, loc); +} + /* If REG is a reload pseudo, try to make its class satisfying CL. */ static void narrow_reload_pseudo_class (rtx reg, enum reg_class cl) @@ -910,8 +969,8 @@ match_reload (signed char out, signed ch rtx in_rtx = *curr_id->operand_loc[ins[0]]; rtx out_rtx = *curr_id->operand_loc[out]; - outmode = lra_get_mode (curr_static_id->operand[out].mode, out_rtx); - inmode = lra_get_mode (curr_static_id->operand[ins[0]].mode, in_rtx); + outmode = get_op_mode (out); + inmode = get_op_mode (ins[0]); if (inmode != outmode) { if (GET_MODE_SIZE (inmode) > GET_MODE_SIZE (outmode)) @@ -1639,8 +1698,7 @@ process_alt_operands (int only_alternati } op = no_subreg_reg_operand[nop]; - mode = lra_get_mode (curr_static_id->operand[nop].mode, - *curr_id->operand_loc[nop]); + mode = get_op_mode (nop); win = did_match = winreg = offmemok = constmemok = false; badop = true; @@ -2113,8 +2171,7 @@ process_alt_operands (int only_alternati && ((targetm.preferred_reload_class (op, this_alternative) == NO_REGS) || no_input_reloads_p) - && lra_get_mode (curr_static_id->operand[nop].mode, - op) != VOIDmode) + && get_op_mode (nop) != VOIDmode) { const_to_mem = 1; if (! no_regs_p) @@ -3099,8 +3156,7 @@ curr_insn_transform (void) rtx op = *curr_id->operand_loc[i]; rtx subreg = NULL_RTX; rtx plus = NULL_RTX; - enum machine_mode mode - = lra_get_mode (curr_static_id->operand[i].mode, op); + enum machine_mode mode = get_op_mode (i); if (GET_CODE (op) == SUBREG) { @@ -3214,7 +3270,7 @@ curr_insn_transform (void) enum op_type type = curr_static_id->operand[i].type; loc = curr_id->operand_loc[i]; - mode = lra_get_mode (curr_static_id->operand[i].mode, *loc); + mode = get_op_mode (i); if (GET_CODE (*loc) == SUBREG) { reg = SUBREG_REG (*loc); Index: lra-int.h =================================================================== --- lra-int.h (revision 192455) +++ lra-int.h (working copy) @@ -238,16 +238,6 @@ struct lra_insn_recog_data typedef struct lra_insn_recog_data *lra_insn_recog_data_t; -/* Return mode for X which corresponds to machine description operand - with mode MD_MODE. */ -static inline enum machine_mode -lra_get_mode (enum machine_mode md_mode, rtx x) -{ - if (GET_MODE (x) != VOIDmode) - return GET_MODE (x); - return md_mode; -} - /* lra.c: */ extern FILE *lra_dump_file;