gcc/ChangeLog:
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / safe-indirect-jump-3.c
blobc338e30d01ad971b4931e746781bb7e176037bd7
1 /* { dg-do compile } */
2 /* { dg-options "-mno-speculate-indirect-jumps" } */
3 /* { dg-warning "'-mno-speculate-indirect-jumps' is deprecated" "" { target *-*-* } 0 } */
5 /* Test for deliberate misprediction of jump tables. */
7 void bar (void);
9 int foo (int x)
11 int a;
13 switch (x)
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;
44 bar();
46 return a;
49 /* The following assumes CR7 as the first chosen volatile. */
51 /* { dg-final { scan-assembler "crset 30" } } */
52 /* { dg-final { scan-assembler "beqctr- 7" } } */
53 /* { dg-final { scan-assembler {b \$} } } */