Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr53568-1.c
blob673d0a146f13b40a4d14db0584a1b361a337c9d5
1 /* Check that the bswap32 pattern is generated as swap.b and swap.w
2 instructions. */
3 /* { dg-do compile } */
4 /* { dg-options "-O2" } */
5 /* { dg-final { scan-assembler-times "swap.w" 7 } } */
6 /* { dg-final { scan-assembler-times "swap.b" 16 } } */
7 /* { dg-final { scan-assembler-times "extu.w" 2 } } */
8 /* { dg-final { scan-assembler-times "mov" 1 } } */
9 /* { dg-final { scan-assembler-not "{shll8|shlr8|shld|shad}" } } */
11 int
12 test_func_00 (int a)
14 /* 1x swap.w
15 2x swap.b */
16 return __builtin_bswap32 (a);
19 unsigned int
20 test_func_01 (unsigned int a)
22 /* 1x swap.w
23 2x swap.b */
24 return __builtin_bswap32 (a);
27 int
28 test_func_02 (int a)
30 /* 1x swap.w
31 2x swap.b */
32 return (((a >> 0) & 0xFF) << 24)
33 | (((a >> 8) & 0xFF) << 16)
34 | (((a >> 16) & 0xFF) << 8)
35 | (((a >> 24) & 0xFF) << 0);
38 unsigned int
39 test_func_03 (unsigned int a)
41 /* 1x swap.w
42 2x swap.b */
43 return (((a >> 0) & 0xFF) << 24)
44 | (((a >> 8) & 0xFF) << 16)
45 | (((a >> 16) & 0xFF) << 8)
46 | (((a >> 24) & 0xFF) << 0);
49 int
50 test_func_04 (int a)
52 /* 1x swap.b
53 1x extu.w */
54 return __builtin_bswap32 (a) >> 16;
57 unsigned short
58 test_func_05 (unsigned short a)
60 /* 1x swap.b
61 1x extu.w */
62 return __builtin_bswap32 (a) >> 16;
65 long long
66 test_func_06 (long long a)
68 /* 2x swap.w
69 4x swap.b */
70 return __builtin_bswap64 (a);
73 long long
74 test_func_07 (long long a)
76 /* 1x swap.w
77 2x swap.b
78 1x mov #0,Rn */
79 return __builtin_bswap64 (a) >> 32;