This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR rtl-optimization/42461


This is a missed optimization due the EH rewrite from last year: the RTL DCE 
pass doesn't eliminate calls to pure/const functions any longer.

Tested on x86_64-suse-linux.  I'd like to put this on the 4.5 branch as well, 
any objections from RMs?


2010-06-07  Eric Botcazou  <ebotcazou@adacore.com>

	PR rtl-optimization/42461
	* dce.c (deletable_insn_p): Return true for const or pure calls again.
	* except.c (insn_could_throw_p): Return false if !flag_exceptions.


2010-06-07  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.dg/pr42461.c: New test.


-- 
Eric Botcazou
Index: dce.c
===================================================================
--- dce.c	(revision 160359)
+++ dce.c	(working copy)
@@ -94,14 +94,6 @@ deletable_insn_p (rtx insn, bool fast, b
   rtx body, x;
   int i;
 
-  /* Don't delete jumps, notes and the like.  */
-  if (!NONJUMP_INSN_P (insn))
-    return false;
-
-  /* Don't delete insns that can throw.  */
-  if (!insn_nothrow_p (insn))
-    return false;
-
   if (CALL_P (insn)
       /* We cannot delete calls inside of the recursive dce because
 	 this may cause basic blocks to be deleted and this messes up
@@ -116,6 +108,14 @@ deletable_insn_p (rtx insn, bool fast, b
 	  && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
     return find_call_stack_args (insn, false, fast, arg_stores);
 
+  /* Don't delete jumps, notes and the like.  */
+  if (!NONJUMP_INSN_P (insn))
+    return false;
+
+  /* Don't delete insns that can throw.  */
+  if (!insn_nothrow_p (insn))
+    return false;
+
   body = PATTERN (insn);
   switch (GET_CODE (body))
     {
Index: except.c
===================================================================
--- except.c	(revision 160359)
+++ except.c	(working copy)
@@ -1617,6 +1617,8 @@ make_reg_eh_region_note_nothrow_nononloc
 bool
 insn_could_throw_p (const_rtx insn)
 {
+  if (!flag_exceptions)
+    return false;
   if (CALL_P (insn))
     return true;
   if (INSN_P (insn) && cfun->can_throw_non_call_exceptions)
/* PR rtl-optimization/42461 */
/* Reported by Patrick Pelissier <patrick.pelissier@gmail.com> */

/* { dg-do link } */
/* { dg-options "-O" } */

extern int link_failure (int) __attribute__ ((pure));

int main (void)
{
  if (link_failure (0) < 1)
    __builtin_unreachable ();
  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]