libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-early-break_74.c
blobafd238618b30ed905ca2f790bc94d019d7bf8019
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-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */
7 #include <limits.h>
8 #include <assert.h>
10 #include "tree-vect.h"
12 #if __INT_MAX__ > 2147483647L
13 # if __INT_MAX__ >= 9223372036854775807L
14 # define BITSIZEOF_INT 64
15 # else
16 # define BITSIZEOF_INT 32
17 # endif
18 #else
19 # if __INT_MAX__ >= 2147483647L
20 # define BITSIZEOF_INT 32
21 # else
22 # define BITSIZEOF_INT 16
23 # endif
24 #endif
26 #if __LONG_MAX__ > 2147483647L
27 # if __LONG_MAX__ >= 9223372036854775807L
28 # define BITSIZEOF_LONG 64
29 # else
30 # define BITSIZEOF_LONG 32
31 # endif
32 #else
33 # define BITSIZEOF_LONG 32
34 #endif
36 #if __LONG_LONG_MAX__ > 2147483647L
37 # if __LONG_LONG_MAX__ >= 9223372036854775807L
38 # define BITSIZEOF_LONG_LONG 64
39 # else
40 # define BITSIZEOF_LONG_LONG 32
41 # endif
42 #else
43 # define BITSIZEOF_LONG_LONG 32
44 #endif
46 #define MAKE_FUNS(suffix, type) \
47 int my_clrsb##suffix(type x) { \
48 int i; \
49 int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1; \
50 for (i = 1; i < CHAR_BIT * sizeof (type); i++) \
51 if (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1) \
52 != leading) \
53 break; \
54 return i - 1; \
57 MAKE_FUNS (, unsigned);
59 extern void abort (void);
60 extern void exit (int);
62 #define NUMS16 \
63 { \
64 0x0000U, \
65 0x0001U, \
66 0x8000U, \
67 0x0002U, \
68 0x4000U, \
69 0x0100U, \
70 0x0080U, \
71 0xa5a5U, \
72 0x5a5aU, \
73 0xcafeU, \
74 0xffffU \
77 #define NUMS32 \
78 { \
79 0x00000000UL, \
80 0x00000001UL, \
81 0x80000000UL, \
82 0x00000002UL, \
83 0x40000000UL, \
84 0x00010000UL, \
85 0x00008000UL, \
86 0xa5a5a5a5UL, \
87 0x5a5a5a5aUL, \
88 0xcafe0000UL, \
89 0x00cafe00UL, \
90 0x0000cafeUL, \
91 0xffffffffUL \
94 #define NUMS64 \
95 { \
96 0x0000000000000000ULL, \
97 0x0000000000000001ULL, \
98 0x8000000000000000ULL, \
99 0x0000000000000002ULL, \
100 0x4000000000000000ULL, \
101 0x0000000100000000ULL, \
102 0x0000000080000000ULL, \
103 0xa5a5a5a5a5a5a5a5ULL, \
104 0x5a5a5a5a5a5a5a5aULL, \
105 0xcafecafe00000000ULL, \
106 0x0000cafecafe0000ULL, \
107 0x00000000cafecafeULL, \
108 0xffffffffffffffffULL \
111 unsigned int ints[] =
112 #if BITSIZEOF_INT == 64
113 NUMS64;
114 #elif BITSIZEOF_INT == 32
115 NUMS32;
116 #else
117 NUMS16;
118 #endif
120 unsigned long longs[] =
121 #if BITSIZEOF_LONG == 64
122 NUMS64;
123 #else
124 NUMS32;
125 #endif
127 unsigned long long longlongs[] =
128 #if BITSIZEOF_LONG_LONG == 64
129 NUMS64;
130 #else
131 NUMS32;
132 #endif
134 #define N(table) (sizeof (table) / sizeof (table[0]))
137 main (void)
139 int i;
141 check_vect ();
143 /* Test constant folding. */
145 #define TEST(x, suffix) \
146 if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x)) \
147 abort ();
149 #if BITSIZEOF_INT == 32
150 TEST(0x00000000UL,);
151 TEST(0x00000001UL,);
152 TEST(0x80000000UL,);
153 TEST(0x40000000UL,);
154 TEST(0x00010000UL,);
155 TEST(0x00008000UL,);
156 TEST(0xa5a5a5a5UL,);
157 TEST(0x5a5a5a5aUL,);
158 TEST(0xcafe0000UL,);
159 TEST(0x00cafe00UL,);
160 TEST(0x0000cafeUL,);
161 TEST(0xffffffffUL,);
162 #endif
164 exit (0);