public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix -fcompare-debug issue in reload1 (PR debug/46252)
@ 2010-11-01 19:31 Jakub Jelinek
  2010-11-02 18:46 ` Eric Botcazou
  0 siblings, 1 reply; 9+ messages in thread
From: Jakub Jelinek @ 2010-11-01 19:31 UTC (permalink / raw)
  To: gcc-patches

Hi!

delete_dead_insn removes unused preceeding insn, but will not do that
if there are debug insns in between.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2010-11-01  Jakub Jelinek  <jakub@redhat.com>

	PR debug/46252
	* rtl.h (prev_real_nondebug_insn): New prototype.
	* emit-rtl.c (prev_real_nondebug_insn): New function.
	* reload1.c (delete_dead_insn): Use it instead of
	prev_real_insn.
	* cfgcleanup.c (try_head_merge_bb): Likewise.

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

--- gcc/rtl.h.jj	2010-11-01 09:07:23.000000000 +0100
+++ gcc/rtl.h	2010-11-01 15:41:31.000000000 +0100
@@ -1751,6 +1751,7 @@ extern rtx prev_nonnote_nondebug_insn (r
 extern rtx next_nonnote_nondebug_insn (rtx);
 extern rtx prev_real_insn (rtx);
 extern rtx next_real_insn (rtx);
+extern rtx prev_real_nondebug_insn (rtx);
 extern rtx prev_active_insn (rtx);
 extern rtx next_active_insn (rtx);
 extern int active_insn_p (const_rtx);
--- gcc/emit-rtl.c.jj	2010-11-01 09:07:23.000000000 +0100
+++ gcc/emit-rtl.c	2010-11-01 15:41:01.000000000 +0100
@@ -3133,8 +3133,8 @@ next_real_insn (rtx insn)
   return insn;
 }
 
-/* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
-   or 0, if there is none.  This routine does not look inside
+/* Return the last INSN, CALL_INSN, JUMP_INSN or DEBUG_INSN
+   before INSN; or 0, if there is none.  This routine does not look inside
    SEQUENCEs.  */
 
 rtx
@@ -3150,6 +3150,23 @@ prev_real_insn (rtx insn)
   return insn;
 }
 
+/* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
+   or 0, if there is none.  This routine does not look inside
+   SEQUENCEs.  */
+
+rtx
+prev_real_nondebug_insn (rtx insn)
+{
+  while (insn)
+    {
+      insn = PREV_INSN (insn);
+      if (insn == 0 || NONDEBUG_INSN_P (insn))
+	break;
+    }
+
+  return insn;
+}
+
 /* Return the last CALL_INSN in the current list, or 0 if there is none.
    This routine does not look inside SEQUENCEs.  */
 
--- gcc/reload1.c.jj	2010-11-01 09:07:24.000000000 +0100
+++ gcc/reload1.c	2010-11-01 15:39:21.000000000 +0100
@@ -2112,7 +2112,7 @@ spill_failure (rtx insn, enum reg_class 
 static void
 delete_dead_insn (rtx insn)
 {
-  rtx prev = prev_real_insn (insn);
+  rtx prev = prev_real_nondebug_insn (insn);
   rtx prev_dest;
 
   /* If the previous insn sets a register that dies in our insn, delete it
--- gcc/cfgcleanup.c.jj	2010-11-01 09:07:23.000000000 +0100
+++ gcc/cfgcleanup.c	2010-11-01 15:42:08.000000000 +0100
@@ -2054,9 +2054,7 @@ try_head_merge_bb (basic_block bb)
       max_match--;
       if (max_match == 0)
 	return false;
-      do
-	e0_last_head = prev_real_insn (e0_last_head);
-      while (DEBUG_INSN_P (e0_last_head));
+      e0_last_head = prev_real_nondebug_insn (e0_last_head);
     }
 
   if (max_match == 0)
--- gcc/testsuite/gcc.dg/pr46252.c.jj	2010-11-01 16:12:22.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr46252.c	2010-11-01 16:12:07.000000000 +0100
@@ -0,0 +1,15 @@
+/* PR debug/46252 */
+/* { dg-do compile } */
+/* { dg-options "-O -frerun-cse-after-loop -fno-tree-loop-optimize -funroll-loops -fcompare-debug" } */
+
+void
+foo (float *f)
+{
+  int i;
+  for (i = 0; i < 4; i++)
+    f[i] = i;
+  bar ();
+  for (i = 0; i < 4; i++)
+    if (f[i] != i)
+      __builtin_abort ();
+}

	Jakub

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-11-04 16:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-01 19:31 [PATCH] Fix -fcompare-debug issue in reload1 (PR debug/46252) Jakub Jelinek
2010-11-02 18:46 ` Eric Botcazou
2010-11-02 18:58   ` Jakub Jelinek
2010-11-02 19:51     ` Eric Botcazou
2010-11-02 20:09       ` Jakub Jelinek
2010-11-02 20:48         ` Eric Botcazou
2010-11-03  0:03           ` Jakub Jelinek
2010-11-03  8:32             ` Eric Botcazou
2010-11-04 16:16             ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).