libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / bitint-44.c
blobfe5c168538781a15ef9200e53a2b2e1395ab1a62
1 /* PR c/111309 */
2 /* { dg-do run { target bitint } } */
3 /* { dg-options "-std=c23 -pedantic-errors" } */
4 /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */
5 /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
7 #if __BITINT_MAXWIDTH__ >= 512
8 __attribute__((noipa)) int
9 clz512 (unsigned _BitInt(512) x)
11 return __builtin_clzg (x);
14 __attribute__((noipa)) int
15 clzd512 (unsigned _BitInt(512) x)
17 return __builtin_clzg (x, __builtin_popcountg ((typeof (x)) ~(typeof (x)) 0));
20 __attribute__((noipa)) int
21 clzD512 (unsigned _BitInt(512) x, int y)
23 return __builtin_clzg (x, y);
26 __attribute__((noipa)) int
27 ctz512 (unsigned _BitInt(512) x)
29 return __builtin_ctzg (x);
32 __attribute__((noipa)) int
33 ctzd512 (unsigned _BitInt(512) x)
35 return __builtin_ctzg (x, __builtin_popcountg ((typeof (x)) ~(typeof (x)) 0));
38 __attribute__((noipa)) int
39 ctzD512 (unsigned _BitInt(512) x, int y)
41 return __builtin_ctzg (x, y);
44 __attribute__((noipa)) int
45 clrsb512 (_BitInt(512) x)
47 return __builtin_clrsbg (x);
50 __attribute__((noipa)) int
51 ffs512 (_BitInt(512) x)
53 return __builtin_ffsg (x);
56 __attribute__((noipa)) int
57 parity512 (unsigned _BitInt(512) x)
59 return __builtin_parityg (x);
62 __attribute__((noipa)) int
63 popcount512 (unsigned _BitInt(512) x)
65 return __builtin_popcountg (x);
67 #endif
69 #if __BITINT_MAXWIDTH__ >= 523
70 __attribute__((noipa)) int
71 clz523 (unsigned _BitInt(523) x)
73 return __builtin_clzg (x);
76 __attribute__((noipa)) int
77 clzd523 (unsigned _BitInt(523) x)
79 return __builtin_clzg (x, __builtin_popcountg ((typeof (x)) ~(typeof (x)) 0));
82 __attribute__((noipa)) int
83 clzD523 (unsigned _BitInt(523) x, int y)
85 return __builtin_clzg (x, y);
88 __attribute__((noipa)) int
89 ctz523 (unsigned _BitInt(523) x)
91 return __builtin_ctzg (x);
94 __attribute__((noipa)) int
95 ctzd523 (unsigned _BitInt(523) x)
97 return __builtin_ctzg (x, __builtin_popcountg ((typeof (x)) ~(typeof (x)) 0));
100 __attribute__((noipa)) int
101 ctzD523 (unsigned _BitInt(523) x, int y)
103 return __builtin_ctzg (x, y);
106 __attribute__((noipa)) int
107 clrsb523 (_BitInt(523) x)
109 return __builtin_clrsbg (x);
112 __attribute__((noipa)) int
113 ffs523 (_BitInt(523) x)
115 return __builtin_ffsg (x);
118 __attribute__((noipa)) int
119 parity523 (unsigned _BitInt(523) x)
121 return __builtin_parityg (x);
124 __attribute__((noipa)) int
125 popcount523 (unsigned _BitInt(523) x)
127 return __builtin_popcountg (x);
129 #endif
132 main ()
134 #if __BITINT_MAXWIDTH__ >= 512
135 if (clzd512 (0) != 512
136 || clzD512 (0, -1) != -1
137 || ctzd512 (0) != 512
138 || ctzD512 (0, 42) != 42
139 || clrsb512 (0) != 512 - 1
140 || ffs512 (0) != 0
141 || parity512 (0) != 0
142 || popcount512 (0) != 0
143 || __builtin_clzg ((unsigned _BitInt(512)) 0, 512 + 32) != 512 + 32
144 || __builtin_ctzg ((unsigned _BitInt(512)) 0, 512) != 512
145 || __builtin_clrsbg ((_BitInt(512)) 0) != 512 - 1
146 || __builtin_ffsg ((_BitInt(512)) 0) != 0
147 || __builtin_parityg ((unsigned _BitInt(512)) 0) != 0
148 || __builtin_popcountg ((unsigned _BitInt(512)) 0) != 0)
149 __builtin_abort ();
150 if (clz512 (-1) != 0
151 || clzd512 (-1) != 0
152 || clzD512 (-1, 0) != 0
153 || ctz512 (-1) != 0
154 || ctzd512 (-1) != 0
155 || ctzD512 (-1, 17) != 0
156 || clrsb512 (-1) != 512 - 1
157 || ffs512 (-1) != 1
158 || parity512 (-1) != 0
159 || popcount512 (-1) != 512
160 || __builtin_clzg ((unsigned _BitInt(512)) -1) != 0
161 || __builtin_clzg ((unsigned _BitInt(512)) -1, 512 + 32) != 0
162 || __builtin_ctzg ((unsigned _BitInt(512)) -1) != 0
163 || __builtin_ctzg ((unsigned _BitInt(512)) -1, 512) != 0
164 || __builtin_clrsbg ((_BitInt(512)) -1) != 512 - 1
165 || __builtin_ffsg ((_BitInt(512)) -1) != 1
166 || __builtin_parityg ((unsigned _BitInt(512)) -1) != 0
167 || __builtin_popcountg ((unsigned _BitInt(512)) -1) != 512)
168 __builtin_abort ();
169 if (clz512 (((unsigned _BitInt(512)) -1) >> 24) != 24
170 || clz512 (((unsigned _BitInt(512)) -1) >> 79) != 79
171 || clz512 (1) != 512 - 1
172 || clzd512 (((unsigned _BitInt(512)) -1) >> 139) != 139
173 || clzd512 (2) != 512 - 2
174 || ctz512 (((unsigned _BitInt(512)) -1) << 42) != 42
175 || ctz512 (((unsigned _BitInt(512)) -1) << 57) != 57
176 || ctz512 (0x4000000000000000000000uwb) != 86
177 || ctzd512 (((unsigned _BitInt(512)) -1) << 149) != 149
178 || ctzd512 (2) != 1
179 || clrsb512 ((unsigned _BitInt(512 - 4)) -1) != 3
180 || clrsb512 ((unsigned _BitInt(512 - 28)) -1) != 27
181 || clrsb512 ((unsigned _BitInt(512 - 29)) -1) != 28
182 || clrsb512 (~(unsigned _BitInt(512)) (unsigned _BitInt(512 - 68)) -1) != 67
183 || clrsb512 (~(unsigned _BitInt(512)) (unsigned _BitInt(512 - 92)) -1) != 91
184 || clrsb512 (~(unsigned _BitInt(512)) (unsigned _BitInt(512 - 93)) -1) != 92
185 || ffs512 (((unsigned _BitInt(512)) -1) << 42) != 43
186 || ffs512 (((unsigned _BitInt(512)) -1) << 57) != 58
187 || ffs512 (0x4000000000000000000000uwb) != 87
188 || ffs512 (((unsigned _BitInt(512)) -1) << 149) != 150
189 || ffs512 (2) != 2
190 || __builtin_clzg (((unsigned _BitInt(512)) -1) >> 24) != 24
191 || __builtin_clzg (((unsigned _BitInt(512)) -1) >> 79) != 79
192 || __builtin_clzg ((unsigned _BitInt(512)) 1) != 512 - 1
193 || __builtin_clzg (((unsigned _BitInt(512)) -1) >> 139, 512) != 139
194 || __builtin_clzg ((unsigned _BitInt(512)) 2, 512) != 512 - 2
195 || __builtin_ctzg (((unsigned _BitInt(512)) -1) << 42) != 42
196 || __builtin_ctzg (((unsigned _BitInt(512)) -1) << 57) != 57
197 || __builtin_ctzg ((unsigned _BitInt(512)) 0x4000000000000000000000uwb) != 86
198 || __builtin_ctzg (((unsigned _BitInt(512)) -1) << 149, 512) != 149
199 || __builtin_ctzg ((unsigned _BitInt(512)) 2, 512) != 1
200 || __builtin_clrsbg ((_BitInt(512)) (unsigned _BitInt(512 - 4)) -1) != 3
201 || __builtin_clrsbg ((_BitInt(512)) (unsigned _BitInt(512 - 28)) -1) != 27
202 || __builtin_clrsbg ((_BitInt(512)) (unsigned _BitInt(512 - 29)) -1) != 28
203 || __builtin_clrsbg ((_BitInt(512)) ~(unsigned _BitInt(512)) (unsigned _BitInt(512 - 68)) -1) != 67
204 || __builtin_clrsbg ((_BitInt(512)) ~(unsigned _BitInt(512)) (unsigned _BitInt(512 - 92)) -1) != 91
205 || __builtin_clrsbg ((_BitInt(512)) ~(unsigned _BitInt(512)) (unsigned _BitInt(512 - 93)) -1) != 92
206 || __builtin_ffsg ((_BitInt(512)) (((unsigned _BitInt(512)) -1) << 42)) != 43
207 || __builtin_ffsg ((_BitInt(512)) (((unsigned _BitInt(512)) -1) << 57)) != 58
208 || __builtin_ffsg ((_BitInt(512)) 0x4000000000000000000000uwb) != 87
209 || __builtin_ffsg ((_BitInt(512)) (((unsigned _BitInt(512)) -1) << 149)) != 150
210 || __builtin_ffsg ((_BitInt(512)) 2) != 2)
211 __builtin_abort ();
212 if (parity512 (8278593062772967967574644592392030907507244457324713380127157444008480135136016412791369421272159911061801023217823646324038055629840240503699995274750141uwb) != __builtin_parityg (8278593062772967967574644592392030907507244457324713380127157444008480135136016412791369421272159911061801023217823646324038055629840240503699995274750141uwb)
213 || parity512 (663951521760319802637316646127146913163123967584512032007606686578544864655291546789196279408181546344880831465704154822174055168766759305688225967189384uwb) != __builtin_parityg (663951521760319802637316646127146913163123967584512032007606686578544864655291546789196279408181546344880831465704154822174055168766759305688225967189384uwb)
214 || parity512 (8114152627481936575035564712656624361256533214211179387274127464949371919139038942819974113641465089580051998523156404968195970853124179018281296621919217uwb) != __builtin_parityg (8114152627481936575035564712656624361256533214211179387274127464949371919139038942819974113641465089580051998523156404968195970853124179018281296621919217uwb)
215 || popcount512 (697171368046392901434470580443928282938585745214587494987284546386421344865289735592202298494880955572094546861862007016154025065165834164941207378563932uwb) != __builtin_popcountg (697171368046392901434470580443928282938585745214587494987284546386421344865289735592202298494880955572094546861862007016154025065165834164941207378563932uwb)
216 || popcount512 (12625357869391866487124235043239209385173615631331705015179232007319637649427586947822360147798041278948617160703315666047585702906648747835331939389354450uwb) != __builtin_popcountg (12625357869391866487124235043239209385173615631331705015179232007319637649427586947822360147798041278948617160703315666047585702906648747835331939389354450uwb)
217 || popcount512 (12989863959706456104163426941303698078341934896544520782734564901708926112239778316241786242633862403309192697330635825122310265805838908726925342761646021uwb) != __builtin_popcountg (12989863959706456104163426941303698078341934896544520782734564901708926112239778316241786242633862403309192697330635825122310265805838908726925342761646021uwb))
218 __builtin_abort ();
219 #endif
220 #if __BITINT_MAXWIDTH__ >= 523
221 if (clzd523 (0) != 523
222 || clzD523 (0, 42) != 42
223 || ctzd523 (0) != 523
224 || ctzD523 (0, -1) != -1
225 || clrsb523 (0) != 523 - 1
226 || ffs523 (0) != 0
227 || parity523 (0) != 0
228 || popcount523 (0) != 0
229 || __builtin_clzg ((unsigned _BitInt(523)) 0, 523 + 32) != 523 + 32
230 || __builtin_ctzg ((unsigned _BitInt(523)) 0, 523) != 523
231 || __builtin_clrsbg ((_BitInt(523)) 0) != 523 - 1
232 || __builtin_ffsg ((_BitInt(523)) 0) != 0
233 || __builtin_parityg ((unsigned _BitInt(523)) 0) != 0
234 || __builtin_popcountg ((unsigned _BitInt(523)) 0) != 0)
235 __builtin_abort ();
236 if (clz523 (-1) != 0
237 || clzd523 (-1) != 0
238 || clzD523 (-1, 15) != 0
239 || ctz523 (-1) != 0
240 || ctzd523 (-1) != 0
241 || ctzD523 (-1, -57) != 0
242 || clrsb523 (-1) != 523 - 1
243 || ffs523 (-1) != 1
244 || parity523 (-1) != 1
245 || popcount523 (-1) != 523
246 || __builtin_clzg ((unsigned _BitInt(523)) -1) != 0
247 || __builtin_clzg ((unsigned _BitInt(523)) -1, 523 + 32) != 0
248 || __builtin_ctzg ((unsigned _BitInt(523)) -1) != 0
249 || __builtin_ctzg ((unsigned _BitInt(523)) -1, 523) != 0
250 || __builtin_clrsbg ((_BitInt(523)) -1) != 523 - 1
251 || __builtin_ffsg ((_BitInt(523)) -1) != 1
252 || __builtin_parityg ((unsigned _BitInt(523)) -1) != 1
253 || __builtin_popcountg ((unsigned _BitInt(523)) -1) != 523)
254 __builtin_abort ();
255 if (clz523 (((unsigned _BitInt(523)) -1) >> 24) != 24
256 || clz523 (((unsigned _BitInt(523)) -1) >> 79) != 79
257 || clz523 (1) != 523 - 1
258 || clzd523 (((unsigned _BitInt(523)) -1) >> 139) != 139
259 || clzd523 (2) != 523 - 2
260 || ctz523 (((unsigned _BitInt(523)) -1) << 42) != 42
261 || ctz523 (((unsigned _BitInt(523)) -1) << 57) != 57
262 || ctz523 (0x4000000000000000000000uwb) != 86
263 || ctzd523 (((unsigned _BitInt(523)) -1) << 149) != 149
264 || ctzd523 (2) != 1
265 || clrsb523 ((unsigned _BitInt(523 - 4)) -1) != 3
266 || clrsb523 ((unsigned _BitInt(523 - 28)) -1) != 27
267 || clrsb523 ((unsigned _BitInt(523 - 29)) -1) != 28
268 || clrsb523 (~(unsigned _BitInt(523)) (unsigned _BitInt(523 - 68)) -1) != 67
269 || clrsb523 (~(unsigned _BitInt(523)) (unsigned _BitInt(523 - 92)) -1) != 91
270 || clrsb523 (~(unsigned _BitInt(523)) (unsigned _BitInt(523 - 93)) -1) != 92
271 || ffs523 (((unsigned _BitInt(523)) -1) << 42) != 43
272 || ffs523 (((unsigned _BitInt(523)) -1) << 57) != 58
273 || ffs523 (0x4000000000000000000000uwb) != 87
274 || ffs523 (((unsigned _BitInt(523)) -1) << 149) != 150
275 || ffs523 (2) != 2
276 || __builtin_clzg (((unsigned _BitInt(523)) -1) >> 24) != 24
277 || __builtin_clzg (((unsigned _BitInt(523)) -1) >> 79) != 79
278 || __builtin_clzg ((unsigned _BitInt(523)) 1) != 523 - 1
279 || __builtin_clzg (((unsigned _BitInt(523)) -1) >> 139, 523) != 139
280 || __builtin_clzg ((unsigned _BitInt(523)) 2, 523) != 523 - 2
281 || __builtin_ctzg (((unsigned _BitInt(523)) -1) << 42) != 42
282 || __builtin_ctzg (((unsigned _BitInt(523)) -1) << 57) != 57
283 || __builtin_ctzg ((unsigned _BitInt(523)) 0x4000000000000000000000uwb) != 86
284 || __builtin_ctzg (((unsigned _BitInt(523)) -1) << 149, 523) != 149
285 || __builtin_ctzg ((unsigned _BitInt(523)) 2, 523) != 1
286 || __builtin_clrsbg ((_BitInt(523)) (unsigned _BitInt(523 - 4)) -1) != 3
287 || __builtin_clrsbg ((_BitInt(523)) (unsigned _BitInt(523 - 28)) -1) != 27
288 || __builtin_clrsbg ((_BitInt(523)) (unsigned _BitInt(523 - 29)) -1) != 28
289 || __builtin_clrsbg ((_BitInt(523)) ~(unsigned _BitInt(523)) (unsigned _BitInt(523 - 68)) -1) != 67
290 || __builtin_clrsbg ((_BitInt(523)) ~(unsigned _BitInt(523)) (unsigned _BitInt(523 - 92)) -1) != 91
291 || __builtin_clrsbg ((_BitInt(523)) ~(unsigned _BitInt(523)) (unsigned _BitInt(523 - 93)) -1) != 92
292 || __builtin_ffsg ((_BitInt(523)) (((unsigned _BitInt(523)) -1) << 42)) != 43
293 || __builtin_ffsg ((_BitInt(523)) (((unsigned _BitInt(523)) -1) << 57)) != 58
294 || __builtin_ffsg ((_BitInt(523)) 0x4000000000000000000000uwb) != 87
295 || __builtin_ffsg ((_BitInt(523)) (((unsigned _BitInt(523)) -1) << 149)) != 150
296 || __builtin_ffsg ((_BitInt(523)) 2) != 2)
297 __builtin_abort ();
298 if (parity523 (14226628251091586975416900831427560438504550751597528218770815297642064445318137709184907300499591292677456563377096100346699421879373024906380724757049700104uwb) != __builtin_parityg (14226628251091586975416900831427560438504550751597528218770815297642064445318137709184907300499591292677456563377096100346699421879373024906380724757049700104uwb)
299 || parity523 (20688958227123188226117538663818621034852702121556301239818743230005799574164516085541310491875153692467123662601853835357822935286851364843928714141587045255uwb) != __builtin_parityg (20688958227123188226117538663818621034852702121556301239818743230005799574164516085541310491875153692467123662601853835357822935286851364843928714141587045255uwb)
300 || parity523 (8927708174664018648856542263215989788443763271738485875573765922613438023117960552135374015673598803453205044464280019640319125968982118836809392169156450404uwb) != __builtin_parityg (8927708174664018648856542263215989788443763271738485875573765922613438023117960552135374015673598803453205044464280019640319125968982118836809392169156450404uwb)
301 || popcount523 (27178327344587654457581274852432957423537947348354896748701960885269035920194935311522194372418922852798513401240689173265979378157685169921449935364246334672uwb) != __builtin_popcountg (27178327344587654457581274852432957423537947348354896748701960885269035920194935311522194372418922852798513401240689173265979378157685169921449935364246334672uwb)
302 || popcount523 (5307736750284212829931201546806718535860789684371772688568780952567669490917265125893664418036905110148872995350655890585853451175740907670080602411287166989uwb) != __builtin_popcountg (5307736750284212829931201546806718535860789684371772688568780952567669490917265125893664418036905110148872995350655890585853451175740907670080602411287166989uwb)
303 || popcount523 (21261096432069432668470452941790780841888331284195411465624030283325239673941548816191698556934198698768393659379577567450765073013688585051560340496749593370uwb) != __builtin_popcountg (21261096432069432668470452941790780841888331284195411465624030283325239673941548816191698556934198698768393659379577567450765073013688585051560340496749593370uwb))
304 __builtin_abort ();
305 #endif