| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O -fdump-tree-ifcombine-details" } */ |
| 3 |
|
| 4 |
/* Check that tests for sign-extension bits are handled correctly. */ |
| 5 |
|
| 6 |
struct s { |
| 7 |
signed char a; |
| 8 |
signed char b; |
| 9 |
unsigned char c; |
| 10 |
unsigned char d; |
| 11 |
} __attribute__ ((aligned (4))); |
| 12 |
|
| 13 |
struct s p = { -1, 0, 0, 0 }; |
| 14 |
struct s q = { 0, -1, 0, 0 }; |
| 15 |
struct s r = { 1, 1, 0, 0 }; |
| 16 |
|
| 17 |
const long mask = 1l << (sizeof (long) * __CHAR_BIT__ - 5); |
| 18 |
|
| 19 |
int fp () |
| 20 |
{ |
| 21 |
if ((p.a & mask) |
| 22 |
|| (p.c & mask) |
| 23 |
|| p.d |
| 24 |
|| (p.b & mask)) |
| 25 |
return 1; |
| 26 |
else |
| 27 |
return -1; |
| 28 |
} |
| 29 |
|
| 30 |
int fq () |
| 31 |
{ |
| 32 |
if ((q.a & mask) |
| 33 |
|| (q.c & mask) |
| 34 |
|| q.d |
| 35 |
|| (q.b & mask)) |
| 36 |
return 1; |
| 37 |
else |
| 38 |
return -1; |
| 39 |
} |
| 40 |
|
| 41 |
int fr () |
| 42 |
{ |
| 43 |
if ((r.a & mask) |
| 44 |
|| (r.c & mask) |
| 45 |
|| r.d |
| 46 |
|| (r.b & mask)) |
| 47 |
return 1; |
| 48 |
else |
| 49 |
return -1; |
| 50 |
} |
| 51 |
|
| 52 |
int main () { |
| 53 |
if (fp () < 0 |
| 54 |
|| fq () < 0 |
| 55 |
|| fr () > 0) |
| 56 |
__builtin_abort (); |
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
/* We test .b after other fields instead of right after .a to give field |
| 61 |
merging a chance, otherwise the masked compares with zero are combined by |
| 62 |
other ifcombine logic. The .c test is discarded by earlier optimizers. */ |
| 63 |
/* { dg-final { scan-tree-dump-times "optimizing" 6 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */ |