| 1 |
/* Check that record-form instructions are used. */ |
| 2 |
|
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-O2" } */ |
| 5 |
|
| 6 |
/* { dg-final { scan-assembler-times {\mrotl[wd]\.} 2 } } */ |
| 7 |
/* { dg-final { scan-assembler-times {\msl[wd]\.} 2 } } */ |
| 8 |
/* { dg-final { scan-assembler-times {\msr[wd]\.} 2 } } */ |
| 9 |
/* { dg-final { scan-assembler-times {\msra[wd]\.} 2 } } */ |
| 10 |
|
| 11 |
/* { dg-final { scan-assembler-times {\mrotl[wd]i\.} 2 } } */ |
| 12 |
/* { dg-final { scan-assembler-times {\msl[wd]i\.} 2 } } */ |
| 13 |
/* { dg-final { scan-assembler-times {\msr[wd]i\.} 2 } } */ |
| 14 |
/* Combine converts the arith shift right compares to a (more expensive) |
| 15 |
direct compare. Luckily not the other shifts. XFAIL for now. */ |
| 16 |
/* { dg-final { scan-assembler-times {\msra[wd]i\.} 2 { xfail *-*-* } } } */ |
| 17 |
|
| 18 |
/* There should not be any extends of the shift amount (or anything else). */ |
| 19 |
/* { dg-final { scan-assembler-not {\mextsw\M} } } */ |
| 20 |
/* { dg-final { scan-assembler-not {\mrldicl\M} } } */ |
| 21 |
/* { dg-final { scan-assembler-not {\mclrldi\M} } } */ |
| 22 |
/* { dg-final { scan-assembler-not {\mrlwinm\M} } } */ |
| 23 |
|
| 24 |
|
| 25 |
typedef unsigned long u; |
| 26 |
typedef long s; |
| 27 |
#define M(n) (8 * sizeof(long) - (n)) |
| 28 |
#define T1 if ((s)x > 0) g(); |
| 29 |
#define T2 if ((s)x > 0) g(); return x; |
| 30 |
|
| 31 |
void g(void); |
| 32 |
|
| 33 |
void rot1(u x, u n) { x = (x << M(n)) | (x >> n); T1 } |
| 34 |
u rot2(u x, u n) { x = (x << M(n)) | (x >> n); T2 } |
| 35 |
void shl1(u x, u n) { x <<= n; T1 } |
| 36 |
u shl2(u x, u n) { x <<= n; T2 } |
| 37 |
void shr1(u x, u n) { x >>= n; T1 } |
| 38 |
u shr2(u x, u n) { x >>= n; T2 } |
| 39 |
void asr1(s x, u n) { x >>= n; T1 } |
| 40 |
s asr2(s x, u n) { x >>= n; T2 } |
| 41 |
|
| 42 |
void rot1i(u x) { x = (x << M(23)) | (x >> 23); T1 } |
| 43 |
u rot2i(u x) { x = (x << M(23)) | (x >> 23); T2 } |
| 44 |
void shl1i(u x) { x <<= 23; T1 } |
| 45 |
u shl2i(u x) { x <<= 23; T2 } |
| 46 |
void shr1i(u x) { x >>= 23; T1 } |
| 47 |
u shr2i(u x) { x >>= 23; T2 } |
| 48 |
void asr1i(s x) { x >>= 23; T1 } |
| 49 |
s asr2i(s x) { x >>= 23; T2 } |