https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68870
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- So to complete my earlier fix we need to do sth like Index: gcc/tree-cfgcleanup.c =================================================================== --- gcc/tree-cfgcleanup.c (revision 231673) +++ gcc/tree-cfgcleanup.c (working copy) @@ -78,7 +78,8 @@ remove_fallthru_edge (vec<edge, va_gc> * at block BB. */ static bool -cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi) +cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi, + bool first_p) { edge taken_edge; bool retval = false; @@ -95,15 +96,26 @@ cleanup_control_expr_graph (basic_block switch (gimple_code (stmt)) { case GIMPLE_COND: - { - code_helper rcode; - tree ops[3] = {}; - if (gimple_simplify (stmt, &rcode, ops, NULL, no_follow_ssa_edges, - no_follow_ssa_edges) - && rcode == INTEGER_CST) - val = ops[0]; - break; - } + /* During a first iteration on the CFG only remove trivially + dead edges but mark other conditions for re-evaluation. */ + if (first_p) + { + val = const_binop (gimple_cond_code (stmt), boolean_type_node, + gimple_cond_lhs (stmt), + gimple_cond_rhs (stmt)); + if (! val) + bitmap_set_bit (cfgcleanup_altered_bbs, bb->index); + } + else + { + code_helper rcode; + tree ops[3] = {}; + if (gimple_simplify (stmt, &rcode, ops, NULL, no_follow_ssa_edges, + no_follow_ssa_edges) + && rcode == INTEGER_CST) + val = ops[0]; + } + break; case GIMPLE_SWITCH: val = gimple_switch_index (as_a <gswitch *> (stmt)); @@ -176,7 +188,7 @@ cleanup_call_ctrl_altering_flag (gimple true if anything changes. */ static bool -cleanup_control_flow_bb (basic_block bb) +cleanup_control_flow_bb (basic_block bb, bool first_p) { gimple_stmt_iterator gsi; bool retval = false; @@ -199,7 +211,7 @@ cleanup_control_flow_bb (basic_block bb) || gimple_code (stmt) == GIMPLE_SWITCH) { gcc_checking_assert (gsi_stmt (gsi_last_bb (bb)) == stmt); - retval |= cleanup_control_expr_graph (bb, gsi); + retval |= cleanup_control_expr_graph (bb, gsi, first_p); } else if (gimple_code (stmt) == GIMPLE_GOTO && TREE_CODE (gimple_goto_dest (stmt)) == ADDR_EXPR @@ -680,7 +692,7 @@ cleanup_tree_cfg_1 (void) { bb = BASIC_BLOCK_FOR_FN (cfun, i); if (bb) - retval |= cleanup_control_flow_bb (bb); + retval |= cleanup_control_flow_bb (bb, true); } /* After doing the above SSA form should be valid (or an update SSA @@ -708,7 +720,7 @@ cleanup_tree_cfg_1 (void) if (!bb) continue; - retval |= cleanup_control_flow_bb (bb); + retval |= cleanup_control_flow_bb (bb, false); retval |= cleanup_tree_cfg_bb (bb); }