1 /* { dg-do compile } */
2 /* { dg-options "-mno-speculate-indirect-jumps" } */
3 /* { dg-warning "'-mno-speculate-indirect-jumps' is deprecated" "" { target *-*-* } 0 } */
4
5 /* Test for deliberate misprediction of jump tables. */
6
7 void bar (void);
8
foo(int x)9 int foo (int x)
10 {
11 int a;
12
13 switch (x)
14 {
15 default:
16 a = -1;
17 break;
18 case 0:
19 a = x * x;
20 break;
21 case 1:
22 a = x + 1;
23 break;
24 case 2:
25 a = x + x;
26 break;
27 case 3:
28 a = x << 3;
29 break;
30 case 4:
31 a = x >> 1;
32 break;
33 case 5:
34 a = x;
35 break;
36 case 6:
37 a = 0;
38 break;
39 case 7:
40 a = x * x + x;
41 break;
42 }
43
44 bar();
45
46 return a;
47 }
48
49 /* The following assumes CR7 as the first chosen volatile. */
50
51 /* { dg-final { scan-assembler "crset 30" } } */
52 /* { dg-final { scan-assembler "beqctr- 7" } } */
53 /* { dg-final { scan-assembler {b \$} } } */
54