From patchwork Fri Jul 1 17:33:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 102934 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 4583AB6F5C for ; Sat, 2 Jul 2011 03:33:45 +1000 (EST) Received: (qmail 12443 invoked by alias); 1 Jul 2011 17:33:43 -0000 Received: (qmail 12421 invoked by uid 22791); 1 Jul 2011 17:33:40 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jul 2011 17:33:25 +0000 Received: (qmail 11396 invoked from network); 1 Jul 2011 17:33:24 -0000 Received: from unknown (HELO ?84.152.209.23?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Jul 2011 17:33:24 -0000 Message-ID: <4E0E04DD.8020500@codesourcery.com> Date: Fri, 01 Jul 2011 19:33:17 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110505 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: GCC Patches Subject: [5/11] Neater tests for paradoxical subregs References: <4E0E0310.60406@codesourcery.com> In-Reply-To: <4E0E0310.60406@codesourcery.com> 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 Adds a new helper function, paradoxical_subreg_p, and uses that instead of explicit mode comparisons. The function now uses GET_MODE_PRECISION instead of GET_MODE_BITSIZE. Additional, some code in reload testing subreg modes is adjusted to do the same. Bernd * emit-rtl.c (paradoxical_subreg_p): New function. * rtl.h (paradoxical_subreg_p): Declare. * combine.c (set_nonzero_bits_and_sign_copies, get_last_value, apply_distributive_law, simplify_comparison, simplify_set): Use it. * cse.c (record_jump_cond, cse_insn): Likewise. * expr.c (force_operand): Likewise. * rtlanal.c (num_sign_bit_copies1): Likewise. * reload1.c (eliminate_regs_1, strip_paradoxical_subreg): Likewise. * reload.c (push_secondary_reload, find_reloads_toplev): Likewise. (push_reload): Use precision to check for paradoxical subregs. * expmed.c (extract_bit_field_1): Likewise. Index: baseline-trunk/gcc/combine.c =================================================================== --- baseline-trunk.orig/gcc/combine.c +++ baseline-trunk/gcc/combine.c @@ -1610,9 +1610,7 @@ set_nonzero_bits_and_sign_copies (rtx x, set what we know about X. */ if (SET_DEST (set) == x - || (GET_CODE (SET_DEST (set)) == SUBREG - && (GET_MODE_SIZE (GET_MODE (SET_DEST (set))) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (set))))) + || (paradoxical_subreg_p (SET_DEST (set)) && SUBREG_REG (SET_DEST (set)) == x)) { rtx src = SET_SRC (set); @@ -6559,8 +6557,7 @@ simplify_set (rtx x) && INTEGRAL_MODE_P (GET_MODE (SUBREG_REG (src))) && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (src))) != UNKNOWN && SUBREG_BYTE (src) == 0 - && (GET_MODE_SIZE (GET_MODE (src)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (src)))) + && paradoxical_subreg_p (src) && MEM_P (SUBREG_REG (src))) { SUBST (SET_SRC (x), @@ -9255,8 +9252,7 @@ apply_distributive_law (rtx x) || ! subreg_lowpart_p (lhs) || (GET_MODE_CLASS (GET_MODE (lhs)) != GET_MODE_CLASS (GET_MODE (SUBREG_REG (lhs)))) - || (GET_MODE_SIZE (GET_MODE (lhs)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (lhs)))) + || paradoxical_subreg_p (lhs) || VECTOR_MODE_P (GET_MODE (lhs)) || GET_MODE_SIZE (GET_MODE (SUBREG_REG (lhs))) > UNITS_PER_WORD /* Result might need to be truncated. Don't change mode if @@ -11134,9 +11130,8 @@ simplify_comparison (enum rtx_code code, HOST_WIDE_INT c1 = INTVAL (XEXP (op1, 1)); int changed = 0; - if (GET_CODE (inner_op0) == SUBREG && GET_CODE (inner_op1) == SUBREG - && (GET_MODE_SIZE (GET_MODE (inner_op0)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (inner_op0)))) + if (paradoxical_subreg_p (inner_op0) + && GET_CODE (inner_op1) == SUBREG && (GET_MODE (SUBREG_REG (inner_op0)) == GET_MODE (SUBREG_REG (inner_op1))) && (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (inner_op0))) @@ -11979,8 +11974,7 @@ simplify_comparison (enum rtx_code code, && GET_MODE_CLASS (GET_MODE (SUBREG_REG (op0))) == MODE_INT && (code == NE || code == EQ)) { - if (GET_MODE_SIZE (GET_MODE (op0)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)))) + if (paradoxical_subreg_p (op0)) { /* For paradoxical subregs, allow case 1 as above. Case 3 isn't implemented. */ @@ -12716,8 +12710,7 @@ get_last_value (const_rtx x) we cannot predict what values the "extra" bits might have. */ if (GET_CODE (x) == SUBREG && subreg_lowpart_p (x) - && (GET_MODE_SIZE (GET_MODE (x)) - <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) + && !paradoxical_subreg_p (x) && (value = get_last_value (SUBREG_REG (x))) != 0) return gen_lowpart (GET_MODE (x), value); Index: baseline-trunk/gcc/cse.c =================================================================== --- baseline-trunk.orig/gcc/cse.c +++ baseline-trunk/gcc/cse.c @@ -3959,9 +3959,7 @@ record_jump_cond (enum rtx_code code, en is not worth testing for with no SUBREG). */ /* Note that GET_MODE (op0) may not equal MODE. */ - if (code == EQ && GET_CODE (op0) == SUBREG - && (GET_MODE_SIZE (GET_MODE (op0)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0))))) + if (code == EQ && paradoxical_subreg_p (op0)) { enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op0)); rtx tem = record_jump_cond_subreg (inner_mode, op1); @@ -3970,9 +3968,7 @@ record_jump_cond (enum rtx_code code, en reversed_nonequality); } - if (code == EQ && GET_CODE (op1) == SUBREG - && (GET_MODE_SIZE (GET_MODE (op1)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op1))))) + if (code == EQ && paradoxical_subreg_p (op1)) { enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op1)); rtx tem = record_jump_cond_subreg (inner_mode, op0); @@ -4556,9 +4552,7 @@ cse_insn (rtx insn) treat it as volatile. It may do the work of an SI in one context where the extra bits are not being used, but cannot replace an SI in general. */ - if (GET_CODE (src) == SUBREG - && (GET_MODE_SIZE (GET_MODE (src)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (src))))) + if (paradoxical_subreg_p (src)) sets[i].src_volatile = 1; #endif @@ -4836,9 +4830,7 @@ cse_insn (rtx insn) /* Also skip paradoxical subregs, unless that's what we're looking for. */ - if (code == SUBREG - && (GET_MODE_SIZE (GET_MODE (p->exp)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (p->exp)))) + if (paradoxical_subreg_p (p->exp) && ! (src != 0 && GET_CODE (src) == SUBREG && GET_MODE (src) == GET_MODE (p->exp) @@ -4947,9 +4939,7 @@ cse_insn (rtx insn) size, but later may be adjusted so that the upper bits aren't what we want. So reject it. */ if (elt != 0 - && GET_CODE (elt->exp) == SUBREG - && (GET_MODE_SIZE (GET_MODE (elt->exp)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (elt->exp)))) + && paradoxical_subreg_p (elt->exp) /* It is okay, though, if the rtx we're trying to match will ignore any of the bits we can't predict. */ && ! (src != 0 @@ -5710,9 +5700,7 @@ cse_insn (rtx insn) some tracking to be wrong. ??? Think about this more later. */ - || (GET_CODE (dest) == SUBREG - && (GET_MODE_SIZE (GET_MODE (dest)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))) + || (paradoxical_subreg_p (dest) && (GET_CODE (sets[i].src) == SIGN_EXTEND || GET_CODE (sets[i].src) == ZERO_EXTEND))) continue; Index: baseline-trunk/gcc/emit-rtl.c =================================================================== --- baseline-trunk.orig/gcc/emit-rtl.c +++ baseline-trunk/gcc/emit-rtl.c @@ -1334,6 +1334,16 @@ subreg_lowpart_p (const_rtx x) return (subreg_lowpart_offset (GET_MODE (x), GET_MODE (SUBREG_REG (x))) == SUBREG_BYTE (x)); } + +/* Return true if X is a paradoxical subreg, false otherwise. */ +bool +paradoxical_subreg_p (const_rtx x) +{ + if (GET_CODE (x) != SUBREG) + return false; + return (GET_MODE_PRECISION (GET_MODE (x)) + > GET_MODE_PRECISION (GET_MODE (SUBREG_REG (x)))); +} /* Return subword OFFSET of operand OP. The word number, OFFSET, is interpreted as the word number starting Index: baseline-trunk/gcc/expmed.c =================================================================== --- baseline-trunk.orig/gcc/expmed.c +++ baseline-trunk/gcc/expmed.c @@ -1476,8 +1476,8 @@ extract_bit_field_1 (rtx str_rtx, unsign && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (xtarget), ext_mode)) { xtarget = gen_lowpart (ext_mode, xtarget); - if (GET_MODE_SIZE (ext_mode) - > GET_MODE_SIZE (GET_MODE (xspec_target))) + if (GET_MODE_PRECISION (ext_mode) + > GET_MODE_PRECISION (GET_MODE (xspec_target))) xspec_target_subreg = xtarget; } else Index: baseline-trunk/gcc/expr.c =================================================================== --- baseline-trunk.orig/gcc/expr.c +++ baseline-trunk/gcc/expr.c @@ -6497,9 +6497,7 @@ force_operand (rtx value, rtx target) #ifdef INSN_SCHEDULING /* On machines that have insn scheduling, we want all memory reference to be explicit, so we need to deal with such paradoxical SUBREGs. */ - if (GET_CODE (value) == SUBREG && MEM_P (SUBREG_REG (value)) - && (GET_MODE_SIZE (GET_MODE (value)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (value))))) + if (paradoxical_subreg_p (value) && MEM_P (SUBREG_REG (value))) value = simplify_gen_subreg (GET_MODE (value), force_reg (GET_MODE (SUBREG_REG (value)), Index: baseline-trunk/gcc/reload1.c =================================================================== --- baseline-trunk.orig/gcc/reload1.c +++ baseline-trunk/gcc/reload1.c @@ -2840,8 +2840,7 @@ eliminate_regs_1 (rtx x, enum machine_mo eliminated version of the memory location because push_reload may do the replacement in certain circumstances. */ if (REG_P (SUBREG_REG (x)) - && (GET_MODE_SIZE (GET_MODE (x)) - <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) + && !paradoxical_subreg_p (x) && reg_equivs && reg_equiv_memory_loc (REGNO (SUBREG_REG (x))) != 0) { @@ -4495,12 +4494,9 @@ strip_paradoxical_subreg (rtx *op_ptr, r rtx op, inner, other, tem; op = *op_ptr; - if (GET_CODE (op) != SUBREG) + if (!paradoxical_subreg_p (op)) return false; - inner = SUBREG_REG (op); - if (GET_MODE_SIZE (GET_MODE (op)) <= GET_MODE_SIZE (GET_MODE (inner))) - return false; other = *other_ptr; tem = gen_lowpart_common (GET_MODE (inner), other); Index: baseline-trunk/gcc/reload.c =================================================================== --- baseline-trunk.orig/gcc/reload.c +++ baseline-trunk/gcc/reload.c @@ -347,9 +347,7 @@ push_secondary_reload (int in_p, rtx x, /* If X is a paradoxical SUBREG, use the inner value to determine both the mode and object being reloaded. */ - if (GET_CODE (x) == SUBREG - && (GET_MODE_SIZE (GET_MODE (x)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))) + if (paradoxical_subreg_p (x)) { x = SUBREG_REG (x); reload_mode = GET_MODE (x); @@ -1026,20 +1024,20 @@ push_reload (rtx in, rtx out, rtx *inloc || (((REG_P (SUBREG_REG (in)) && REGNO (SUBREG_REG (in)) >= FIRST_PSEUDO_REGISTER) || MEM_P (SUBREG_REG (in))) - && ((GET_MODE_SIZE (inmode) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))) + && ((GET_MODE_PRECISION (inmode) + > GET_MODE_PRECISION (GET_MODE (SUBREG_REG (in)))) #ifdef LOAD_EXTEND_OP || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) <= UNITS_PER_WORD) - && (GET_MODE_SIZE (inmode) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))) + && (GET_MODE_PRECISION (inmode) + > GET_MODE_PRECISION (GET_MODE (SUBREG_REG (in)))) && INTEGRAL_MODE_P (GET_MODE (SUBREG_REG (in))) && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (in))) != UNKNOWN) #endif #ifdef WORD_REGISTER_OPERATIONS - || ((GET_MODE_SIZE (inmode) - < GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))) + || ((GET_MODE_PRECISION (inmode) + < GET_MODE_PRECISION (GET_MODE (SUBREG_REG (in)))) && ((GET_MODE_SIZE (inmode) - 1) / UNITS_PER_WORD == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) - 1) / UNITS_PER_WORD))) @@ -1134,11 +1132,11 @@ push_reload (rtx in, rtx out, rtx *inloc || (((REG_P (SUBREG_REG (out)) && REGNO (SUBREG_REG (out)) >= FIRST_PSEUDO_REGISTER) || MEM_P (SUBREG_REG (out))) - && ((GET_MODE_SIZE (outmode) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))) + && ((GET_MODE_PRECISION (outmode) + > GET_MODE_PRECISION (GET_MODE (SUBREG_REG (out)))) #ifdef WORD_REGISTER_OPERATIONS - || ((GET_MODE_SIZE (outmode) - < GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))) + || ((GET_MODE_PRECISION (outmode) + < GET_MODE_PRECISION (GET_MODE (SUBREG_REG (out)))) && ((GET_MODE_SIZE (outmode) - 1) / UNITS_PER_WORD == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))) - 1) / UNITS_PER_WORD))) @@ -4752,16 +4750,15 @@ find_reloads_toplev (rtx x, int opnum, e if (regno >= FIRST_PSEUDO_REGISTER #ifdef LOAD_EXTEND_OP - && (GET_MODE_SIZE (GET_MODE (x)) - <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) + && !paradoxical_subreg_p (x) #endif - && (reg_equiv_address (regno) != 0 - || (reg_equiv_mem (regno) != 0 - && (! strict_memory_address_addr_space_p - (GET_MODE (x), XEXP (reg_equiv_mem (regno), 0), - MEM_ADDR_SPACE (reg_equiv_mem (regno))) - || ! offsettable_memref_p (reg_equiv_mem (regno)) - || num_not_at_initial_offset)))) + && (reg_equiv_address (regno) != 0 + || (reg_equiv_mem (regno) != 0 + && (! strict_memory_address_addr_space_p + (GET_MODE (x), XEXP (reg_equiv_mem (regno), 0), + MEM_ADDR_SPACE (reg_equiv_mem (regno))) + || ! offsettable_memref_p (reg_equiv_mem (regno)) + || num_not_at_initial_offset)))) x = find_reloads_subreg_address (x, 1, opnum, type, ind_levels, insn, address_reloaded); } Index: baseline-trunk/gcc/rtlanal.c =================================================================== --- baseline-trunk.orig/gcc/rtlanal.c +++ baseline-trunk/gcc/rtlanal.c @@ -4483,8 +4483,7 @@ num_sign_bit_copies1 (const_rtx x, enum then we lose all sign bit copies that existed before the store to the stack. */ - if ((GET_MODE_SIZE (GET_MODE (x)) - > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) + if (paradoxical_subreg_p (x) && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (x))) == SIGN_EXTEND && MEM_P (SUBREG_REG (x))) return cached_num_sign_bit_copies (SUBREG_REG (x), mode, Index: baseline-trunk/gcc/rtl.h =================================================================== --- baseline-trunk.orig/gcc/rtl.h +++ baseline-trunk/gcc/rtl.h @@ -1633,6 +1633,7 @@ extern rtx operand_subword (rtx, unsigne /* In emit-rtl.c */ extern rtx operand_subword_force (rtx, unsigned int, enum machine_mode); +extern bool paradoxical_subreg_p (const_rtx); extern int subreg_lowpart_p (const_rtx); extern unsigned int subreg_lowpart_offset (enum machine_mode, enum machine_mode);