From e51482c9c83406a928bef4c60f47a08a4232f379 Mon Sep 17 00:00:00 2001 From: Segher Boessenkool Date: Mon, 21 Nov 2016 16:15:21 +0100 Subject: [PATCH] Testcase for PR71785 gcc/testsuite/ PR rtl-optimization/71785 * gcc.target/powerpc/pr71785.c: New file. From-SVN: r242665 --- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.target/powerpc/pr71785.c | 52 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr71785.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 11f14f96b56..3f827378697 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-21 Segher Boessenkool + + PR rtl-optimization/71785 + * gcc.target/powerpc/pr71785.c: New file. + 2016-11-21 Bin Cheng 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 index 00000000000..613dcd1a937 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr71785.c @@ -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; +}