2018-06-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / long_branch.c
blobf388a80c89258f847b5144af5c0ae9aabec8a933
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-reorder-blocks" } */
4 void abort ();
6 __attribute__((noinline, noclone)) int
7 restore (int a, int b)
9 return a * b;
12 __attribute__((noinline, noclone)) void
13 do_nothing (int *input)
15 *input = restore (*input, 1);
16 return;
19 #define CASE_ENTRY(n) \
20 case n: \
21 sum = sum / (n + 1); \
22 sum = restore (sum, n + 1); \
23 if (sum == (n + addend)) \
24 break;\
25 sum = sum / (n + 2); \
26 sum = restore (sum, n + 2); \
27 sum = sum / (n + 3); \
28 sum = restore (sum, n + 3); \
29 sum = sum / (n + 4); \
30 sum = restore (sum, n + 4); \
31 sum = sum / (n + 5); \
32 sum = restore (sum, n + 5); \
33 sum = sum / (n + 6); \
34 sum = restore (sum, n + 6); \
35 sum = sum / (n + 7); \
36 sum = restore (sum, n + 7); \
37 sum = sum / (n + 8); \
38 sum = restore (sum, n + 8); \
39 sum = sum / (n + 9); \
40 sum = restore (sum, n + 9); \
41 sum = sum / (n + 10); \
42 sum = restore (sum, n + 10); \
43 sum = sum / (n + 11); \
44 sum = restore (sum, n + 11); \
45 sum = sum / (n + 12); \
46 sum = restore (sum, n + 12); \
47 sum = sum / (n + 13); \
48 sum = restore (sum, n + 13); \
49 sum = sum / (n + 14); \
50 sum = restore (sum, n + 14); \
51 sum = sum / (n + 15); \
52 sum = restore (sum, n + 15); \
53 sum = sum / (n + 16); \
54 sum = restore (sum, n + 16); \
55 sum = sum / (n + 17); \
56 sum = restore (sum, n + 17); \
57 sum = sum / (n + 18); \
58 sum = restore (sum, n + 18); \
59 sum = sum / (n + 19); \
60 sum = restore (sum, n + 19); \
61 sum = sum / (n + 20); \
62 sum = restore (sum, n + 20); \
63 sum = sum / (n + 21); \
64 sum = restore (sum, n + 21); \
65 sum = sum / (n + 22); \
66 sum = restore (sum, n + 22); \
67 sum = sum / (n + 23); \
68 sum = restore (sum, n + 23); \
69 sum = sum / (n + 24); \
70 sum = restore (sum, n + 24); \
71 sum = sum / (n + 25); \
72 sum = restore (sum, n + 25); \
73 sum = sum / (n + 26); \
74 sum = restore (sum, n + 26); \
75 sum = sum / (n + 27); \
76 sum = restore (sum, n + 27); \
77 sum = sum / (n + 28); \
78 sum = restore (sum, n + 28); \
79 sum = sum / (n + 29); \
80 sum = restore (sum, n + 29); \
81 sum = sum / (n + 30); \
82 sum = restore (sum, n + 30); \
83 sum = sum / (n + 31); \
84 sum = restore (sum, n + 31); \
85 sum = sum / (n + 32); \
86 sum = restore (sum, n + 32); \
87 sum = sum / (n + 33); \
88 sum = restore (sum, n + 33); \
89 sum = sum / (n + 34); \
90 sum = restore (sum, n + 34); \
91 sum = sum / (n + 35); \
92 sum = restore (sum, n + 35); \
93 sum = sum / (n + 36); \
94 sum = restore (sum, n + 36); \
95 break;
97 __attribute__((noinline, noclone)) long long
98 test_and_branch (int selector, int addend)
100 long long sum = selector + 1;
102 if (selector > 64)
104 start:
105 return sum - 1;
107 else
109 switch (selector)
111 CASE_ENTRY (1)
112 CASE_ENTRY (2)
113 CASE_ENTRY (3)
114 CASE_ENTRY (4)
115 CASE_ENTRY (5)
116 CASE_ENTRY (6)
117 CASE_ENTRY (7)
118 CASE_ENTRY (8)
119 CASE_ENTRY (9)
120 CASE_ENTRY (10)
121 CASE_ENTRY (11)
122 CASE_ENTRY (12)
123 CASE_ENTRY (13)
124 CASE_ENTRY (14)
125 CASE_ENTRY (15)
126 CASE_ENTRY (16)
127 CASE_ENTRY (17)
128 CASE_ENTRY (18)
129 CASE_ENTRY (19)
130 CASE_ENTRY (20)
131 CASE_ENTRY (21)
132 CASE_ENTRY (22)
133 CASE_ENTRY (23)
134 CASE_ENTRY (24)
135 CASE_ENTRY (25)
136 CASE_ENTRY (26)
137 CASE_ENTRY (27)
138 CASE_ENTRY (28)
139 CASE_ENTRY (29)
140 CASE_ENTRY (30)
141 CASE_ENTRY (31)
142 CASE_ENTRY (32)
143 CASE_ENTRY (33)
144 CASE_ENTRY (34)
145 CASE_ENTRY (35)
146 CASE_ENTRY (36)
147 CASE_ENTRY (37)
148 CASE_ENTRY (38)
149 CASE_ENTRY (39)
150 CASE_ENTRY (40)
151 CASE_ENTRY (41)
152 CASE_ENTRY (42)
153 CASE_ENTRY (43)
154 CASE_ENTRY (44)
155 CASE_ENTRY (45)
156 CASE_ENTRY (46)
157 CASE_ENTRY (47)
158 CASE_ENTRY (48)
159 CASE_ENTRY (49)
160 CASE_ENTRY (50)
161 CASE_ENTRY (51)
162 CASE_ENTRY (52)
163 CASE_ENTRY (53)
164 CASE_ENTRY (54)
165 CASE_ENTRY (55)
166 CASE_ENTRY (56)
167 CASE_ENTRY (57)
168 CASE_ENTRY (58)
169 CASE_ENTRY (59)
170 CASE_ENTRY (60)
171 CASE_ENTRY (61)
172 CASE_ENTRY (62)
173 CASE_ENTRY (63)
174 CASE_ENTRY (64)
177 do_nothing ((int *)&sum);
179 if (sum & 0x40)
180 goto start;
183 return -1;
187 main (int argc, char **argv)
189 long long ret = test_and_branch (64, 1);
190 if (ret != 64)
191 abort ();
193 ret = test_and_branch (7, 1);
194 if (ret != -1)
195 abort ();
197 return 0;