| 1 |
/* { dg-add-options vect_early_break } */ |
| 2 |
/* { dg-require-effective-target vect_early_break_hw } */ |
| 3 |
/* { dg-require-effective-target vect_int } */ |
| 4 |
|
| 5 |
#include <limits.h> |
| 6 |
#include <assert.h> |
| 7 |
|
| 8 |
#include "tree-vect.h" |
| 9 |
|
| 10 |
# define BITSIZEOF_INT 32 |
| 11 |
# define BITSIZEOF_LONG 64 |
| 12 |
# define BITSIZEOF_LONG_LONG 64 |
| 13 |
|
| 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 |
} \ |
| 24 |
\ |
| 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; \ |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
MAKE_FUNS (, unsigned); |
| 35 |
|
| 36 |
extern void abort (void); |
| 37 |
extern void exit (int); |
| 38 |
|
| 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 \ |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
unsigned int ints[] = NUMS32; |
| 58 |
|
| 59 |
#define N(table) (sizeof (table) / sizeof (table[0])) |
| 60 |
|
| 61 |
int |
| 62 |
main (void) |
| 63 |
{ |
| 64 |
int i; |
| 65 |
|
| 66 |
check_vect (); |
| 67 |
|
| 68 |
for (i = 0; i < N(ints); i++) |
| 69 |
{ |
| 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 (); |
| 75 |
} |
| 76 |
|
| 77 |
exit (0); |
| 78 |
} |
| 79 |
|
| 80 |
/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ |