blob: 1c869b3067a6992cfb58f2b1a20e4649d2ded184 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/* { dg-options "-O2" } */
/* { dg-do run } */
extern void abort (void);
typedef unsigned int __u32;
__u32
__rev16_32_alt (__u32 x)
{
return (((__u32)(x) & (__u32)0xff00ff00UL) >> 8)
| (((__u32)(x) & (__u32)0x00ff00ffUL) << 8);
}
__u32
__rev16_32 (__u32 x)
{
return (((__u32)(x) & (__u32)0x00ff00ffUL) << 8)
| (((__u32)(x) & (__u32)0xff00ff00UL) >> 8);
}
int
main (void)
{
volatile __u32 in32 = 0x12345678;
volatile __u32 expected32 = 0x34127856;
if (__rev16_32 (in32) != expected32)
abort ();
if (__rev16_32_alt (in32) != expected32)
abort ();
return 0;
}
|