From 720cfc437994ab33ce3047b15eddcb727a26f2c1 Mon Sep 17 00:00:00 2001 From: hubicka Date: Thu, 29 Jun 2017 16:40:53 +0000 Subject: * asan.c (asan_emit_stack_protection): Update. (create_cond_insert_point): Update. * auto-profile.c (afdo_propagate_circuit): Update. * basic-block.h (struct edge_def): Turn probability to profile_probability. (EDGE_FREQUENCY): Update. * bb-reorder.c (find_traces_1_round): Update. (better_edge_p): Update. (sanitize_hot_paths): Update. * cfg.c (unchecked_make_edge): Initialize probability to uninitialized. (make_single_succ_edge): Update. (check_bb_profile): Update. (dump_edge_info): Update. (update_bb_profile_for_threading): Update. * cfganal.c (connect_infinite_loops_to_exit): Initialize new edge probabilitycount to 0. * cfgbuild.c (compute_outgoing_frequencies): Update. * cfgcleanup.c (try_forward_edges): Update. (outgoing_edges_match): Update. (try_crossjump_to_edge): Update. * cfgexpand.c (expand_gimple_cond): Update make_single_succ_edge. (expand_gimple_tailcall): Update. (construct_init_block): Use make_single_succ_edge. (construct_exit_block): Use make_single_succ_edge. * cfghooks.c (verify_flow_info): Update. (redirect_edge_succ_nodup): Update. (split_edge): Update. (account_profile_record): Update. * cfgloopanal.c (single_likely_exit): Update. * cfgloopmanip.c (scale_loop_profile): Update. (set_zero_probability): Remove. (duplicate_loop_to_header_edge): Update. * cfgloopmanip.h (loop_version): Update prototype. * cfgrtl.c (try_redirect_by_replacing_jump): Update. (force_nonfallthru_and_redirect): Update. (update_br_prob_note): Update. (rtl_verify_edges): Update. (purge_dead_edges): Update. (rtl_lv_add_condition_to_bb): Update. * cgraph.c: (cgraph_edge::redirect_call_stmt_to_calle): Update. * cgraphunit.c (init_lowered_empty_function): Update. (cgraph_node::expand_thunk): Update. * cilk-common.c: Include profile-count.h * dojump.c (inv): Remove. (jumpifnot): Update. (jumpifnot_1): Update. (do_jump_1): Update. (do_jump): Update. (do_jump_by_parts_greater_rtx): Update. (do_compare_rtx_and_jump): Update. * dojump.h (jumpifnot, jumpifnot_1, jumpif_1, jumpif, do_jump, do_jump_1. do_compare_rtx_and_jump): Update prototype. * dwarf2cfi.c: Include profile-count.h * except.c (dw2_build_landing_pads): Use make_single_succ_edge. (sjlj_emit_dispatch_table): Likewise. * explow.c: Include profile-count.h * expmed.c (emit_store_flag_force): Update. (do_cmp_and_jump): Update. * expr.c (compare_by_pieces_d::generate): Update. (compare_by_pieces_d::finish_mode): Update. (emit_block_move_via_loop): Update. (store_expr_with_bounds): Update. (store_constructor): Update. (expand_expr_real_2): Update. (expand_expr_real_1): Update. * expr.h (try_casesi, try_tablejump): Update prototypes. * gimple-pretty-print.c (dump_probability): Update. (dump_profile): New. (dump_gimple_label): Update. (dump_gimple_bb_header): Update. * graph.c (draw_cfg_node_succ_edges): Update. * hsa-gen.c (convert_switch_statements): Update. * ifcvt.c (cheap_bb_rtx_cost_p): Update. (find_if_case_1): Update. (find_if_case_2): Update. * internal-fn.c (expand_arith_overflow_result_store): Update. (expand_addsub_overflow): Update. (expand_neg_overflow): Update. (expand_mul_overflow): Update. (expand_vector_ubsan_overflow): Update. * ipa-cp.c (good_cloning_opportunity_p): Update. * ipa-split.c (split_function): Use make_single_succ_edge. * ipa-utils.c (ipa_merge_profiles): Update. * loop-doloop.c (add_test): Update. (doloop_modify): Update. * loop-unroll.c (compare_and_jump_seq): Update. (unroll_loop_runtime_iterations): Update. * lra-constraints.c (lra_inheritance): Update. * lto-streamer-in.c (input_cfg): Update. * lto-streamer-out.c (output_cfg): Update. * mcf.c (adjust_cfg_counts): Update. * modulo-sched.c (sms_schedule): Update. * omp-expand.c (expand_omp_for_init_counts): Update. (extract_omp_for_update_vars): Update. (expand_omp_ordered_sink): Update. (expand_omp_for_ordered_loops): Update. (expand_omp_for_generic): Update. (expand_omp_for_static_nochunk): Update. (expand_omp_for_static_chunk): Update. (expand_cilk_for): Update. (expand_omp_simd): Update. (expand_omp_taskloop_for_outer): Update. (expand_omp_taskloop_for_inner): Update. * omp-simd-clone.c (simd_clone_adjust): Update. * optabs.c (expand_doubleword_shift): Update. (expand_abs): Update. (emit_cmp_and_jump_insn_1): Update. (expand_compare_and_swap_loop): Update. * optabs.h (emit_cmp_and_jump_insns): Update prototype. * predict.c (predictable_edge_p): Update. (edge_probability_reliable_p): Update. (set_even_probabilities): Update. (combine_predictions_for_insn): Update. (combine_predictions_for_bb): Update. (propagate_freq): Update. (estimate_bb_frequencies): Update. (force_edge_cold): Update. * profile-count.c (profile_count::dump): Add missing space into dump. (profile_count::debug): Add newline. (profile_count::differs_from_p): Explicitly convert to unsigned. (profile_count::stream_in): Update. (profile_probability::dump): New member function. (profile_probability::debug): New member function. (profile_probability::differs_from_p): New member function. (profile_probability::differs_lot_from_p): New member function. (profile_probability::stream_in): New member function. (profile_probability::stream_out): New member function. * profile-count.h (profile_count_quality): Rename to ... (profile_quality): ... this one. (profile_probability): New. (profile_count): Update. * profile.c (compute_branch_probabilities): Update. * recog.c (peep2_attempt): Update. * sched-ebb.c (schedule_ebbs): Update. * sched-rgn.c (find_single_block_region): Update. (compute_dom_prob_ps): Update. (schedule_region): Update. * sel-sched-ir.c (compute_succs_info): Update. * stmt.c (struct case_node): Update. (do_jump_if_equal): Update. (get_outgoing_edge_probs): Update. (conditional_probability): Update. (emit_case_dispatch_table): Update. (expand_case): Update. (expand_sjlj_dispatch_table): Update. (emit_case_nodes): Update. * targhooks.c: Update. * tracer.c (better_p): Update. (find_best_successor): Update. * trans-mem.c (expand_transaction): Update. * tree-call-cdce.c: Update. * tree-cfg.c (gimple_split_edge): Upate. (move_sese_region_to_fn): Upate. * tree-cfgcleanup.c (cleanup_control_expr_graph): Upate. * tree-eh.c (lower_resx): Upate. (cleanup_empty_eh_move_lp): Upate. * tree-if-conv.c (version_loop_for_if_conversion): Update. * tree-inline.c (copy_edges_for_bb): Update. (copy_cfg_body): Update. * tree-parloops.c (gen_parallel_loop): Update. * tree-profile.c (gimple_gen_ic_func_profiler): Update. (gimple_gen_time_profiler): Update. * tree-ssa-dce.c (remove_dead_stmt): Update. * tree-ssa-ifcombine.c (update_profile_after_ifcombine): Update. * tree-ssa-loop-im.c (execute_sm_if_changed): Update. * tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Update. (unloop_loops): Update. (try_peel_loop): Update. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Update. * tree-ssa-loop-split.c (connect_loops): Update. (split_loop): Update. * tree-ssa-loop-unswitch.c (tree_unswitch_loop): Update. (hoist_guard): Update. * tree-ssa-phionlycprop.c (propagate_rhs_into_lhs): Update. * tree-ssa-phiopt.c (replace_phi_edge_with_variable): Update. (value_replacement): Update. * tree-ssa-reassoc.c (branch_fixup): Update. * tree-ssa-tail-merge.c (replace_block_by): Update. * tree-ssa-threadupdate.c (remove_ctrl_stmt_and_useless_edges): Update. (create_edge_and_update_destination_phis): Update. (compute_path_counts): Update. (recompute_probabilities): Update. (update_joiner_offpath_counts): Update. (freqs_to_counts_path): Update. (duplicate_thread_path): Update. * tree-switch-conversion.c (hoist_edge_and_branch_if_true): Update. (struct switch_conv_info): Update. (gen_inbound_check): Update. * tree-vect-loop-manip.c (slpeel_add_loop_guard): Update. (vect_do_peeling): Update. (vect_loop_versioning): Update. * tree-vect-loop.c (scale_profile_for_vect_loop): Update. (optimize_mask_stores): Update. * ubsan.c (ubsan_expand_null_ifn): Update. * value-prof.c (gimple_divmod_fixed_value): Update. (gimple_divmod_fixed_value_transform): Update. (gimple_mod_pow2): Update. (gimple_mod_pow2_value_transform): Update. (gimple_mod_subtract): Update. (gimple_mod_subtract_transform): Update. (gimple_ic): Update. (gimple_stringop_fixed_value): Update. (gimple_stringops_transform): Update. * value-prof.h: Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249800 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-unswitch.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'gcc/tree-ssa-loop-unswitch.c') diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 12bf640d3f8..6ad5741827b 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -480,7 +480,7 @@ static struct loop * tree_unswitch_loop (struct loop *loop, basic_block unswitch_on, tree cond) { - unsigned prob_true; + profile_probability prob_true; edge edge_true, edge_false; /* Some sanity checking. */ @@ -490,9 +490,13 @@ tree_unswitch_loop (struct loop *loop, extract_true_false_edges_from_block (unswitch_on, &edge_true, &edge_false); prob_true = edge_true->probability; + int p = prob_true.initialized_p () ? prob_true.to_reg_br_prob_base () + : REG_BR_PROB_BASE / 2; return loop_version (loop, unshare_expr (cond), - NULL, prob_true, REG_BR_PROB_BASE - prob_true, prob_true, - REG_BR_PROB_BASE - prob_true, false); + NULL, prob_true, + prob_true.invert (), + p, REG_BR_PROB_BASE - p, + false); } /* Unswitch outer loops by hoisting invariant guard on @@ -818,10 +822,13 @@ hoist_guard (struct loop *loop, edge guard) /* Create new loop pre-header. */ e = split_block (pre_header, last_stmt (pre_header)); if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " Moving guard %i->%i (prob %i) to bb %i, " - "new preheader is %i\n", - guard->src->index, guard->dest->index, guard->probability, - e->src->index, e->dest->index); + { + fprintf (dump_file, " Moving guard %i->%i (prob ", + guard->src->index, guard->dest->index); + guard->probability.dump (dump_file); + fprintf (dump_file, ") to bb %i, new preheader is %i\n", + e->src->index, e->dest->index); + } gcc_assert (loop_preheader_edge (loop)->src == e->dest); @@ -854,23 +861,26 @@ hoist_guard (struct loop *loop, edge guard) } new_edge->count = skip_count; if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " Estimated probability of skipping loop is %i\n", - new_edge->probability); + { + fprintf (dump_file, " Estimated probability of skipping loop is "); + new_edge->probability.dump (dump_file); + fprintf (dump_file, "\n"); + } /* Update profile after the transform: First decrease count of path from newly hoisted loop guard to loop header... */ e->count -= skip_count; - e->probability = REG_BR_PROB_BASE - new_edge->probability; + e->probability = new_edge->probability.invert (); e->dest->count = e->count; e->dest->frequency = EDGE_FREQUENCY (e); /* ... now update profile to represent that original guard will be optimized away ... */ - guard->probability = 0; + guard->probability = profile_probability::never (); guard->count = profile_count::zero (); - not_guard->probability = REG_BR_PROB_BASE; + not_guard->probability = profile_probability::always (); /* This count is wrong (frequency of not_guard does not change), but will be scaled later. */ not_guard->count = guard->src->count; @@ -888,7 +898,10 @@ hoist_guard (struct loop *loop, edge guard) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " %i", bb->index); - scale_bbs_frequencies_int (&bb, 1, e->probability, REG_BR_PROB_BASE); + if (e->probability.initialized_p ()) + scale_bbs_frequencies_int (&bb, 1, + e->probability.to_reg_br_prob_base (), + REG_BR_PROB_BASE); } } -- cgit v1.2.1 From ca69b0696432d6230a0cac12b1f9fc939ec1eae1 Mon Sep 17 00:00:00 2001 From: hubicka Date: Sat, 1 Jul 2017 20:46:40 +0000 Subject: * cfg.c (scale_bbs_frequencies): New function. * cfg.h (scale_bbs_frequencies): Declare it. * cfgloopanal.c (single_likely_exit): Cleanup. * cfgloopmanip.c (scale_loop_frequencies): Take profile_probability as parameter. (scale_loop_profile): Likewise. (loop_version): Likewise. (create_empty_loop_on_edge): Update. * cfgloopmanip.h (scale_loop_frequencies, scale_loop_profile, scale_loop_frequencies, scale_loop_profile, loopify, loop_version): Update prototypes. * modulo-sched.c (sms_schedule): Update. * predict.c (unlikely_executed_edge_p): Also check probability. (probably_never_executed_edge_p): Fix typo. * tree-if-conv.c (version_loop_for_if_conversion): Update. * tree-parloops.c (gen_parallel_loop): Update. * tree-ssa-loop-ivcanon.c (try_peel_loop): Update. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Update. * tree-ssa-loop-split.c (split_loop): Update. * tree-ssa-loop-unswitch.c (tree_unswitch_loop): Update. * tree-vect-loop-manip.c (vect_do_peeling): Update. (vect_loop_versioning): Update. * tree-vect-loop.c (scale_profile_for_vect_loop): Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249872 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-unswitch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'gcc/tree-ssa-loop-unswitch.c') diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 6ad5741827b..8482be5e543 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -490,12 +490,10 @@ tree_unswitch_loop (struct loop *loop, extract_true_false_edges_from_block (unswitch_on, &edge_true, &edge_false); prob_true = edge_true->probability; - int p = prob_true.initialized_p () ? prob_true.to_reg_br_prob_base () - : REG_BR_PROB_BASE / 2; return loop_version (loop, unshare_expr (cond), NULL, prob_true, prob_true.invert (), - p, REG_BR_PROB_BASE - p, + prob_true, prob_true.invert (), false); } -- cgit v1.2.1 From 2dcf5b20b2660f1681d4140f6cf0004ce3544491 Mon Sep 17 00:00:00 2001 From: hubicka Date: Sun, 16 Jul 2017 16:30:40 +0000 Subject: * tree-ssa-loop-unswitch.c (hoist_guard): Avoid use of REG_BR_PROB_BASE fixpoint arithmetics. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250241 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-unswitch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'gcc/tree-ssa-loop-unswitch.c') diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 8482be5e543..204cd0d0645 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -897,9 +897,7 @@ hoist_guard (struct loop *loop, edge guard) if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " %i", bb->index); if (e->probability.initialized_p ()) - scale_bbs_frequencies_int (&bb, 1, - e->probability.to_reg_br_prob_base (), - REG_BR_PROB_BASE); + scale_bbs_frequencies (&bb, 1, e->probability); } } -- cgit v1.2.1 From d49f7ebe3d9182066ea76155c4d3821adab847af Mon Sep 17 00:00:00 2001 From: rguenth Date: Tue, 25 Jul 2017 13:24:51 +0000 Subject: 2017-07-25 Richard Biener PR tree-optimization/81455 * tree-ssa-loop-unswitch.c (find_loop_guard): Make sure to not walk in cycles when looking for guards. * gcc.dg/pr81455.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250518 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-unswitch.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/tree-ssa-loop-unswitch.c') diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 204cd0d0645..57aba4f1dd0 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -582,8 +582,9 @@ find_loop_guard (struct loop *loop) gcond *cond; do { + basic_block next = NULL; if (single_succ_p (header)) - header = single_succ (header); + next = single_succ (header); else { cond = dyn_cast (last_stmt (header)); @@ -593,12 +594,16 @@ find_loop_guard (struct loop *loop) /* Make sure to skip earlier hoisted guards that are left in place as if (true). */ if (gimple_cond_true_p (cond)) - header = te->dest; + next = te->dest; else if (gimple_cond_false_p (cond)) - header = fe->dest; + next = fe->dest; else break; } + /* Never traverse a backedge. */ + if (header->loop_father->header == next) + return NULL; + header = next; } while (1); if (!flow_bb_inside_loop_p (loop, te->dest) -- cgit v1.2.1