diff options
author | Richard Biener <rguenther@suse.de> | 2023-04-25 16:38:44 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-04-26 08:39:58 +0200 |
commit | db29daa5e627c185aa599aa0dad093ae3a86317c (patch) | |
tree | 310057a101b07b6f95566ef9bf721eef8c10dec2 /gcc/tree-ssa-loop-niter.cc | |
parent | 5fce06b868ec0d4f75530a17d6fe6b12b7c9b5f0 (diff) | |
download | gcc-db29daa5e627c185aa599aa0dad093ae3a86317c.zip gcc-db29daa5e627c185aa599aa0dad093ae3a86317c.tar.gz gcc-db29daa5e627c185aa599aa0dad093ae3a86317c.tar.bz2 |
More last_stmt removal
This adjusts more users of last_stmt where it is clear that debug
stmt skipping is unnecessary. In most cases this also allowed
significant code simplification.
gcc/c/
* gimple-parser.cc (c_parser_parse_gimple_body): Avoid
last_stmt.
gcc/
* gimple-range-path.cc (path_range_query::compute_outgoing_relations):
Avoid last_stmt.
* ipa-pure-const.cc (pass_nothrow::execute): Likewise.
* predict.cc (apply_return_prediction): Likewise.
* sese.cc (set_ifsese_condition): Likewise. Simplify.
* tree-cfg.cc (assert_unreachable_fallthru_edge_p): Avoid last_stmt.
(make_edges_bb): Likewise.
(make_cond_expr_edges): Likewise.
(end_recording_case_labels): Likewise.
(make_gimple_asm_edges): Likewise.
(cleanup_dead_labels): Likewise.
(group_case_labels): Likewise.
(gimple_can_merge_blocks_p): Likewise.
(gimple_merge_blocks): Likewise.
(find_taken_edge): Likewise. Also handle empty fallthru blocks.
(gimple_duplicate_sese_tail): Avoid last_stmt.
(find_loop_dist_alias): Likewise.
(gimple_block_ends_with_condjump_p): Likewise.
(gimple_purge_dead_eh_edges): Likewise.
(gimple_purge_dead_abnormal_call_edges): Likewise.
(pass_warn_function_return::execute): Likewise.
(execute_fixup_cfg): Likewise.
* tree-eh.cc (redirect_eh_edge_1): Likewise.
(pass_lower_resx::execute): Likewise.
(pass_lower_eh_dispatch::execute): Likewise.
(cleanup_empty_eh): Likewise.
* tree-if-conv.cc (if_convertible_bb_p): Likewise.
(predicate_bbs): Likewise.
(ifcvt_split_critical_edges): Likewise.
* tree-loop-distribution.cc (create_edge_for_control_dependence):
Likewise.
(loop_distribution::transform_reduction_loop): Likewise.
* tree-parloops.cc (transform_to_exit_first_loop_alt): Likewise.
(try_transform_to_exit_first_loop_alt): Likewise.
(transform_to_exit_first_loop): Likewise.
(create_parallel_loop): Likewise.
* tree-scalar-evolution.cc (get_loop_exit_condition): Likewise.
* tree-ssa-dce.cc (mark_last_stmt_necessary): Likewise.
(eliminate_unnecessary_stmts): Likewise.
* tree-ssa-dom.cc
(dom_opt_dom_walker::set_global_ranges_from_unreachable_edges):
Likewise.
* tree-ssa-ifcombine.cc (ifcombine_ifandif): Likewise.
(pass_tree_ifcombine::execute): Likewise.
* tree-ssa-loop-ch.cc (entry_loop_condition_is_static): Likewise.
(should_duplicate_loop_header_p): Likewise.
* tree-ssa-loop-ivcanon.cc (create_canonical_iv): Likewise.
(tree_estimate_loop_size): Likewise.
(try_unroll_loop_completely): Likewise.
* tree-ssa-loop-ivopts.cc (tree_ssa_iv_optimize_loop): Likewise.
* tree-ssa-loop-manip.cc (ip_normal_pos): Likewise.
(canonicalize_loop_ivs): Likewise.
* tree-ssa-loop-niter.cc (determine_value_range): Likewise.
(bound_difference): Likewise.
(number_of_iterations_popcount): Likewise.
(number_of_iterations_cltz): Likewise.
(number_of_iterations_cltz_complement): Likewise.
(simplify_using_initial_conditions): Likewise.
(number_of_iterations_exit_assumptions): Likewise.
(loop_niter_by_eval): Likewise.
(estimate_numbers_of_iterations): Likewise.
Diffstat (limited to 'gcc/tree-ssa-loop-niter.cc')
-rw-r--r-- | gcc/tree-ssa-loop-niter.cc | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc index adf9937..3323397 100644 --- a/gcc/tree-ssa-loop-niter.cc +++ b/gcc/tree-ssa-loop-niter.cc @@ -436,7 +436,6 @@ determine_value_range (class loop *loop, tree type, tree var, mpz_t off, { edge e; tree c0, c1; - gimple *cond; enum tree_code cmp; if (!single_pred_p (bb)) @@ -446,7 +445,7 @@ determine_value_range (class loop *loop, tree type, tree var, mpz_t off, if (!(e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) continue; - cond = last_stmt (e->src); + gcond *cond = as_a <gcond *> (*gsi_last_bb (e->src)); c0 = gimple_cond_lhs (cond); cmp = gimple_cond_code (cond); c1 = gimple_cond_rhs (cond); @@ -719,7 +718,6 @@ bound_difference (class loop *loop, tree x, tree y, bounds *bnds) edge e; basic_block bb; tree c0, c1; - gimple *cond; enum tree_code cmp; /* Get rid of unnecessary casts, but preserve the value of @@ -771,7 +769,7 @@ bound_difference (class loop *loop, tree x, tree y, bounds *bnds) if (!(e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) continue; - cond = last_stmt (e->src); + gcond *cond = as_a <gcond *> (*gsi_last_bb (e->src)); c0 = gimple_cond_lhs (cond); cmp = gimple_cond_code (cond); c1 = gimple_cond_rhs (cond); @@ -2100,9 +2098,8 @@ number_of_iterations_popcount (loop_p loop, edge exit, /* Check that condition for staying inside the loop is like if (iv != 0). */ - gimple *cond_stmt = last_stmt (exit->src); + gcond *cond_stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (exit->src)); if (!cond_stmt - || gimple_code (cond_stmt) != GIMPLE_COND || code != NE_EXPR || !integer_zerop (gimple_cond_rhs (cond_stmt)) || TREE_CODE (gimple_cond_lhs (cond_stmt)) != SSA_NAME) @@ -2320,9 +2317,8 @@ number_of_iterations_cltz (loop_p loop, edge exit, /* Check that condition for staying inside the loop is like if (iv == 0). */ - gimple *cond_stmt = last_stmt (exit->src); + gcond *cond_stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (exit->src)); if (!cond_stmt - || gimple_code (cond_stmt) != GIMPLE_COND || (code != EQ_EXPR && code != GE_EXPR) || !integer_zerop (gimple_cond_rhs (cond_stmt)) || TREE_CODE (gimple_cond_lhs (cond_stmt)) != SSA_NAME) @@ -2481,9 +2477,8 @@ number_of_iterations_cltz_complement (loop_p loop, edge exit, /* Check that condition for staying inside the loop is like if (iv != 0). */ - gimple *cond_stmt = last_stmt (exit->src); + gcond *cond_stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (exit->src)); if (!cond_stmt - || gimple_code (cond_stmt) != GIMPLE_COND || code != NE_EXPR || !integer_zerop (gimple_cond_rhs (cond_stmt)) || TREE_CODE (gimple_cond_lhs (cond_stmt)) != SSA_NAME) @@ -2964,7 +2959,6 @@ simplify_using_initial_conditions (class loop *loop, tree expr) { edge e; basic_block bb; - gimple *stmt; tree cond, expanded, backup; int cnt = 0; @@ -2987,7 +2981,7 @@ simplify_using_initial_conditions (class loop *loop, tree expr) if (!(e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) continue; - stmt = last_stmt (e->src); + gcond *stmt = as_a <gcond *> (*gsi_last_bb (e->src)); cond = fold_build2 (gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), @@ -3096,8 +3090,6 @@ number_of_iterations_exit_assumptions (class loop *loop, edge exit, gcond **at_stmt, bool every_iteration, basic_block *body) { - gimple *last; - gcond *stmt; tree type; tree op0, op1; enum tree_code code; @@ -3122,10 +3114,7 @@ number_of_iterations_exit_assumptions (class loop *loop, edge exit, niter->control.base = NULL_TREE; niter->control.step = NULL_TREE; niter->control.no_overflow = false; - last = last_stmt (exit->src); - if (!last) - return false; - stmt = dyn_cast <gcond *> (last); + gcond *stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (exit->src)); if (!stmt) return false; @@ -3536,12 +3525,11 @@ loop_niter_by_eval (class loop *loop, edge exit) tree acnd; tree op[2], val[2], next[2], aval[2]; gphi *phi; - gimple *cond; unsigned i, j; enum tree_code cmp; - cond = last_stmt (exit->src); - if (!cond || gimple_code (cond) != GIMPLE_COND) + gcond *cond = safe_dyn_cast <gcond *> (*gsi_last_bb (exit->src)); + if (!cond) return chrec_dont_know; cmp = gimple_cond_code (cond); @@ -4808,7 +4796,7 @@ estimate_numbers_of_iterations (class loop *loop) { if (ex == likely_exit) { - gimple *stmt = last_stmt (ex->src); + gimple *stmt = *gsi_last_bb (ex->src); if (stmt != NULL) { gcond *cond = dyn_cast<gcond *> (stmt); |