20030821-1.c: Verify that the computed goto was folded away.
authorJeff Law <law@redhat.com>
Tue, 8 Mar 2005 03:40:58 +0000 (20:40 -0700)
committerJeff Law <law@gcc.gnu.org>
Tue, 8 Mar 2005 03:40:58 +0000 (20:40 -0700)
        * gcc.dg/tree-ssa/20030821-1.c: Verify that the computed goto
        was folded away.
        * gcc.dg/tree-ssa/pr18133-1.c: New test.
        * gcc.dg/tree-ssa/pr18133-2.c: New test.

From-SVN: r96085

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/20030821-1.c
gcc/testsuite/gcc.dg/tree-ssa/pr18133-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c [new file with mode: 0644]

index c7af0c6f72472e0b3851482502cb3f245ed028df..26c29d59f801f90eeebc5774c7b5fdcc273f2b13 100644 (file)
@@ -1,3 +1,10 @@
+2005-03-07  Jeff Law  <law@redhat.com>
+
+       * gcc.dg/tree-ssa/20030821-1.c: Verify that the computed goto
+       was folded away.
+       * gcc.dg/tree-ssa/pr18133-1.c: New test.
+       * gcc.dg/tree-ssa/pr18133-2.c: New test.
+
 2005-03-07  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * g++.dg/warn/weak1.C: Skip test on hppa*-*-hpux*.
index 2d1e9e78df2f232d7caf4904418b4d5b3710cdf6..08062ef1e44b6a6d3c087d8196f855980f14c6d1 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-dom1 -fdump-tree-optimized" } */
 
 void foo(int k)
 {
@@ -21,3 +21,6 @@ y: ;
 }
 
 /* { dg-final { scan-tree-dump-times "dont_remove \\(\\)" 1 "optimized"} } */
+
+/* We should have folded away the goto &x  */
+/* { dg-final { scan-tree-dump-times "goto &x" 0 "optimized"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr18133-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr18133-1.c
new file mode 100644 (file)
index 0000000..62356a1
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized-blocks" } */
+
+void foo (void)
+{
+void *p;
+p = &&L0;
+goto *p;
+L0:
+return;
+}
+
+/* The goto &L0 should have been optimized away during CFG
+   cleanups.  */
+/* { dg-final { scan-tree-dump-times "goto &L0" 0 "optimized" } } */
+
+/* There should not be any abnormal edges as DOM removed the
+   computed goto.  */
+
+/* { dg-final { scan-tree-dump-times "ab" 0 "optimized" } } */
+
+/* And verify that we have fixed the fallthru flag as well. 
+   After DOM we will have two fallthru edges (e->0, 0->1),
+   but in the dump files we mention the 0->1 two times.  So
+   scan for 3 instances of "fallthru".  */
+
+/* { dg-final { scan-tree-dump-times "fallthru" 3 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c
new file mode 100644 (file)
index 0000000..8717640
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized-blocks" } */
+
+int c, d;
+
+int
+bar (int a)
+{
+  void *p;
+  int b;
+
+  if (a!=0)
+    {
+      b = 3;
+      p = &&L0;
+    }
+  else
+    {
+      b = 5;
+      p = &&L1;
+    }
+
+  goto *p;
+
+ L0:
+  c = b;
+  return 1;
+
+ L1:
+  d = b;
+  return 0;
+}
+
+/* The both paths to the block containing the goto *p should
+   have been threaded, thus eliminating the need for the goto *p.  */
+
+/* { dg-final { scan-tree-dump-times "goto p" 0 "optimized" } } */
+
+/* There should not be any abnormal edges as DOM removed the
+   computed goto.  */
+
+/* { dg-final { scan-tree-dump-times "ab" 0 "optimized" } } */