https://gcc.gnu.org/g:6f777c34c9f221a50d0fc22b70b1cf7dd1fd9101
commit r16-7574-g6f777c34c9f221a50d0fc22b70b1cf7dd1fd9101 Author: Andrew Pinski <[email protected]> Date: Tue Feb 17 21:42:30 2026 -0800 cprop_hardreg: Use delete_insn_and_edges instead of delete_insn [PR116053] So delete_insn_and_edges was added explicitly to solve the problem of having to cleanup the dead eh edges when a load becomes dead (non-trapping in this case). This moves the one call to delete_insn in cprop_hardreg over to use delete_insn_and_edges to fix this case. Basically we copyprop the sp register into a memory load. This memory load is normally dead way before but with non-call eh and -fno-delete-dead-exceptions, it is alive until cprop_hardreg. After thie copy prop of the sp register into the memory address of the load, the load becomes non-trapping and is allowed to be deleted. Except we don't remove the eh edges because cprop_hardreg only called delete_insn. So this updates the call to delete_insn_and_edges which removes the eh edges. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR rtl-optimization/116053 gcc/ChangeLog: * regcprop.cc (copyprop_hardreg_forward_1): Use delete_insn_and_edges instead of delete_insn. gcc/testsuite/ChangeLog: * gcc.dg/pr116053-1.c: New test. Signed-off-by: Andrew Pinski <[email protected]> Diff: --- gcc/regcprop.cc | 2 +- gcc/testsuite/gcc.dg/pr116053-1.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/regcprop.cc b/gcc/regcprop.cc index cc0a877a85d0..e884cb5a9666 100644 --- a/gcc/regcprop.cc +++ b/gcc/regcprop.cc @@ -862,7 +862,7 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) && !side_effects_p (SET_DEST (set))) { bool last = insn == BB_END (bb); - delete_insn (insn); + delete_insn_and_edges (insn); if (last) break; continue; diff --git a/gcc/testsuite/gcc.dg/pr116053-1.c b/gcc/testsuite/gcc.dg/pr116053-1.c new file mode 100644 index 000000000000..cfac84a689b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr116053-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -finstrument-functions -fno-forward-propagate -fno-delete-dead-exceptions -fnon-call-exceptions" } */ +/* { dg-require-effective-target exceptions } */ + +/* PR rtl-optimization/116053 */ + +void +foo (__int128 x) +{ + x = *(__int128 *) __builtin_memset (&x, 0, 10); +}
