libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-early-break_76.c
bloba7d8e279c67008bf4e35c802ab48f1b373827392
1 /* { dg-add-options vect_early_break } */
2 /* { dg-require-effective-target vect_early_break_hw } */
3 /* { dg-require-effective-target vect_int } */
5 /* { dg-additional-options "-O3" } */
6 /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */
8 #include <limits.h>
9 #include <assert.h>
11 #include "tree-vect.h"
13 #if __INT_MAX__ > 2147483647L
14 # if __INT_MAX__ >= 9223372036854775807L
15 # define BITSIZEOF_INT 64
16 # else
17 # define BITSIZEOF_INT 32
18 # endif
19 #else
20 # if __INT_MAX__ >= 2147483647L
21 # define BITSIZEOF_INT 32
22 # else
23 # define BITSIZEOF_INT 16
24 # endif
25 #endif
27 #if __LONG_MAX__ > 2147483647L
28 # if __LONG_MAX__ >= 9223372036854775807L
29 # define BITSIZEOF_LONG 64
30 # else
31 # define BITSIZEOF_LONG 32
32 # endif
33 #else
34 # define BITSIZEOF_LONG 32
35 #endif
37 #if __LONG_LONG_MAX__ > 2147483647L
38 # if __LONG_LONG_MAX__ >= 9223372036854775807L
39 # define BITSIZEOF_LONG_LONG 64
40 # else
41 # define BITSIZEOF_LONG_LONG 32
42 # endif
43 #else
44 # define BITSIZEOF_LONG_LONG 32
45 #endif
47 #define MAKE_FUNS(suffix, type) \
48 int my_clrsb##suffix(type x) { \
49 int i; \
50 int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1; \
51 for (i = 1; i < CHAR_BIT * sizeof (type); i++) \
52 if (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1) \
53 != leading) \
54 break; \
55 return i - 1; \
56 } \
59 MAKE_FUNS (, unsigned);
60 MAKE_FUNS (ll, unsigned long long);
62 extern void abort (void);
63 extern void exit (int);
65 #define NUMS16 \
66 { \
67 0x0000U, \
68 0x0001U, \
69 0x8000U, \
70 0x0002U, \
71 0x4000U, \
72 0x0100U, \
73 0x0080U, \
74 0xa5a5U, \
75 0x5a5aU, \
76 0xcafeU, \
77 0xffffU \
80 #define NUMS32 \
81 { \
82 0x00000000UL, \
83 0x00000001UL, \
84 0x80000000UL, \
85 0x00000002UL, \
86 0x40000000UL, \
87 0x00010000UL, \
88 0x00008000UL, \
89 0xa5a5a5a5UL, \
90 0x5a5a5a5aUL, \
91 0xcafe0000UL, \
92 0x00cafe00UL, \
93 0x0000cafeUL, \
94 0xffffffffUL \
97 #define NUMS64 \
98 { \
99 0x0000000000000000ULL, \
100 0x0000000000000001ULL, \
101 0x8000000000000000ULL, \
102 0x0000000000000002ULL, \
103 0x4000000000000000ULL, \
104 0x0000000100000000ULL, \
105 0x0000000080000000ULL, \
106 0xa5a5a5a5a5a5a5a5ULL, \
107 0x5a5a5a5a5a5a5a5aULL, \
108 0xcafecafe00000000ULL, \
109 0x0000cafecafe0000ULL, \
110 0x00000000cafecafeULL, \
111 0xffffffffffffffffULL \
114 unsigned int ints[] =
115 #if BITSIZEOF_INT == 64
116 NUMS64;
117 #elif BITSIZEOF_INT == 32
118 NUMS32;
119 #else
120 NUMS16;
121 #endif
123 unsigned long longs[] =
124 #if BITSIZEOF_LONG == 64
125 NUMS64;
126 #else
127 NUMS32;
128 #endif
130 unsigned long long longlongs[] =
131 #if BITSIZEOF_LONG_LONG == 64
132 NUMS64;
133 #else
134 NUMS32;
135 #endif
137 #define N(table) (sizeof (table) / sizeof (table[0]))
140 main (void)
142 int i;
144 check_vect ();
146 #pragma GCC novector
147 for (i = 0; i < N(ints); i++)
149 if (__builtin_clrsb (ints[i]) != my_clrsb (ints[i]))
150 abort ();
153 /* Test constant folding. */
155 #define TEST(x, suffix) \
156 if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x)) \
157 abort ();
159 #if BITSIZEOF_LONG_LONG == 64
160 TEST(0xffffffffffffffffULL, ll);
161 TEST(0xffffffffffffffffULL, ll);
162 TEST(0xffffffffffffffffULL, ll);
163 TEST(0xffffffffffffffffULL, ll);
164 TEST(0xffffffffffffffffULL, ll);
165 TEST(0xffffffffffffffffULL, ll);
166 #endif
168 exit (0);