https://gcc.gnu.org/g:16446f19f1313c57a312857026b6982aaa7241c7

commit r14-11606-g16446f19f1313c57a312857026b6982aaa7241c7
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Wed Oct 2 14:21:24 2024 -0700

    aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]
    
    Early-RA was considering throwing instructions as being dead and removing
    them even if -fno-delete-dead-exceptions was in use. This fixes that 
oversight.
    
    Built and tested for aarch64-linux-gnu.
    
            PR target/116927
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-early-ra.cc (early_ra::is_dead_insn): Insns
            that throw are not dead with -fno-delete-dead-exceptions.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/torture/pr116927-1.C: New test.
    
    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
    (cherry picked from commit edec4bfc99744b48da3ffde1e4f39c9aceecfd42)

Diff:
---
 gcc/config/aarch64/aarch64-early-ra.cc    |  6 ++++++
 gcc/testsuite/g++.dg/torture/pr116927-1.C | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/aarch64/aarch64-early-ra.cc 
b/gcc/config/aarch64/aarch64-early-ra.cc
index dd2ed762f8ac..427b6a13aecd 100644
--- a/gcc/config/aarch64/aarch64-early-ra.cc
+++ b/gcc/config/aarch64/aarch64-early-ra.cc
@@ -3437,6 +3437,12 @@ early_ra::is_dead_insn (rtx_insn *insn)
   if (side_effects_p (set))
     return false;
 
+  /* If we can't delete dead exceptions and the insn throws,
+     then the instruction is not dead.  */
+  if (!cfun->can_delete_dead_exceptions
+      && !insn_nothrow_p (insn))
+    return false;
+
   return true;
 }
 
diff --git a/gcc/testsuite/g++.dg/torture/pr116927-1.C 
b/gcc/testsuite/g++.dg/torture/pr116927-1.C
new file mode 100644
index 000000000000..22fa1dbd7e1a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr116927-1.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-additional-options "-fnon-call-exceptions -fno-delete-dead-exceptions" 
}
+
+// PR target/116927
+// aarch64's Early ra was removing possiblely trapping
+// floating point insn
+
+void
+foo (float f)
+{
+  try {
+    f ++;
+  }catch(...)
+  {}
+}

Reply via email to