diff options
author | Richard Biener <rguenther@suse.de> | 2023-04-18 17:26:57 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-04-24 09:35:38 +0200 |
commit | 60bf26a412a9ec2b467c04fac1dfacef2ef09c6d (patch) | |
tree | cd47590228fd0a2c9832b783373a4290605a2133 /gcc/predict.cc | |
parent | 28c06d0ed134d7d325da101e7e4230067cebeab3 (diff) | |
download | gcc-60bf26a412a9ec2b467c04fac1dfacef2ef09c6d.zip gcc-60bf26a412a9ec2b467c04fac1dfacef2ef09c6d.tar.gz gcc-60bf26a412a9ec2b467c04fac1dfacef2ef09c6d.tar.bz2 |
This replaces uses of last_stmt where we do not require debug skipping
There are quite some cases which want to access the control stmt
ending a basic-block. Since there cannot be debug stmts after
such stmt there's no point in using last_stmt which skips debug
stmts and can be a compile-time hog for larger testcases.
* gimple-ssa-split-paths.cc (is_feasible_trace): Avoid
last_stmt.
* graphite-scop-detection.cc (single_pred_cond_non_loop_exit):
Likewise.
* ipa-fnsummary.cc (set_cond_stmt_execution_predicate): Likewise.
(set_switch_stmt_execution_predicate): Likewise.
(phi_result_unknown_predicate): Likewise.
* ipa-prop.cc (compute_complex_ancestor_jump_func): Likewise.
(ipa_analyze_indirect_call_uses): Likewise.
* predict.cc (predict_iv_comparison): Likewise.
(predict_extra_loop_exits): Likewise.
(predict_loops): Likewise.
(tree_predict_by_opcode): Likewise.
* gimple-predicate-analysis.cc (predicate::init_from_control_deps):
Likewise.
* gimple-pretty-print.cc (dump_implicit_edges): Likewise.
* tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Likewise.
(replace_phi_edge_with_variable): Likewise.
(two_value_replacement): Likewise.
(value_replacement): Likewise.
(minmax_replacement): Likewise.
(spaceship_replacement): Likewise.
(cond_removal_in_builtin_zero_pattern): Likewise.
* tree-ssa-reassoc.cc (maybe_optimize_range_tests): Likewise.
* tree-ssa-sccvn.cc (vn_phi_eq): Likewise.
(vn_phi_lookup): Likewise.
(vn_phi_insert): Likewise.
* tree-ssa-structalias.cc (compute_points_to_sets): Likewise.
* tree-ssa-threadbackward.cc (back_threader::maybe_thread_block):
Likewise.
(back_threader_profitability::possibly_profitable_path_p):
Likewise.
* tree-ssa-threadedge.cc (jump_threader::thread_outgoing_edges):
Likewise.
* tree-switch-conversion.cc (pass_convert_switch::execute):
Likewise.
(pass_lower_switch<O0>::execute): Likewise.
* tree-tailcall.cc (tree_optimize_tail_calls_1): Likewise.
* tree-vect-loop-manip.cc (vect_loop_versioning): Likewise.
* tree-vect-slp.cc (vect_slp_function): Likewise.
* tree-vect-stmts.cc (cfun_returns): Likewise.
* tree-vectorizer.cc (vect_loop_vectorized_call): Likewise.
(vect_loop_dist_alias_call): Likewise.
Diffstat (limited to 'gcc/predict.cc')
-rw-r--r-- | gcc/predict.cc | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/gcc/predict.cc b/gcc/predict.cc index a0dc409..4a686b0 100644 --- a/gcc/predict.cc +++ b/gcc/predict.cc @@ -1685,7 +1685,6 @@ predict_iv_comparison (class loop *loop, basic_block bb, enum tree_code loop_bound_code, int loop_bound_step) { - gimple *stmt; tree compare_var, compare_base; enum tree_code compare_code; tree compare_step_var; @@ -1695,10 +1694,10 @@ predict_iv_comparison (class loop *loop, basic_block bb, if (predicted_by_loop_heuristics_p (bb)) return; - stmt = last_stmt (bb); - if (!stmt || gimple_code (stmt) != GIMPLE_COND) + gcond *stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (bb)); + if (!stmt) return; - if (!is_comparison_with_loop_invariant_p (as_a <gcond *> (stmt), + if (!is_comparison_with_loop_invariant_p (stmt, loop, &compare_var, &compare_code, &compare_step_var, @@ -1877,13 +1876,8 @@ predict_extra_loop_exits (class loop *loop, edge exit_edge) gimple *lhs_def_stmt; gphi *phi_stmt; tree cmp_rhs, cmp_lhs; - gimple *last; - gcond *cmp_stmt; - last = last_stmt (exit_edge->src); - if (!last) - return; - cmp_stmt = dyn_cast <gcond *> (last); + gcond *cmp_stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (exit_edge->src)); if (!cmp_stmt) return; @@ -2104,9 +2098,8 @@ predict_loops (void) stmt = as_a <gcond *> (nb_iter->stmt); break; } - if (!stmt && last_stmt (loop->header) - && gimple_code (last_stmt (loop->header)) == GIMPLE_COND) - stmt = as_a <gcond *> (last_stmt (loop->header)); + if (!stmt) + stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (loop->header)); if (stmt) is_comparison_with_loop_invariant_p (stmt, loop, &loop_bound_var, @@ -2195,7 +2188,6 @@ predict_loops (void) && single_succ_p (preheader_edge->src)) preheader_edge = single_pred_edge (preheader_edge->src); - gimple *stmt = last_stmt (preheader_edge->src); /* Pattern match fortran loop preheader: _16 = BUILTIN_EXPECT (_15, 1, PRED_FORTRAN_LOOP_PREHEADER); _17 = (logical(kind=4)) _16; @@ -2208,8 +2200,9 @@ predict_loops (void) headers produced by fortran frontend and in this case we want to predict paths leading to this preheader. */ + gcond *stmt + = safe_dyn_cast <gcond *> (*gsi_last_bb (preheader_edge->src)); if (stmt - && gimple_code (stmt) == GIMPLE_COND && gimple_cond_code (stmt) == NE_EXPR && TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME && integer_zerop (gimple_cond_rhs (stmt))) @@ -2676,7 +2669,6 @@ get_predictor_value (br_predictor predictor, HOST_WIDE_INT probability) static void tree_predict_by_opcode (basic_block bb) { - gimple *stmt = last_stmt (bb); edge then_edge; tree op0, op1; tree type; @@ -2686,6 +2678,7 @@ tree_predict_by_opcode (basic_block bb) enum br_predictor predictor; HOST_WIDE_INT probability; + gimple *stmt = *gsi_last_bb (bb); if (!stmt) return; |