https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90259
Kewen Lin <linkw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |linkw at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #7 from Kewen Lin <linkw at gcc dot gnu.org> --- The function copyprop_hardreg_forward_1 of pass cprop_hardreg has the code: /* Detect obviously dead sets (via REG_UNUSED notes) and remove them. */ if (set && !RTX_FRAME_RELATED_P (insn) && NONJUMP_INSN_P (insn) && !may_trap_p (set) && find_reg_note (insn, REG_UNUSED, SET_DEST (set)) && !side_effects_p (SET_SRC (set)) && !side_effects_p (SET_DEST (set))) { bool last = insn == BB_END (bb); delete_insn (insn); if (last) break; continue; } it removes the insn 109 (insn 109 117 79 6 (set (reg:DF 33 1 [orig:134+8 ] [134]) (mem:DF (plus:SI (reg/f:SI 31 31) (const_int 40 [0x28])) [11 S8 A64])) "pr90259_test.cc":5:53 584 {*movdf_hardfloat32} (expr_list:REG_UNUSED (reg:DF 33 1 [orig:134+8 ] [134]) (expr_list:REG_EH_REGION (const_int 2 [0x2]) (nil)))) as DF 33 is unused and it meets the above conditions. The case can pass if we purge dead edges after this removal, such as the below diff. But I need more investigation to see if we can purge these kinds of dead edges when they are created (it should make more senses). ======= diff --git a/gcc/regcprop.cc b/gcc/regcprop.cc index ce9d32a4fb7..afcfc0bf252 100644 --- a/gcc/regcprop.cc +++ b/gcc/regcprop.cc @@ -36,6 +36,7 @@ #include "cfgrtl.h" #include "target.h" #include "function-abi.h" +#include "cfgcleanup.h" /* The following code does forward propagation of hard register copies. The object is to eliminate as many dependencies as possible, so that @@ -74,6 +75,7 @@ struct value_data struct value_data_entry e[FIRST_PSEUDO_REGISTER]; unsigned int max_value_regs; unsigned int n_debug_insn_changes; + bool need_purge_dead_edge; }; static object_allocator<queued_debug_insn_change> queued_debug_insn_change_pool @@ -818,7 +820,11 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) bool last = insn == BB_END (bb); delete_insn (insn); if (last) - break; + { + if (find_reg_note (insn, REG_EH_REGION, NULL_RTX)) + vd->need_purge_dead_edge = true; + break; + } continue; } @@ -1405,6 +1411,7 @@ pass_cprop_hardreg::execute (function *fun) FOR_EACH_BB_FN (bb, fun) { + all_vd[bb->index].need_purge_dead_edge = false; if (cprop_hardreg_bb (bb, all_vd, visited)) curr->safe_push (bb->index); if (all_vd[bb->index].n_debug_insn_changes) @@ -1444,6 +1451,10 @@ pass_cprop_hardreg::execute (function *fun) std::swap (curr, next); } + FOR_EACH_BB_FN (bb, fun) + if (all_vd[bb->index].need_purge_dead_edge) + purge_dead_edges (bb); + free (all_vd); return 0; }