libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-early-break_69.c
blob916351a14ab4c4509d9f291805ed35ebf2396639
1 /* { dg-add-options vect_early_break } */
2 /* { dg-require-effective-target vect_early_break_hw } */
3 /* { dg-require-effective-target vect_int } */
5 #include <limits.h>
6 #include <assert.h>
8 #include "tree-vect.h"
10 # define BITSIZEOF_INT 32
11 # define BITSIZEOF_LONG 64
12 # define BITSIZEOF_LONG_LONG 64
14 #define MAKE_FUNS(suffix, type) \
15 int my_ffs##suffix(type x) { \
16 int i; \
17 if (x == 0) \
18 return 0; \
19 for (i = 0; i < CHAR_BIT * sizeof (type); i++) \
20 if (x & ((type) 1 << i)) \
21 break; \
22 return i + 1; \
23 } \
25 int my_clz##suffix(type x) { \
26 int i; \
27 for (i = 0; i < CHAR_BIT * sizeof (type); i++) \
28 if (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1))) \
29 break; \
30 return i; \
34 MAKE_FUNS (, unsigned);
36 extern void abort (void);
37 extern void exit (int);
39 #define NUMS32 \
40 { \
41 0x00000000UL, \
42 0x00000001UL, \
43 0x80000000UL, \
44 0x00000002UL, \
45 0x40000000UL, \
46 0x00010000UL, \
47 0x00008000UL, \
48 0xa5a5a5a5UL, \
49 0x5a5a5a5aUL, \
50 0xcafe0000UL, \
51 0x00cafe00UL, \
52 0x0000cafeUL, \
53 0xffffffffUL \
57 unsigned int ints[] = NUMS32;
59 #define N(table) (sizeof (table) / sizeof (table[0]))
61 int
62 main (void)
64 int i;
66 check_vect ();
68 for (i = 0; i < N(ints); i++)
70 if (__builtin_ffs (ints[i]) != my_ffs (ints[i]))
71 abort ();
72 if (ints[i] != 0
73 && __builtin_clz (ints[i]) != my_clz (ints[i]))
74 abort ();
77 exit (0);
80 /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */