aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-phiopt.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-04-18 17:26:57 +0200
committerRichard Biener <rguenther@suse.de>2023-04-24 09:35:38 +0200
commit60bf26a412a9ec2b467c04fac1dfacef2ef09c6d (patch)
treecd47590228fd0a2c9832b783373a4290605a2133 /gcc/tree-ssa-phiopt.cc
parent28c06d0ed134d7d325da101e7e4230067cebeab3 (diff)
downloadgcc-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/tree-ssa-phiopt.cc')
-rw-r--r--gcc/tree-ssa-phiopt.cc32
1 files changed, 14 insertions, 18 deletions
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index d886c88..14e689b 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -137,7 +137,6 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
for (i = 0; i < n; i++)
{
- gimple *cond_stmt;
gphi *phi;
basic_block bb1, bb2;
edge e1, e2;
@@ -146,10 +145,9 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
bb = bb_order[i];
- cond_stmt = last_stmt (bb);
/* Check to see if the last statement is a GIMPLE_COND. */
- if (!cond_stmt
- || gimple_code (cond_stmt) != GIMPLE_COND)
+ gcond *cond_stmt = safe_dyn_cast <gcond *> (*gsi_last_bb (bb));
+ if (!cond_stmt)
continue;
e1 = EDGE_SUCC (bb, 0);
@@ -408,7 +406,7 @@ replace_phi_edge_with_variable (basic_block cond_block,
/* If there are other edges into the middle block make
CFG cleanup deal with the edge removal to avoid
updating dominators here in a non-trivial way. */
- gcond *cond = as_a <gcond *> (last_stmt (cond_block));
+ gcond *cond = as_a <gcond *> (*gsi_last_bb (cond_block));
if (keep_edge->flags & EDGE_FALSE_VALUE)
gimple_cond_make_false (cond);
else if (keep_edge->flags & EDGE_TRUE_VALUE)
@@ -655,7 +653,7 @@ two_value_replacement (basic_block cond_bb, basic_block middle_bb,
if (!empty_block_p (middle_bb))
return false;
- gimple *stmt = last_stmt (cond_bb);
+ gcond *stmt = as_a <gcond *> (*gsi_last_bb (cond_bb));
tree lhs = gimple_cond_lhs (stmt);
tree rhs = gimple_cond_rhs (stmt);
@@ -1283,7 +1281,6 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
edge e0, edge e1, gphi *phi, tree arg0, tree arg1)
{
gimple_stmt_iterator gsi;
- gimple *cond;
edge true_edge, false_edge;
enum tree_code code;
bool empty_or_with_defined_p = true;
@@ -1318,7 +1315,7 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
empty_or_with_defined_p = false;
}
- cond = last_stmt (cond_bb);
+ gcond *cond = as_a <gcond *> (*gsi_last_bb (cond_bb));
code = gimple_cond_code (cond);
/* This transformation is only valid for equality comparisons. */
@@ -1826,7 +1823,7 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, basic_block alt_
if (HONOR_NANS (type) || HONOR_SIGNED_ZEROS (type))
return false;
- gcond *cond = as_a <gcond *> (last_stmt (cond_bb));
+ gcond *cond = as_a <gcond *> (*gsi_last_bb (cond_bb));
enum tree_code cmp = gimple_cond_code (cond);
tree rhs = gimple_cond_rhs (cond);
@@ -2568,7 +2565,7 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
if (!empty_block_p (middle_bb))
return false;
- gcond *cond1 = as_a <gcond *> (last_stmt (cond_bb));
+ gcond *cond1 = as_a <gcond *> (*gsi_last_bb (cond_bb));
enum tree_code cmp1 = gimple_cond_code (cond1);
switch (cmp1)
{
@@ -2610,8 +2607,8 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
tree arg2 = gimple_phi_arg_def (phi, cond2_phi_edge->dest_idx);
if (!tree_fits_shwi_p (arg2))
return false;
- gimple *cond2 = last_stmt (cond2_bb);
- if (cond2 == NULL || gimple_code (cond2) != GIMPLE_COND)
+ gcond *cond2 = safe_dyn_cast <gcond *> (*gsi_last_bb (cond2_bb));
+ if (!cond2)
return false;
enum tree_code cmp2 = gimple_cond_code (cond2);
tree lhs2 = gimple_cond_lhs (cond2);
@@ -2667,7 +2664,7 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
tree arg3 = arg2;
basic_block cond3_bb = cond2_bb;
edge cond3_phi_edge = cond2_phi_edge;
- gimple *cond3 = cond2;
+ gcond *cond3 = cond2;
enum tree_code cmp3 = cmp2;
tree lhs3 = lhs2;
tree rhs3 = rhs2;
@@ -2727,8 +2724,8 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
else
cond3_phi_edge = EDGE_SUCC (cond3_bb, 0);
arg3 = gimple_phi_arg_def (phi, cond3_phi_edge->dest_idx);
- cond3 = last_stmt (cond3_bb);
- if (cond3 == NULL || gimple_code (cond3) != GIMPLE_COND)
+ cond3 = safe_dyn_cast <gcond *> (*gsi_last_bb (cond3_bb));
+ if (!cond3)
return false;
cmp3 = gimple_cond_code (cond3);
lhs3 = gimple_cond_lhs (cond3);
@@ -2970,7 +2967,6 @@ cond_removal_in_builtin_zero_pattern (basic_block cond_bb,
edge e1, edge e2, gphi *phi,
tree arg0, tree arg1)
{
- gimple *cond;
gimple_stmt_iterator gsi, gsi_from;
gimple *call;
gimple *cast = NULL;
@@ -3076,11 +3072,11 @@ cond_removal_in_builtin_zero_pattern (basic_block cond_bb,
arg = gimple_assign_rhs1 (cast);
}
- cond = last_stmt (cond_bb);
+ gcond *cond = dyn_cast <gcond *> (*gsi_last_bb (cond_bb));
/* Cond_bb has a check for b_4 [!=|==] 0 before calling the popcount/clz/ctz
builtin. */
- if (gimple_code (cond) != GIMPLE_COND
+ if (!cond
|| (gimple_cond_code (cond) != NE_EXPR
&& gimple_cond_code (cond) != EQ_EXPR)
|| !integer_zerop (gimple_cond_rhs (cond))