https://gcc.gnu.org/g:cbfcd3865f6b87df53891ab62edde5cbdb3a0cbd
commit cbfcd3865f6b87df53891ab62edde5cbdb3a0cbd Author: Ondřej Machota <ondrejmach...@gmail.com> Date: Mon Mar 17 23:30:08 2025 +0100 rtl-ssa-dce: add prefetch as prelive + clone on pass Diff: --- gcc/dce.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gcc/dce.cc b/gcc/dce.cc index 091e5c620f5b..b11ced743d74 100644 --- a/gcc/dce.cc +++ b/gcc/dce.cc @@ -1454,8 +1454,7 @@ bool is_rtx_insn_prelive(rtx_insn *insn) { // return !find_call_stack_args (as_a <rtx_call_insn *> (insn), false, fast, arg_stores); // Only rtx_insn should be handled here - auto code = GET_CODE(insn); - gcc_assert(code == INSN); + gcc_assert(GET_CODE(insn) == INSN); /* Don't delete insns that may throw if we cannot do so. */ if (!(cfun->can_delete_dead_exceptions && can_alter_cfg) && !insn_nothrow_p (insn)) @@ -1476,6 +1475,11 @@ bool is_rtx_insn_prelive(rtx_insn *insn) { if (GET_CODE(body) == CLOBBER) // gcc/gcc/testsuite/gcc.c-torture/compile/20000605-1.c return true; + if (GET_CODE(body) == PREFETCH) + return true; + + // See deletable_insn_p_1 for UNSPEC. TRAP_IF is caught by may_trap_or_fault_p + // may_trap_or_fault_p helps a lot to pass some tests from RUNTESTSFLAGS=execute.exp // e. g. this one: testsuite/gcc.c-torture/execute/20020418-1.c // TODO : debug the testcase @@ -1484,10 +1488,6 @@ bool is_rtx_insn_prelive(rtx_insn *insn) { if (side_effects_with_mem(body) || can_throw_internal(body) || may_trap_or_fault_p(body)) return true; - // TODO : parallel, {pre,post}_{int,dec}, {pre,post}_modify, may_trap_or_fault_p - // Parallel is handled by volatile_refs_p - - return false; } @@ -1767,8 +1767,9 @@ namespace public: pass_rtl_ssa_dce(gcc::context *ctxt) : rtl_opt_pass(pass_data_rtl_ssa_dce, ctxt) - { - } + {} + + opt_pass * clone () final override { return new pass_rtl_ssa_dce (m_ctxt); } /* opt_pass methods: */ bool gate(function *) final override { return optimize > 0 && flag_dce; }