]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cprop_hardreg: Use delete_insn_and_edges instead of delete_insn [PR116053]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 18 Feb 2026 05:42:30 +0000 (21:42 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 18 Feb 2026 20:15:14 +0000 (12:15 -0800)
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 <andrew.pinski@oss.qualcomm.com>
gcc/regcprop.cc
gcc/testsuite/gcc.dg/pr116053-1.c [new file with mode: 0644]

index cc0a877a85d079bf32b5dbda0e030adfd1bbf0ad..e884cb5a9666f04d259c0bc16e4c713c6f095b64 100644 (file)
@@ -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 (file)
index 0000000..cfac84a
--- /dev/null
@@ -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);
+}