| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O1" } */ |
| 3 |
|
| 4 |
/* tree-optimization/118409 */ |
| 5 |
|
| 6 |
/* Check that tests involving a sign bit of a storage unit are handled |
| 7 |
correctly. The compares are turned into xor tests by earlier passes, and |
| 8 |
ifcombine has to propagate the sign bit mask to the right hand of the |
| 9 |
compare extracted from the xor, otherwise we'll retain unwanted bits for the |
| 10 |
compare. */ |
| 11 |
|
| 12 |
typedef struct { |
| 13 |
int p : __CHAR_BIT__; |
| 14 |
int d : 1; |
| 15 |
int b : __CHAR_BIT__ - 2; |
| 16 |
int e : 1; |
| 17 |
} g; |
| 18 |
|
| 19 |
g a = {.d = 1, .e = 1}, c = {.b = 1, .d = 1, .e = 1}; |
| 20 |
|
| 21 |
__attribute__((noipa)) |
| 22 |
int f1 () |
| 23 |
{ |
| 24 |
if (a.d == c.d |
| 25 |
&& a.e == c.e) |
| 26 |
return 0; |
| 27 |
return -1; |
| 28 |
} |
| 29 |
|
| 30 |
__attribute__((noipa)) |
| 31 |
int f2 () |
| 32 |
{ |
| 33 |
if (a.d != c.d |
| 34 |
|| a.e != c.e) |
| 35 |
return -1; |
| 36 |
return 0; |
| 37 |
} |
| 38 |
|
| 39 |
__attribute__((noipa)) |
| 40 |
int f3 () |
| 41 |
{ |
| 42 |
if (c.d == a.d |
| 43 |
&& c.e == a.e) |
| 44 |
return 0; |
| 45 |
return -1; |
| 46 |
} |
| 47 |
|
| 48 |
__attribute__((noipa)) |
| 49 |
int f4 () |
| 50 |
{ |
| 51 |
if (c.d != a.d |
| 52 |
|| c.e != a.e) |
| 53 |
return -1; |
| 54 |
return 0; |
| 55 |
} |
| 56 |
|
| 57 |
int main() { |
| 58 |
if (f1 () < 0 |
| 59 |
|| f2 () < 0 |
| 60 |
|| f3 () < 0 |
| 61 |
|| f4 () < 0) |
| 62 |
__builtin_abort(); |
| 63 |
return 0; |
| 64 |
} |