| 1 |
/* Check that shifts do not get unnecessary extends. |
| 2 |
See PR66706 for a case where this failed. */ |
| 3 |
|
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-O2" } */ |
| 6 |
|
| 7 |
/* Each function should compile to exactly two instructions. */ |
| 8 |
/* { dg-final { scan-assembler-times {(?n)^\s+[a-z]} 16 } } */ |
| 9 |
/* { dg-final { scan-assembler-times {(?n)^\s+blr} 8 } } */ |
| 10 |
|
| 11 |
|
| 12 |
typedef unsigned u; |
| 13 |
typedef signed s; |
| 14 |
|
| 15 |
u rot(u x, u n) { return (x << n) | (x >> (32 - n)); } |
| 16 |
u shl(u x, u n) { return x << n; } |
| 17 |
u shr(u x, u n) { return x >> n; } |
| 18 |
s asr(s x, u n) { return x >> n; } |
| 19 |
|
| 20 |
u roti(u x) { return (x << 23) | (x >> 9); } |
| 21 |
u shli(u x) { return x << 23; } |
| 22 |
u shri(u x) { return x >> 23; } |
| 23 |
s asri(s x) { return x >> 23; } |