]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2013-02-18 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Feb 2013 13:03:15 +0000 (13:03 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Feb 2013 13:03:15 +0000 (13:03 +0000)
PR middle-end/56350
* cfghooks.c (merge_blocks): If we merge a latch into another
block adjust references to it.
* cfgloop.c (flow_loops_find): Reset latch before recomputing it.
(verify_loop_structure): Verify that a recorded latch is in fact
a latch.

* gcc.dg/torture/pr56350.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196118 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfghooks.c
gcc/cfgloop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr56350.c [new file with mode: 0644]

index 044ca29cfaa9bdb8edccd5dfafe02c5a3264dc2b..15a8fd18128dc7c794cc40e6b6119276b89ce8ed 100644 (file)
@@ -1,3 +1,12 @@
+2013-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/56350
+       * cfghooks.c (merge_blocks): If we merge a latch into another
+       block adjust references to it.
+       * cfgloop.c (flow_loops_find): Reset latch before recomputing it.
+       (verify_loop_structure): Verify that a recorded latch is in fact
+       a latch.
+
 2013-02-18  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/56321
index 54f805f5ff97130f263f0ba7dc9f3be969e60330..5e3eeb587b54c9873b6c790deba5892fed3b6a18 100644 (file)
@@ -761,7 +761,12 @@ merge_blocks (basic_block a, basic_block b)
     {
       e->src = a;
       if (current_loops != NULL)
-       rescan_loop_exit (e, true, false);
+       {
+         /* If b was a latch, a now is.  */
+         if (e->dest->loop_father->latch == b)
+           e->dest->loop_father->latch = a;
+         rescan_loop_exit (e, true, false);
+       }
     }
   a->succs = b->succs;
   a->flags |= b->flags;
index 3619907f727a6ffba9fe69104d265665154cbfb0..751da5a2c177bb31051b4b83fd21774f0e31fd65 100644 (file)
@@ -466,6 +466,8 @@ flow_loops_find (struct loops *loops)
                         "loop %d with header %d\n",
                         loop->num, header->index);
            }
+         /* Reset latch, we recompute it below.  */
+         loop->latch = NULL;
          larray.safe_push (loop);
        }
 
@@ -1413,6 +1415,19 @@ verify_loop_structure (void)
          error ("loop %d%'s header does not have exactly 2 entries", i);
          err = 1;
        }
+      if (loop->latch)
+       {
+         if (!find_edge (loop->latch, loop->header))
+           {
+             error ("loop %d%'s latch does not have an edge to its header", i);
+             err = 1;
+           }
+         if (!dominated_by_p (CDI_DOMINATORS, loop->latch, loop->header))
+           {
+             error ("loop %d%'s latch is not dominated by its header", i);
+             err = 1;
+           }
+       }
       if (loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES))
        {
          if (!single_succ_p (loop->latch))
index ac25824326e176f1ab57fe8cdcb54ef5ecca24ea..f4287ea68783ca5942ad55a82a94049b5005383f 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/56350
+       * gcc.dg/torture/pr56350.c: New testcase.
+
 2013-02-18  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/56321
diff --git a/gcc/testsuite/gcc.dg/torture/pr56350.c b/gcc/testsuite/gcc.dg/torture/pr56350.c
new file mode 100644 (file)
index 0000000..dc9ed08
--- /dev/null
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+
+int a, b;
+short c;
+
+void f(void)
+{
+  int a = 0;
+  int *k = 0;
+
+  for(; a < 2; a++);
+
+  if(!!(b |= a < 3) - 1)
+    {
+      if(0)
+       for (;; a++)
+         {
+           for (; c; *k = 0);
+lbl1:
+           ;
+         }
+
+      for(; *k; k++)
+       {
+         c = b ? : a;
+
+         if (c)
+           lbl2:
+               b = 0;
+       }
+      goto lbl1;
+    }
+
+  for(;; b++)
+    {
+      if(b)
+       goto lbl2;
+
+      k = &b;
+    }
+}