| 1 |
/* PR tree-optimization/109906 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-O1 -fdump-tree-optimized-raw" } */ |
| 4 |
/* { dg-require-effective-target int32 } */ |
| 5 |
|
| 6 |
/* Implementation of rotate right operation */ |
| 7 |
static inline |
| 8 |
unsigned rrotate(unsigned x, int t) |
| 9 |
{ |
| 10 |
if (t >= 32) __builtin_unreachable(); |
| 11 |
unsigned tl = x >> (t); |
| 12 |
unsigned th = x << (32 - t); |
| 13 |
return tl | th; |
| 14 |
} |
| 15 |
|
| 16 |
/* Here rotate left is achieved by doing rotate right by (32 - x) */ |
| 17 |
unsigned rotateleft(unsigned t, int x) |
| 18 |
{ |
| 19 |
return rrotate (t, 32 - x); |
| 20 |
} |
| 21 |
|
| 22 |
/* Implementation of rotate left operation */ |
| 23 |
static inline |
| 24 |
unsigned lrotate(unsigned x, int t) |
| 25 |
{ |
| 26 |
if (t >= 32) __builtin_unreachable(); |
| 27 |
unsigned tl = x << (t); |
| 28 |
unsigned th = x >> (32 - t); |
| 29 |
return tl | th; |
| 30 |
} |
| 31 |
|
| 32 |
/* Here rotate right is achieved by doing rotate left by (32 - x) */ |
| 33 |
unsigned rotateright(unsigned t, int x) |
| 34 |
{ |
| 35 |
return lrotate (t, 32 - x); |
| 36 |
} |
| 37 |
|
| 38 |
/* Shouldn't have instruction for (32 - x). */ |
| 39 |
/* { dg-final { scan-tree-dump-not "minus_expr" "optimized" } } */ |
| 40 |
/* { dg-final { scan-tree-dump "rrotate_expr" "optimized" } } */ |
| 41 |
/* { dg-final { scan-tree-dump "lrotate_expr" "optimized" } } */ |