From patchwork Fri Jul 1 17:36:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 102937 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 6464FB6F5A for ; Sat, 2 Jul 2011 03:37:07 +1000 (EST) Received: (qmail 3399 invoked by alias); 1 Jul 2011 17:37:04 -0000 Received: (qmail 3087 invoked by uid 22791); 1 Jul 2011 17:36:59 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_CL, 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:36:41 +0000 Received: (qmail 11869 invoked from network); 1 Jul 2011 17:36:40 -0000 Received: from unknown (HELO ?84.152.209.23?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Jul 2011 17:36:40 -0000 Message-ID: <4E0E05A1.9020909@codesourcery.com> Date: Fri, 01 Jul 2011 19:36:33 +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: [8/11] Expander changes 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 This replaces remaining uses of GET_MODE_BITSIZE with GET_MODE_PRECISION where doing so seems relatively obviously correct. The patch is intended to cover the expander. Bernd * optabs.c (expand_binop): Use GET_MODE_PRECISION instead of GET_MODE_BITSIZE where appropriate. (widen_leading, expand_parity, expand_ctz, expand_ffs, expand_unop, expand_abs_nojump, expand_one_cmpl_abs_nojump, expand_float, expand_fix): Likewise. * expr.c (convert_move, convert_modes, expand_expr_real_2, expand_expr_real_1, reduce_to_bit_field_precision): Likewise. * stor-layout.c (get_mode_bounds): Likewise. * cfgexpand.c (convert_debug_memory_address, expand_debug_expr): Likewise. * convert.c (convert_to_integer): Likewise. * expmed.c (expand_shift_1): Likewise. Index: gcc/optabs.c =================================================================== --- gcc/optabs.c.orig +++ gcc/optabs.c @@ -1407,7 +1407,7 @@ expand_binop (enum machine_mode mode, op { optab otheroptab = (binoptab == rotl_optab ? rotr_optab : rotl_optab); rtx newop1; - unsigned int bits = GET_MODE_BITSIZE (mode); + unsigned int bits = GET_MODE_PRECISION (mode); if (CONST_INT_P (op1)) newop1 = GEN_INT (bits - INTVAL (op1)); @@ -2353,8 +2353,8 @@ widen_leading (enum machine_mode mode, r unoptab != clrsb_optab); if (temp != 0) temp = expand_binop (wider_mode, sub_optab, temp, - GEN_INT (GET_MODE_BITSIZE (wider_mode) - - GET_MODE_BITSIZE (mode)), + GEN_INT (GET_MODE_PRECISION (wider_mode) + - GET_MODE_PRECISION (mode)), target, true, OPTAB_DIRECT); if (temp == 0) delete_insns_since (last); @@ -2540,7 +2540,7 @@ expand_parity (enum machine_mode mode, r } /* Try calculating ctz(x) as K - clz(x & -x) , - where K is GET_MODE_BITSIZE(mode) - 1. + where K is GET_MODE_PRECISION(mode) - 1. Both __builtin_ctz and __builtin_clz are undefined at zero, so we don't have to worry about what the hardware does in that case. (If @@ -2568,7 +2568,7 @@ expand_ctz (enum machine_mode mode, rtx if (temp) temp = expand_unop_direct (mode, clz_optab, temp, NULL_RTX, true); if (temp) - temp = expand_binop (mode, sub_optab, GEN_INT (GET_MODE_BITSIZE (mode) - 1), + temp = expand_binop (mode, sub_optab, GEN_INT (GET_MODE_PRECISION (mode) - 1), temp, target, true, OPTAB_DIRECT); if (temp == 0) @@ -2619,7 +2619,7 @@ expand_ffs (enum machine_mode mode, rtx if (CLZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2) { defined_at_zero = true; - val = (GET_MODE_BITSIZE (mode) - 1) - val; + val = (GET_MODE_PRECISION (mode) - 1) - val; } } else @@ -3077,8 +3077,8 @@ expand_unop (enum machine_mode mode, opt if ((unoptab == clz_optab || unoptab == clrsb_optab) && temp != 0) temp = expand_binop (wider_mode, sub_optab, temp, - GEN_INT (GET_MODE_BITSIZE (wider_mode) - - GET_MODE_BITSIZE (mode)), + GEN_INT (GET_MODE_PRECISION (wider_mode) + - GET_MODE_PRECISION (mode)), target, true, OPTAB_DIRECT); if (temp) @@ -3173,7 +3173,7 @@ expand_abs_nojump (enum machine_mode mod false) >= 2) { rtx extended = expand_shift (RSHIFT_EXPR, mode, op0, - GET_MODE_BITSIZE (mode) - 1, + GET_MODE_PRECISION (mode) - 1, NULL_RTX, 0); temp = expand_binop (mode, xor_optab, extended, op0, target, 0, @@ -3274,7 +3274,7 @@ expand_one_cmpl_abs_nojump (enum machine false) >= 2) { rtx extended = expand_shift (RSHIFT_EXPR, mode, op0, - GET_MODE_BITSIZE (mode) - 1, + GET_MODE_PRECISION (mode) - 1, NULL_RTX, 0); temp = expand_binop (mode, xor_optab, extended, op0, target, 0, @@ -4663,7 +4663,7 @@ expand_float (rtx to, rtx from, int unsi int doing_unsigned = unsignedp; if (fmode != GET_MODE (to) - && significand_size (fmode) < GET_MODE_BITSIZE (GET_MODE (from))) + && significand_size (fmode) < GET_MODE_PRECISION (GET_MODE (from))) continue; icode = can_float_p (fmode, imode, unsignedp); @@ -4707,7 +4707,7 @@ expand_float (rtx to, rtx from, int unsi for (fmode = GET_MODE (to); fmode != VOIDmode; fmode = GET_MODE_WIDER_MODE (fmode)) - if (GET_MODE_BITSIZE (GET_MODE (from)) < GET_MODE_BITSIZE (fmode) + if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_BITSIZE (fmode) && can_float_p (fmode, GET_MODE (from), 0) != CODE_FOR_nothing) break; @@ -4718,7 +4718,7 @@ expand_float (rtx to, rtx from, int unsi /* Avoid double-rounding when TO is narrower than FROM. */ if ((significand_size (fmode) + 1) - < GET_MODE_BITSIZE (GET_MODE (from))) + < GET_MODE_PRECISION (GET_MODE (from))) { rtx temp1; rtx neglabel = gen_label_rtx (); @@ -4785,7 +4785,7 @@ expand_float (rtx to, rtx from, int unsi 0, label); - real_2expN (&offset, GET_MODE_BITSIZE (GET_MODE (from)), fmode); + real_2expN (&offset, GET_MODE_PRECISION (GET_MODE (from)), fmode); temp = expand_binop (fmode, add_optab, target, CONST_DOUBLE_FROM_REAL_VALUE (offset, fmode), target, 0, OPTAB_LIB_WIDEN); @@ -4915,18 +4915,18 @@ expand_fix (rtx to, rtx from, int unsign 2^63. The subtraction of 2^63 should not generate any rounding as it simply clears out that bit. The rest is trivial. */ - if (unsignedp && GET_MODE_BITSIZE (GET_MODE (to)) <= HOST_BITS_PER_WIDE_INT) + if (unsignedp && GET_MODE_PRECISION (GET_MODE (to)) <= HOST_BITS_PER_WIDE_INT) for (fmode = GET_MODE (from); fmode != VOIDmode; fmode = GET_MODE_WIDER_MODE (fmode)) if (CODE_FOR_nothing != can_fix_p (GET_MODE (to), fmode, 0, &must_trunc) && (!DECIMAL_FLOAT_MODE_P (fmode) - || GET_MODE_BITSIZE (fmode) > GET_MODE_BITSIZE (GET_MODE (to)))) + || GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (GET_MODE (to)))) { int bitsize; REAL_VALUE_TYPE offset; rtx limit, lab1, lab2, insn; - bitsize = GET_MODE_BITSIZE (GET_MODE (to)); + bitsize = GET_MODE_PRECISION (GET_MODE (to)); real_2expN (&offset, bitsize - 1, fmode); limit = CONST_DOUBLE_FROM_REAL_VALUE (offset, fmode); lab1 = gen_label_rtx (); Index: gcc/expr.c =================================================================== --- gcc/expr.c.orig +++ gcc/expr.c @@ -336,8 +336,8 @@ convert_move (rtx to, rtx from, int unsi TO here. */ if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from) - && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (from))) - >= GET_MODE_SIZE (to_mode)) + && (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (from))) + >= GET_MODE_PRECISION (to_mode)) && SUBREG_PROMOTED_UNSIGNED_P (from) == unsignedp) from = gen_lowpart (to_mode, from), from_mode = to_mode; @@ -478,8 +478,8 @@ convert_move (rtx to, rtx from, int unsi /* Now both modes are integers. */ /* Handle expanding beyond a word. */ - if (GET_MODE_BITSIZE (from_mode) < GET_MODE_BITSIZE (to_mode) - && GET_MODE_BITSIZE (to_mode) > BITS_PER_WORD) + if (GET_MODE_PRECISION (from_mode) < GET_MODE_PRECISION (to_mode) + && GET_MODE_PRECISION (to_mode) > BITS_PER_WORD) { rtx insns; rtx lowpart; @@ -503,7 +503,7 @@ convert_move (rtx to, rtx from, int unsi return; } /* Next, try converting via full word. */ - else if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD + else if (GET_MODE_PRECISION (from_mode) < BITS_PER_WORD && ((code = can_extend_p (to_mode, word_mode, unsignedp)) != CODE_FOR_nothing)) { @@ -529,7 +529,7 @@ convert_move (rtx to, rtx from, int unsi from = force_reg (from_mode, from); /* Get a copy of FROM widened to a word, if necessary. */ - if (GET_MODE_BITSIZE (from_mode) < BITS_PER_WORD) + if (GET_MODE_PRECISION (from_mode) < BITS_PER_WORD) lowpart_mode = word_mode; else lowpart_mode = from_mode; @@ -567,8 +567,8 @@ convert_move (rtx to, rtx from, int unsi } /* Truncating multi-word to a word or less. */ - if (GET_MODE_BITSIZE (from_mode) > BITS_PER_WORD - && GET_MODE_BITSIZE (to_mode) <= BITS_PER_WORD) + if (GET_MODE_PRECISION (from_mode) > BITS_PER_WORD + && GET_MODE_PRECISION (to_mode) <= BITS_PER_WORD) { if (!((MEM_P (from) && ! MEM_VOLATILE_P (from) @@ -603,7 +603,7 @@ convert_move (rtx to, rtx from, int unsi } /* Handle extension. */ - if (GET_MODE_BITSIZE (to_mode) > GET_MODE_BITSIZE (from_mode)) + if (GET_MODE_PRECISION (to_mode) > GET_MODE_PRECISION (from_mode)) { /* Convert directly if that works. */ if ((code = can_extend_p (to_mode, from_mode, unsignedp)) @@ -635,8 +635,8 @@ convert_move (rtx to, rtx from, int unsi /* No suitable intermediate mode. Generate what we need with shifts. */ - shift_amount = (GET_MODE_BITSIZE (to_mode) - - GET_MODE_BITSIZE (from_mode)); + shift_amount = (GET_MODE_PRECISION (to_mode) + - GET_MODE_PRECISION (from_mode)); from = gen_lowpart (to_mode, force_reg (from_mode, from)); tmp = expand_shift (LSHIFT_EXPR, to_mode, from, shift_amount, to, unsignedp); @@ -664,7 +664,7 @@ convert_move (rtx to, rtx from, int unsi ??? Code above formerly short-circuited this, for most integer mode pairs, with a force_reg in from_mode followed by a recursive call to this routine. Appears always to have been wrong. */ - if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)) + if (GET_MODE_PRECISION (to_mode) < GET_MODE_PRECISION (from_mode)) { rtx temp = force_reg (to_mode, gen_lowpart (to_mode, from)); emit_move_insn (to, temp); @@ -742,11 +742,11 @@ convert_modes (enum machine_mode mode, e wider than HOST_BITS_PER_WIDE_INT, we must be narrowing the operand. */ if ((CONST_INT_P (x) - && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) + && GET_MODE_PRECISION (mode) <= HOST_BITS_PER_WIDE_INT) || (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_CLASS (oldmode) == MODE_INT && (GET_CODE (x) == CONST_DOUBLE - || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (oldmode) + || (GET_MODE_PRECISION (mode) <= GET_MODE_PRECISION (oldmode) && ((MEM_P (x) && ! MEM_VOLATILE_P (x) && direct_load[(int) mode]) || (REG_P (x) @@ -759,7 +759,7 @@ convert_modes (enum machine_mode mode, e X does not need sign- or zero-extension. This may not be the case, but it's the best we can do. */ if (CONST_INT_P (x) && oldmode != VOIDmode - && GET_MODE_SIZE (mode) > GET_MODE_SIZE (oldmode)) + && GET_MODE_PRECISION (mode) > GET_MODE_PRECISION (oldmode)) { HOST_WIDE_INT val = INTVAL (x); @@ -4279,7 +4279,7 @@ expand_assignment (tree to, tree from, b if (!MEM_P (to_rtx) && GET_MODE (to_rtx) != BLKmode && (unsigned HOST_WIDE_INT) bitpos - >= GET_MODE_BITSIZE (GET_MODE (to_rtx))) + >= GET_MODE_PRECISION (GET_MODE (to_rtx))) { expand_normal (from); result = NULL; @@ -7476,7 +7476,7 @@ expand_expr_real_2 (sepops ops, rtx targ if (modifier == EXPAND_STACK_PARM) target = 0; if (TREE_CODE (treeop0) == INTEGER_CST - && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT + && GET_MODE_PRECISION (mode) <= HOST_BITS_PER_WIDE_INT && TREE_CONSTANT (treeop1)) { rtx constant_part; @@ -7498,7 +7498,7 @@ expand_expr_real_2 (sepops ops, rtx targ } else if (TREE_CODE (treeop1) == INTEGER_CST - && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT + && GET_MODE_PRECISION (mode) <= HOST_BITS_PER_WIDE_INT && TREE_CONSTANT (treeop0)) { rtx constant_part; @@ -8968,7 +8968,7 @@ expand_expr_real_1 (tree exp, rtx target we can't do this optimization. */ && (! DECL_BIT_FIELD (field) || ((GET_MODE_CLASS (DECL_MODE (field)) == MODE_INT) - && (GET_MODE_BITSIZE (DECL_MODE (field)) + && (GET_MODE_PRECISION (DECL_MODE (field)) <= HOST_BITS_PER_WIDE_INT)))) { if (DECL_BIT_FIELD (field) @@ -8987,7 +8987,7 @@ expand_expr_real_1 (tree exp, rtx target } else { - int count = GET_MODE_BITSIZE (imode) - bitsize; + int count = GET_MODE_PRECISION (imode) - bitsize; op0 = expand_shift (LSHIFT_EXPR, imode, op0, count, target, 0); @@ -9431,7 +9431,8 @@ expand_expr_real_1 (tree exp, rtx target /* If neither mode is BLKmode, and both modes are the same size then we can use gen_lowpart. */ else if (mode != BLKmode && GET_MODE (op0) != BLKmode - && GET_MODE_SIZE (mode) == GET_MODE_SIZE (GET_MODE (op0)) + && (GET_MODE_PRECISION (mode) + == GET_MODE_PRECISION (GET_MODE (op0))) && !COMPLEX_MODE_P (GET_MODE (op0))) { if (GET_CODE (op0) == SUBREG) @@ -9754,7 +9755,7 @@ reduce_to_bit_field_precision (rtx exp, } else { - int count = GET_MODE_BITSIZE (GET_MODE (exp)) - prec; + int count = GET_MODE_PRECISION (GET_MODE (exp)) - prec; exp = expand_shift (LSHIFT_EXPR, GET_MODE (exp), exp, count, target, 0); return expand_shift (RSHIFT_EXPR, GET_MODE (exp), Index: gcc/expmed.c =================================================================== --- gcc/expmed.c.orig +++ gcc/expmed.c @@ -2090,7 +2090,7 @@ expand_shift_1 (enum tree_code code, enu if (code == LSHIFT_EXPR && CONST_INT_P (op1) && INTVAL (op1) > 0 - && INTVAL (op1) < GET_MODE_BITSIZE (mode) + && INTVAL (op1) < GET_MODE_PRECISION (mode) && INTVAL (op1) < MAX_BITS_PER_WORD && shift_cost[speed][mode][INTVAL (op1)] > INTVAL (op1) * add_cost[speed][mode] && shift_cost[speed][mode][INTVAL (op1)] != MAX_COST) @@ -2146,7 +2146,7 @@ expand_shift_1 (enum tree_code code, enu else other_amount = simplify_gen_binary (MINUS, GET_MODE (op1), - GEN_INT (GET_MODE_BITSIZE (mode)), + GEN_INT (GET_MODE_PRECISION (mode)), op1); shifted = force_reg (mode, shifted); Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c.orig +++ gcc/cfgexpand.c @@ -2303,7 +2303,7 @@ convert_debug_memory_address (enum machi if (GET_MODE (x) == mode || GET_MODE (x) == VOIDmode) return x; - if (GET_MODE_BITSIZE (mode) < GET_MODE_BITSIZE (xmode)) + if (GET_MODE_PRECISION (mode) < GET_MODE_PRECISION (xmode)) x = simplify_gen_subreg (mode, x, xmode, subreg_lowpart_offset (mode, xmode)); @@ -2558,7 +2558,7 @@ expand_debug_expr (tree exp) op0 = simplify_gen_unary (FIX, mode, op0, inner_mode); } else if (CONSTANT_P (op0) - || GET_MODE_BITSIZE (mode) <= GET_MODE_BITSIZE (inner_mode)) + || GET_MODE_PRECISION (mode) <= GET_MODE_PRECISION (inner_mode)) op0 = simplify_gen_subreg (mode, op0, inner_mode, subreg_lowpart_offset (mode, inner_mode)); Index: gcc/convert.c =================================================================== --- gcc/convert.c.orig +++ gcc/convert.c @@ -583,7 +583,7 @@ convert_to_integer (tree type, tree expr be cleared. */ if (TYPE_UNSIGNED (type) != TYPE_UNSIGNED (TREE_TYPE (expr)) && (TYPE_PRECISION (TREE_TYPE (expr)) - != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (expr))))) + != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (expr))))) code = CONVERT_EXPR; else code = NOP_EXPR; @@ -602,7 +602,7 @@ convert_to_integer (tree type, tree expr type corresponding to its mode, then do a nop conversion to TYPE. */ else if (TREE_CODE (type) == ENUMERAL_TYPE - || outprec != GET_MODE_BITSIZE (TYPE_MODE (type))) + || outprec != GET_MODE_PRECISION (TYPE_MODE (type))) return build1 (NOP_EXPR, type, convert (lang_hooks.types.type_for_mode (TYPE_MODE (type), TYPE_UNSIGNED (type)),