| 1 |
/* { dg-options "-O2 -fdump-tree-optimized-raw" } */ |
| 2 |
|
| 3 |
unsigned int |
| 4 |
f1 (unsigned int x) |
| 5 |
{ |
| 6 |
if (x & 3) |
| 7 |
__builtin_unreachable (); |
| 8 |
x >>= 2; |
| 9 |
return x << 3; |
| 10 |
} |
| 11 |
|
| 12 |
unsigned int |
| 13 |
f2 (unsigned int x) |
| 14 |
{ |
| 15 |
if (x & 3) |
| 16 |
__builtin_unreachable (); |
| 17 |
unsigned char y = x; |
| 18 |
y >>= 2; |
| 19 |
return y << 3; |
| 20 |
} |
| 21 |
|
| 22 |
unsigned long |
| 23 |
f3 (unsigned int x) |
| 24 |
{ |
| 25 |
if (x & 3) |
| 26 |
__builtin_unreachable (); |
| 27 |
x >>= 2; |
| 28 |
return (unsigned long) x << 3; |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
f4 (int x) |
| 33 |
{ |
| 34 |
if (x & 15) |
| 35 |
__builtin_unreachable (); |
| 36 |
x >>= 4; |
| 37 |
return x << 5; |
| 38 |
} |
| 39 |
|
| 40 |
unsigned int |
| 41 |
f5 (int x) |
| 42 |
{ |
| 43 |
if (x & 31) |
| 44 |
__builtin_unreachable (); |
| 45 |
x >>= 5; |
| 46 |
return x << 6; |
| 47 |
} |
| 48 |
|
| 49 |
unsigned int |
| 50 |
f6 (unsigned int x) |
| 51 |
{ |
| 52 |
if (x & 1) |
| 53 |
__builtin_unreachable (); |
| 54 |
x >>= 1; |
| 55 |
return x << (sizeof (int) * __CHAR_BIT__ - 1); |
| 56 |
} |
| 57 |
|
| 58 |
/* { dg-final { scan-tree-dump-not {<[a-z]*_div_expr,} "optimized" } } */ |
| 59 |
/* { dg-final { scan-tree-dump-not {<rshift_expr,} "optimized" } } */ |
| 60 |
/* { dg-final { scan-tree-dump-times {<lshift_expr, [^,]*, [^,]*, 1,} 5 "optimized" } } */ |
| 61 |
/* { dg-final { scan-tree-dump {<lshift_expr, [^,]*, [^,]*, 30,} "optimized" { target int32 } } } */ |