Testcase for PR71785
authorSegher Boessenkool <segher@kernel.crashing.org>
Mon, 21 Nov 2016 15:15:21 +0000 (16:15 +0100)
committerSegher Boessenkool <segher@gcc.gnu.org>
Mon, 21 Nov 2016 15:15:21 +0000 (16:15 +0100)
gcc/testsuite/
PR rtl-optimization/71785
* gcc.target/powerpc/pr71785.c: New file.

From-SVN: r242665

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr71785.c [new file with mode: 0644]

index 11f14f9..3f82737 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-21  Segher Boessenkool  <segher@kernel.crashing.org>
+
+       PR rtl-optimization/71785
+       * gcc.target/powerpc/pr71785.c: New file.
+
 2016-11-21  Bin Cheng  <bin.cheng@arm.com>
 
        PR testsuite/78114
diff --git a/gcc/testsuite/gcc.target/powerpc/pr71785.c b/gcc/testsuite/gcc.target/powerpc/pr71785.c
new file mode 100644 (file)
index 0000000..613dcd1
--- /dev/null
@@ -0,0 +1,52 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not {\mb\M} } } */
+
+/* Check that all computed gotos in this testcase end up unfactored completely.
+   If some is not there will be a unconditional jump left; if all works fine,
+   all are gone.  */
+
+typedef enum opcode
+{
+       OP_A,
+       OP_B,
+       OP_END
+} opcode;
+
+typedef struct op
+{
+       opcode opcode;
+       int arg;
+} op;
+
+extern void do_stuff_b(int arg);
+extern void do_stuff_c(int arg);
+
+extern int someglobal;
+
+void
+eval(op *op)
+{
+       static const void *dispatch_table[] = {
+               &&CASE_OP_A,
+               &&CASE_OP_B,
+               &&CASE_OP_C,
+               &&CASE_OP_END
+       };
+
+       goto *dispatch_table[op->opcode];
+CASE_OP_A:
+       someglobal++;
+       op++;
+       goto *dispatch_table[op->opcode];
+CASE_OP_B:
+       do_stuff_b(op->arg);
+       op++;
+       goto *dispatch_table[op->opcode];
+CASE_OP_C:
+       do_stuff_c(op->arg);
+       op++;
+       goto *dispatch_table[op->opcode];
+CASE_OP_END:
+       return;
+}