| 1 |
/* PR target/29776 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-O2 -fdump-tree-vrp1" } */ |
| 4 |
/* { dg-final { scan-tree-dump-not "link_error" "vrp1"} } */ |
| 5 |
|
| 6 |
#define A(fn, arg, min, max) \ |
| 7 |
if (__builtin_##fn (arg) < min || __builtin_##fn (arg) > max) \ |
| 8 |
link_error (); |
| 9 |
#define B(fn, min, max) \ |
| 10 |
A (fn, a, min, max) A (fn##l, b, min, max) A (fn##ll, c, min, max) |
| 11 |
#define C(fn, min, sub) \ |
| 12 |
A (fn, a, min, ((int) sizeof (a) * __CHAR_BIT__ - sub)) \ |
| 13 |
A (fn##l, b, min, ((int) sizeof (b) * __CHAR_BIT__ - sub)) \ |
| 14 |
A (fn##ll, c, min, ((int) sizeof (c) * __CHAR_BIT__ - sub)) |
| 15 |
#define D(fn, sub1, sub2) \ |
| 16 |
A (fn, a, ((int) sizeof (a) * __CHAR_BIT__ - sub1), \ |
| 17 |
((int) sizeof (a) * __CHAR_BIT__ - sub2)) \ |
| 18 |
A (fn##l, b, ((int) sizeof (b) * __CHAR_BIT__ - sub1), \ |
| 19 |
((int) sizeof (b) * __CHAR_BIT__ - sub2)) \ |
| 20 |
A (fn##ll, c, ((int) sizeof (c) * __CHAR_BIT__ - sub1), \ |
| 21 |
((int) sizeof (c) * __CHAR_BIT__ - sub2)) |
| 22 |
|
| 23 |
extern void link_error (void); |
| 24 |
|
| 25 |
unsigned int d; |
| 26 |
unsigned long e; |
| 27 |
unsigned long long f; |
| 28 |
|
| 29 |
void |
| 30 |
foo (unsigned int a, unsigned long b, unsigned long long c) |
| 31 |
{ |
| 32 |
B (parity, 0, 1) |
| 33 |
C (ffs, 0, 0) |
| 34 |
C (popcount, 0, 0) |
| 35 |
C (clz, 0, 0) |
| 36 |
C (ctz, -1, 0) |
| 37 |
a &= 63; |
| 38 |
b &= 63; |
| 39 |
c &= 63; |
| 40 |
B (ffs, 0, 6) |
| 41 |
B (popcount, 0, 6) |
| 42 |
a += 3; b += 3; c += 3; |
| 43 |
B (ffs, 1, 7) |
| 44 |
B (popcount, 1, 7) |
| 45 |
a = 32U + (d & 1023U); |
| 46 |
b = 32UL + (e & 1023UL); |
| 47 |
c = 32ULL + (f & 1023ULL); |
| 48 |
D (clz, 11, 6) |
| 49 |
B (ctz, 0, 10) |
| 50 |
} |
| 51 |
|
| 52 |
void |
| 53 |
bar (int a, long b, long long c) |
| 54 |
{ |
| 55 |
C (clrsb, 0, 1) |
| 56 |
} |