| 1 |
/* PR tree-optimization/15826 - don't use "if" to extract a single bit |
| 2 |
bit-field */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-O2 -fdump-tree-optimized" } */ |
| 5 |
|
| 6 |
struct s { |
| 7 |
unsigned int bit : 1; |
| 8 |
}; |
| 9 |
|
| 10 |
unsigned int |
| 11 |
foo (struct s *p) |
| 12 |
{ |
| 13 |
if (p->bit) |
| 14 |
return 1; |
| 15 |
else |
| 16 |
return 0; |
| 17 |
} |
| 18 |
|
| 19 |
unsigned int |
| 20 |
bar (struct s *p) |
| 21 |
{ |
| 22 |
return (unsigned int) (p->bit); |
| 23 |
} |
| 24 |
|
| 25 |
unsigned int |
| 26 |
andrew (struct s *p) |
| 27 |
{ |
| 28 |
int i; |
| 29 |
if (p->bit) |
| 30 |
i = 1; |
| 31 |
else |
| 32 |
i = 0; |
| 33 |
return i; |
| 34 |
} |
| 35 |
|
| 36 |
/* { dg-final { scan-tree-dump-not "goto " "optimized" } } */ |