| 1 |
/* { dg-do compile { target { ! riscv_abi_e } } } */ |
| 2 |
/* { dg-options "-march=rv32gc_xtheadbb" { target { rv32 } } } */ |
| 3 |
/* { dg-options "-march=rv64gc_xtheadbb" { target { rv64 } } } */ |
| 4 |
/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Og" } } */ |
| 5 |
|
| 6 |
unsigned int |
| 7 |
foo32 (unsigned int x) |
| 8 |
{ |
| 9 |
return (((x << 24) & 0xff000000) |
| 10 |
| ((x << 8) & 0xff0000) |
| 11 |
| ((x >> 8) & 0xff00) |
| 12 |
| ((x >> 24) & 0xff)); |
| 13 |
} |
| 14 |
|
| 15 |
unsigned int |
| 16 |
foo32_1 (unsigned int x) |
| 17 |
{ |
| 18 |
return __builtin_bswap32 (x); |
| 19 |
} |
| 20 |
|
| 21 |
#if __riscv_xlen == 64 |
| 22 |
unsigned long |
| 23 |
foo64 (unsigned long x) |
| 24 |
{ |
| 25 |
return (((x << 56) & 0xff00000000000000ull) |
| 26 |
| ((x << 40) & 0xff000000000000ull) |
| 27 |
| ((x << 24) & 0xff0000000000ull) |
| 28 |
| ((x << 8) & 0xff00000000ull) |
| 29 |
| ((x >> 8) & 0xff000000) |
| 30 |
| ((x >> 24) & 0xff0000) |
| 31 |
| ((x >> 40) & 0xff00) |
| 32 |
| ((x >> 56) & 0xff)); |
| 33 |
} |
| 34 |
|
| 35 |
unsigned long |
| 36 |
foo64_1 (unsigned long x) |
| 37 |
{ |
| 38 |
return __builtin_bswap64 (x); |
| 39 |
} |
| 40 |
#endif |
| 41 |
|
| 42 |
/* { dg-final { scan-assembler-times "th.rev\t" 2 { target { rv32 } } } } */ |
| 43 |
|
| 44 |
/* { dg-final { scan-assembler-times "th.revw\t" 2 { target { rv64 } } } } */ |
| 45 |
/* { dg-final { scan-assembler-times "th.rev\t" 2 { target { rv64 } } } } */ |