From beb8758f95e923ebea354786754095013d4ce903 Mon Sep 17 00:00:00 2001 From: ktkachov Date: Mon, 12 Sep 2016 08:17:27 +0000 Subject: [expmed.c] PR middle-end/77426 Delete duplicate condition in synth_mult PR middle-end/77426 * expmed.c (synth_mult): Delete duplicate mode check. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240089 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/expmed.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/expmed.c') diff --git a/gcc/expmed.c b/gcc/expmed.c index 1cedf023c8e..a5da8836f21 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -2571,7 +2571,6 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, /* See if we already know what to do for T. */ entry_ptr = alg_hash_entry_ptr (hash_index); if (entry_ptr->t == t - && entry_ptr->mode == mode && entry_ptr->mode == mode && entry_ptr->speed == speed && entry_ptr->alg != alg_unknown) -- cgit v1.2.1 From ac29ece21d1243ab39f49fd72ef7c171cf1feaee Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 16 Sep 2016 19:20:44 +0000 Subject: Add inline functions for various bitwise operations. * hwint.h (least_bit_hwi, pow2_or_zerop, pow2p_hwi, ctz_or_zero): New. * hwint.c (exact_log2): Use pow2p_hwi. (ctz_hwi, ffs_hwi): Use least_bit_hwi. * alias.c (memrefs_conflict_p): Use pow2_or_zerop. * builtins.c (get_object_alignment_2, get_object_alignment) (get_pointer_alignment, fold_builtin_atomic_always_lock_free): Use least_bit_hwi. * calls.c (compute_argument_addresses, store_one_arg): Use least_bit_hwi. * cfgexpand.c (expand_one_stack_var_at): Use least_bit_hwi. * combine.c (force_to_mode): Use least_bit_hwi. * emit-rtl.c (set_mem_attributes_minus_bitpos, adjust_address_1): Use least_bit_hwi. * expmed.c (synth_mult, expand_divmod): Use ctz_or_zero, ctz_hwi. (init_expmed_one_conv): Use pow2p_hwi. * fold-const.c (round_up_loc, round_down_loc): Use pow2_or_zerop. (fold_binary_loc): Use pow2p_hwi. * function.c (assign_parm_find_stack_rtl): Use least_bit_hwi. * gimple-fold.c (gimple_fold_builtin_memory_op): Use pow2p_hwi. * gimple-ssa-strength-reduction.c (replace_ref): Use least_bit_hwi. * hsa-gen.c (gen_hsa_addr_with_align, hsa_bitmemref_alignment): Use least_bit_hwi. * ipa-cp.c (ipcp_alignment_lattice::meet_with_1): Use least_bit_hwi. * ipa-prop.c (ipa_modify_call_arguments): Use least_bit_hwi. * omp-low.c (oacc_loop_fixed_partitions) (oacc_loop_auto_partitions): Use least_bit_hwi. * rtlanal.c (nonzero_bits1): Use ctz_or_zero. * stor-layout.c (place_field): Use least_bit_hwi. * tree-pretty-print.c (dump_generic_node): Use pow2p_hwi. * tree-sra.c (build_ref_for_offset): Use least_bit_hwi. * tree-ssa-ccp.c (ccp_finalize): Use least_bit_hwi. * tree-ssa-math-opts.c (bswap_replace): Use least_bit_hwi. * tree-ssa-strlen.c (handle_builtin_memcmp): Use pow2p_hwi. * tree-vect-data-refs.c (vect_analyze_group_access_1) (vect_grouped_store_supported, vect_grouped_load_supported) (vect_permute_load_chain, vect_shift_permute_load_chain) (vect_transform_grouped_load): Use pow2p_hwi. * tree-vect-generic.c (expand_vector_divmod): Use ctz_or_zero. * tree-vect-patterns.c (vect_recog_divmod_pattern): Use ctz_or_zero. * tree-vect-stmts.c (vectorizable_mask_load_store): Use least_bit_hwi. * tsan.c (instrument_expr): Use least_bit_hwi. * var-tracking.c (negative_power_of_two_p): Use pow2_or_zerop. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240194 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/expmed.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'gcc/expmed.c') diff --git a/gcc/expmed.c b/gcc/expmed.c index a5da8836f21..2f789a2f075 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -127,10 +127,10 @@ init_expmed_one_conv (struct init_expmed_rtl *all, machine_mode to_mode, comparison purposes here, reduce the bit size by one in that case. */ if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT - && exact_log2 (to_size) != -1) + && pow2p_hwi (to_size)) to_size --; if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT - && exact_log2 (from_size) != -1) + && pow2p_hwi (from_size)) from_size --; /* Assume cost of zero-extend and sign-extend is the same. */ @@ -2635,7 +2635,7 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, if ((t & 1) == 0) { do_alg_shift: - m = floor_log2 (t & -t); /* m = number of low zero bits */ + m = ctz_or_zero (t); /* m = number of low zero bits */ if (m < maxm) { q = t >> m; @@ -2872,9 +2872,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, { do_alg_add_t2_m: q = t - 1; - q = q & -q; - m = exact_log2 (q); - if (m >= 0 && m < maxm) + m = ctz_hwi (q); + if (q && m < maxm) { op_cost = shiftadd_cost (speed, mode, m); new_limit.cost = best_cost.cost - op_cost; @@ -2896,9 +2895,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, do_alg_sub_t2_m: q = t + 1; - q = q & -q; - m = exact_log2 (q); - if (m >= 0 && m < maxm) + m = ctz_hwi (q); + if (q && m < maxm) { op_cost = shiftsub0_cost (speed, mode, m); new_limit.cost = best_cost.cost - op_cost; @@ -4214,7 +4212,7 @@ expand_divmod (int rem_flag, enum tree_code code, machine_mode mode, initial right shift. */ if (mh != 0 && (d & 1) == 0) { - pre_shift = floor_log2 (d & -d); + pre_shift = ctz_or_zero (d); mh = choose_multiplier (d >> pre_shift, size, size - pre_shift, &ml, &post_shift, &dummy); @@ -4872,7 +4870,7 @@ expand_divmod (int rem_flag, enum tree_code code, machine_mode mode, int pre_shift; rtx t1; - pre_shift = floor_log2 (d & -d); + pre_shift = ctz_or_zero (d); ml = invert_mod2n (d >> pre_shift, size); t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0, pre_shift, NULL_RTX, unsignedp); -- cgit v1.2.1