diff options
author | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-20 23:01:12 +0000 |
---|---|---|
committer | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-20 23:01:12 +0000 |
commit | e1dfbe3090ccf6cfbc7275cfdfa38f71647de3ed (patch) | |
tree | 8c98991ecdce73acfe22e53e466031d83b2524c1 /gcc/expmed.c | |
parent | 6f44b17da48973c9fe4f7b690879dd90bf8a8c90 (diff) | |
parent | 1b2bf75690af8115739ebba710a44d05388c7a1a (diff) | |
download | gcc-e1dfbe3090ccf6cfbc7275cfdfa38f71647de3ed.tar.gz |
Merge in trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@202802 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r-- | gcc/expmed.c | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c index d42341c6536..b504a4e2f9f 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -55,7 +55,7 @@ static void store_split_bit_field (rtx, unsigned HOST_WIDE_INT, static rtx extract_fixed_bit_field (enum machine_mode, rtx, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, rtx, int, bool); -static rtx lshift_value (enum machine_mode, rtx, int, int); +static rtx lshift_value (enum machine_mode, unsigned HOST_WIDE_INT, int); static rtx extract_split_bit_field (rtx, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, int); static void do_cmp_and_jump (rtx, rtx, enum rtx_code, enum machine_mode, rtx); @@ -1003,7 +1003,7 @@ store_fixed_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize, || (bitsize == HOST_BITS_PER_WIDE_INT && v == -1)) all_one = 1; - value = lshift_value (mode, value, bitnum, bitsize); + value = lshift_value (mode, v, bitnum); } else { @@ -1852,15 +1852,17 @@ extract_fixed_bit_field (enum machine_mode tmode, rtx op0, return expand_shift (RSHIFT_EXPR, mode, op0, GET_MODE_BITSIZE (mode) - bitsize, target, 0); } -/* Return a constant integer rtx with the value VALUE truncated to - BITSIZE bits and then shifted left BITPOS bits. */ + +/* Return a constant integer (CONST_INT or CONST_DOUBLE) rtx with the value + VALUE << BITPOS. */ static rtx -lshift_value (enum machine_mode mode, rtx value, int bitpos, int bitsize) +lshift_value (enum machine_mode mode, unsigned HOST_WIDE_INT value, + int bitpos) { return - immed_wide_int_const (wi::lshift (wi::zext (std::make_pair (value, mode), - bitsize), bitpos), mode); + immed_wide_int_const (wi::lshift (max_wide_int (value), + bitpos), mode); } /* Extract a bit field that is split across two words @@ -2202,11 +2204,10 @@ expand_shift_1 (enum tree_code code, enum machine_mode mode, rtx shifted, other_amount = simplify_gen_unary (NEG, GET_MODE (op1), op1, GET_MODE (op1)); + HOST_WIDE_INT mask = GET_MODE_PRECISION (mode) - 1; other_amount - = simplify_gen_binary (AND, GET_MODE (op1), - other_amount, - GEN_INT (GET_MODE_PRECISION (mode) - - 1)); + = simplify_gen_binary (AND, GET_MODE (op1), other_amount, + gen_int_mode (mask, GET_MODE (op1))); } shifted = force_reg (mode, shifted); @@ -2994,7 +2995,8 @@ expand_mult_const (enum machine_mode mode, rtx op0, HOST_WIDE_INT val, insn = get_last_insn (); set_dst_reg_note (insn, REG_EQUAL, - gen_rtx_MULT (nmode, tem, GEN_INT (val_so_far)), + gen_rtx_MULT (nmode, tem, + gen_int_mode (val_so_far, nmode)), accum_inner); } } @@ -3649,7 +3651,8 @@ expand_smod_pow2 (enum machine_mode mode, rtx op0, HOST_WIDE_INT d) NULL_RTX, 1, OPTAB_LIB_WIDEN); temp = expand_binop (mode, sub_optab, temp, signmask, NULL_RTX, 1, OPTAB_LIB_WIDEN); - temp = expand_binop (mode, and_optab, temp, GEN_INT (masklow), + temp = expand_binop (mode, and_optab, temp, + gen_int_mode (masklow, mode), NULL_RTX, 1, OPTAB_LIB_WIDEN); temp = expand_binop (mode, xor_optab, temp, signmask, NULL_RTX, 1, OPTAB_LIB_WIDEN); @@ -3664,7 +3667,8 @@ expand_smod_pow2 (enum machine_mode mode, rtx op0, HOST_WIDE_INT d) temp = expand_binop (mode, add_optab, op0, signmask, NULL_RTX, 1, OPTAB_LIB_WIDEN); - temp = expand_binop (mode, and_optab, temp, GEN_INT (masklow), + temp = expand_binop (mode, and_optab, temp, + gen_int_mode (masklow, mode), NULL_RTX, 1, OPTAB_LIB_WIDEN); temp = expand_binop (mode, sub_optab, temp, signmask, NULL_RTX, 1, OPTAB_LIB_WIDEN); @@ -3739,7 +3743,7 @@ expand_sdiv_pow2 (enum machine_mode mode, rtx op0, HOST_WIDE_INT d) start_sequence (); temp2 = copy_to_mode_reg (mode, op0); - temp = expand_binop (mode, add_optab, temp2, GEN_INT (d-1), + temp = expand_binop (mode, add_optab, temp2, gen_int_mode (d - 1, mode), NULL_RTX, 0, OPTAB_LIB_WIDEN); temp = force_reg (mode, temp); @@ -3766,7 +3770,7 @@ expand_sdiv_pow2 (enum machine_mode mode, rtx op0, HOST_WIDE_INT d) temp = emit_store_flag (temp, LT, op0, const0_rtx, mode, 0, -1); if (shift_cost (optimize_insn_for_speed_p (), mode, ushift) > COSTS_N_INSNS (1)) - temp = expand_binop (mode, and_optab, temp, GEN_INT (d - 1), + temp = expand_binop (mode, and_optab, temp, gen_int_mode (d - 1, mode), NULL_RTX, 0, OPTAB_LIB_WIDEN); else temp = expand_shift (RSHIFT_EXPR, mode, temp, @@ -3779,7 +3783,7 @@ expand_sdiv_pow2 (enum machine_mode mode, rtx op0, HOST_WIDE_INT d) label = gen_label_rtx (); temp = copy_to_mode_reg (mode, op0); do_cmp_and_jump (temp, const0_rtx, GE, mode, label); - expand_inc (temp, GEN_INT (d - 1)); + expand_inc (temp, gen_int_mode (d - 1, mode)); emit_label (label); return expand_shift (RSHIFT_EXPR, mode, temp, logd, NULL_RTX, 0); } @@ -4037,9 +4041,11 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, pre_shift = floor_log2 (d); if (rem_flag) { + unsigned HOST_WIDE_INT mask + = ((unsigned HOST_WIDE_INT) 1 << pre_shift) - 1; remainder = expand_binop (compute_mode, and_optab, op0, - GEN_INT (((HOST_WIDE_INT) 1 << pre_shift) - 1), + gen_int_mode (mask, compute_mode), remainder, 1, OPTAB_LIB_WIDEN); if (remainder) @@ -4090,10 +4096,10 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, = (shift_cost (speed, compute_mode, post_shift - 1) + shift_cost (speed, compute_mode, 1) + 2 * add_cost (speed, compute_mode)); - t1 = expmed_mult_highpart (compute_mode, op0, - GEN_INT (ml), - NULL_RTX, 1, - max_cost - extra_cost); + t1 = expmed_mult_highpart + (compute_mode, op0, + gen_int_mode (ml, compute_mode), + NULL_RTX, 1, max_cost - extra_cost); if (t1 == 0) goto fail1; t2 = force_operand (gen_rtx_MINUS (compute_mode, @@ -4122,10 +4128,10 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, extra_cost = (shift_cost (speed, compute_mode, pre_shift) + shift_cost (speed, compute_mode, post_shift)); - t2 = expmed_mult_highpart (compute_mode, t1, - GEN_INT (ml), - NULL_RTX, 1, - max_cost - extra_cost); + t2 = expmed_mult_highpart + (compute_mode, t1, + gen_int_mode (ml, compute_mode), + NULL_RTX, 1, max_cost - extra_cost); if (t2 == 0) goto fail1; quotient = expand_shift @@ -4249,9 +4255,9 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, extra_cost = (shift_cost (speed, compute_mode, post_shift) + shift_cost (speed, compute_mode, size - 1) + add_cost (speed, compute_mode)); - t1 = expmed_mult_highpart (compute_mode, op0, - GEN_INT (ml), NULL_RTX, 0, - max_cost - extra_cost); + t1 = expmed_mult_highpart + (compute_mode, op0, gen_int_mode (ml, compute_mode), + NULL_RTX, 0, max_cost - extra_cost); if (t1 == 0) goto fail1; t2 = expand_shift @@ -4343,9 +4349,12 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, pre_shift = floor_log2 (d); if (rem_flag) { - remainder = expand_binop (compute_mode, and_optab, op0, - GEN_INT (((HOST_WIDE_INT) 1 << pre_shift) - 1), - remainder, 0, OPTAB_LIB_WIDEN); + unsigned HOST_WIDE_INT mask + = ((unsigned HOST_WIDE_INT) 1 << pre_shift) - 1; + remainder = expand_binop + (compute_mode, and_optab, op0, + gen_int_mode (mask, compute_mode), + remainder, 0, OPTAB_LIB_WIDEN); if (remainder) return gen_lowpart (mode, remainder); } @@ -4372,9 +4381,9 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, extra_cost = (shift_cost (speed, compute_mode, post_shift) + shift_cost (speed, compute_mode, size - 1) + 2 * add_cost (speed, compute_mode)); - t3 = expmed_mult_highpart (compute_mode, t2, - GEN_INT (ml), NULL_RTX, 1, - max_cost - extra_cost); + t3 = expmed_mult_highpart + (compute_mode, t2, gen_int_mode (ml, compute_mode), + NULL_RTX, 1, max_cost - extra_cost); if (t3 != 0) { t4 = expand_shift @@ -4512,7 +4521,7 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0, floor_log2 (d), tquotient, 1); t2 = expand_binop (compute_mode, and_optab, op0, - GEN_INT (d - 1), + gen_int_mode (d - 1, compute_mode), NULL_RTX, 1, OPTAB_LIB_WIDEN); t3 = gen_reg_rtx (compute_mode); t3 = emit_store_flag (t3, NE, t2, const0_rtx, @@ -4609,7 +4618,7 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0, floor_log2 (d), tquotient, 0); t2 = expand_binop (compute_mode, and_optab, op0, - GEN_INT (d - 1), + gen_int_mode (d - 1, compute_mode), NULL_RTX, 1, OPTAB_LIB_WIDEN); t3 = gen_reg_rtx (compute_mode); t3 = emit_store_flag (t3, NE, t2, const0_rtx, @@ -5443,7 +5452,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, STORE_FLAG_VALUE, target_mode); if (tem) return expand_binop (target_mode, add_optab, tem, - GEN_INT (normalizep), + gen_int_mode (normalizep, target_mode), target, 0, OPTAB_WIDEN); } else if (!want_add @@ -5547,7 +5556,8 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, STORE_FLAG_VALUE, target_mode); if (tem != 0) tem = expand_binop (target_mode, add_optab, tem, - GEN_INT (normalizep), target, 0, OPTAB_WIDEN); + gen_int_mode (normalizep, target_mode), + target, 0, OPTAB_WIDEN); } else if (!want_add && rtx_cost (trueval, XOR, 1, |