| 1 |
/* { dg-options "-O2 -fdump-tree-switchconv" } */ |
| 2 |
/* { dg-do run } */ |
| 3 |
|
| 4 |
extern void abort (void); |
| 5 |
|
| 6 |
static int X, Y; |
| 7 |
|
| 8 |
int check(int param) |
| 9 |
{ |
| 10 |
int a = 0; |
| 11 |
int b = 1; |
| 12 |
|
| 13 |
switch (param) |
| 14 |
{ |
| 15 |
case -2: |
| 16 |
a = 0; |
| 17 |
b = -1; |
| 18 |
break; |
| 19 |
case 1: |
| 20 |
case 2: |
| 21 |
a = 8; |
| 22 |
b = 6; |
| 23 |
break; |
| 24 |
case 3: |
| 25 |
a = 9; |
| 26 |
b = 5; |
| 27 |
break; |
| 28 |
case 6: |
| 29 |
a = 10; |
| 30 |
b = 4; |
| 31 |
break; |
| 32 |
default: |
| 33 |
a = 16; |
| 34 |
b = 1; |
| 35 |
} |
| 36 |
|
| 37 |
X = a; |
| 38 |
Y = b; |
| 39 |
return 0; |
| 40 |
} |
| 41 |
|
| 42 |
void assertions(int a, int b) |
| 43 |
{ |
| 44 |
if (X != a || Y != b) |
| 45 |
abort(); |
| 46 |
|
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
int main () |
| 51 |
{ |
| 52 |
check (-10); |
| 53 |
assertions (16, 1); |
| 54 |
|
| 55 |
check (-2); |
| 56 |
assertions (0, -1); |
| 57 |
|
| 58 |
check(1); |
| 59 |
assertions (8, 6); |
| 60 |
|
| 61 |
check(2); |
| 62 |
assertions (8, 6); |
| 63 |
|
| 64 |
check(3); |
| 65 |
assertions (9, 5); |
| 66 |
|
| 67 |
check(5); |
| 68 |
assertions (16, 1); |
| 69 |
|
| 70 |
check(6); |
| 71 |
assertions (10, 4); |
| 72 |
|
| 73 |
check(12); |
| 74 |
assertions (16, 1); |
| 75 |
|
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
/* { dg-final { scan-tree-dump "Switch converted" "switchconv" } } */ |