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]

Re: [PATCH] Fix cfg_layout_merge_blocks (PR rtl-optimization/52139)


On Wed, Feb 08, 2012 at 11:55:52AM +0100, Richard Guenther wrote:
> > I'll bootstrap/regtest now just that single hunk, is that ok for
> > trunk/4.6/4.5?
> 
> Yes.

Thanks, this is what I've committed after bootstrap/regtest on x86_64-linux
and i686-linux:

2012-02-08  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/52139
	* cfgrtl.c (cfg_layout_merge_blocks): If BB_END
	is a BARRIER after emit_insn_after_noloc, move BB_END
	to the last non-BARRIER insn before it.

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

--- gcc/cfgrtl.c.jj	2012-02-07 16:05:47.977533716 +0100
+++ gcc/cfgrtl.c	2012-02-07 17:03:52.925956927 +0100
@@ -2871,6 +2871,11 @@ cfg_layout_merge_blocks (basic_block a,
       rtx first = BB_END (a), last;
 
       last = emit_insn_after_noloc (b->il.rtl->header, BB_END (a), a);
+      /* The above might add a BARRIER as BB_END, but as barriers
+	 aren't valid parts of a bb, remove_insn doesn't update
+	 BB_END if it is a barrier.  So adjust BB_END here.  */
+      while (BB_END (a) != first && BARRIER_P (BB_END (a)))
+	BB_END (a) = PREV_INSN (BB_END (a));
       delete_insn_chain (NEXT_INSN (first), last, false);
       b->il.rtl->header = NULL;
     }
--- gcc/testsuite/gcc.dg/pr52139.c.jj	2012-02-07 16:14:32.537734917 +0100
+++ gcc/testsuite/gcc.dg/pr52139.c	2012-02-07 16:14:32.537734917 +0100
@@ -0,0 +1,49 @@
+/* PR rtl-optimization/52139 */
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dominator-opts -fno-tree-fre" } */
+/* { dg-additional-options "-fpic" { target fpic } } */
+
+void *p;
+
+void
+foo (int a)
+{
+  switch (a)
+    {
+    case 0:
+    a0:
+    case 1:
+    a1:
+      p = &&a1;
+    case 2:
+    a2:
+      p = &&a2;
+    case 3:
+    a3:
+      p = &&a3;
+    case 4:
+    a4:
+      p = &&a4;
+    case 5:
+    a5:
+      p = &&a5;
+    case 6:
+    a6:
+      p = &&a6;
+    case 7:
+    a7:
+      p = &&a7;
+    case 8:
+    a8:
+      p = &&a8;
+    case 9:
+    a9:
+      p = &&a9;
+    case 10:
+    a10:
+      p = &&a10;
+    default:
+      p = &&a0;
+    }
+  goto *p;
+}


	Jakub


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