OSDN Git Service

* gcc.dg/tree-ssa/inline-4.c: Bind pic locally.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / optimize-bswapsi-1.c
1 /* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */
2 /* { dg-require-effective-target stdint_types } */
3 /* { dg-options "-O2 -fdump-tree-bswap" } */
4
5 #include <stdint.h>
6
7 #define __const_swab32(x) ((uint32_t)(                                \
8         (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |            \
9         (((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |            \
10         (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) |            \
11         (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
12
13 /* This byte swap implementation is used by the Linux kernel and the
14    GNU C library.  */
15
16 uint32_t
17 swap32_a (uint32_t in)
18 {
19   return __const_swab32 (in);
20 }
21
22 /* The OpenSSH byte swap implementation.  */
23 uint32_t
24 swap32_b (uint32_t in)
25 {
26   uint32_t a;
27
28   a = (in << 16) | (in >> 16);
29   a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
30
31   return a;
32 }
33
34 /* This variant is currently used by libgcc.  The difference is that
35    the bswap source and destination have a signed integer type which
36    requires a slightly higher search depth in order to dive through
37    the cast as well.  */
38
39 typedef int SItype __attribute__ ((mode (SI)));
40
41 SItype
42 swap32_c (SItype u)
43 {
44   return ((((u) & 0xff000000) >> 24)
45           | (((u) & 0x00ff0000) >>  8)
46           | (((u) & 0x0000ff00) <<  8)
47           | (((u) & 0x000000ff) << 24));
48 }
49
50 /* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 3 "bswap" } } */
51 /* { dg-final { cleanup-tree-dump "bswap" } } */