| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
/* PR tree-optimization/117776 */ |
| 5 |
|
| 6 |
/* These 2 functions should be optimized to just `return 1;` |
| 7 |
as `(int)(unsigned smaller)medium` is the same as |
| 8 |
`(int)medium&smaller_mask` where smaller_mask in this case is |
| 9 |
either `1` (_Bool) or `0xff` (char). */ |
| 10 |
int f(unsigned char a) |
| 11 |
{ |
| 12 |
_Bool odd = (a & 1) != 0; |
| 13 |
int odd1 = (a & 1) != 0; |
| 14 |
return odd == odd1; |
| 15 |
} |
| 16 |
int g(unsigned short a) |
| 17 |
{ |
| 18 |
unsigned char b = a; |
| 19 |
int d = b; |
| 20 |
unsigned short c = a&0xff; |
| 21 |
int e = c; |
| 22 |
return d == e; |
| 23 |
} |
| 24 |
|
| 25 |
/* { dg-final { scan-tree-dump-times "return 1" 2 "optimized" } } */ |