aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-eqbswap-1.c
blob: ed9820b0f909ec65628de32875e056203d40ab2b (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

int test1(int x, int y)
{
#if __SIZEOF_INT__ == 4
  return __builtin_bswap32(x) == __builtin_bswap32(y);
#else
  return x == y;
#endif
}

int test2(int x, int y)
{
#if __SIZEOF_INT__ == 4
  return __builtin_bswap32(x) != __builtin_bswap32(y);
#else
  return x != y;
#endif
}

int test3(int x)
{
#if __SIZEOF_INT__ == 4
  return __builtin_bswap32(x) == 12345;
#else
  return x;
#endif
}

int test4(int x)
{
#if __SIZEOF_INT__ == 4
  return __builtin_bswap32(x) != 12345;
#else
  return x;
#endif
}

int test1ll(long long x, long long y)
{
#if __SIZEOF_LONG_LONG__ == 8
  return __builtin_bswap64(x) == __builtin_bswap64(y);
#else
  return x == y;
#endif
}

int test2ll(long long x, long long y)
{
#if __SIZEOF_LONG_LONG__ == 8
  return __builtin_bswap64(x) != __builtin_bswap64(y);
#else
  return x != y;
#endif
}

int test3ll(long long x)
{
#if __SIZEOF_LONG_LONG__ == 8
  return __builtin_bswap64(x) == 12345;
#else
  return (int)x;
#endif
}

int test4ll(long long x)
{
#if __SIZEOF_LONG_LONG__ == 8
  return __builtin_bswap64(x) != 12345;
#else
  return (int)x;
#endif
}

int test1s(short x, short y)
{
#if __SIZEOF_SHORT__ == 2
  return __builtin_bswap16(x) == __builtin_bswap16(y);
#else
  return x == y;
#endif
}

int test2s(short x, short y)
{
#if __SIZEOF_SHORT__ == 2
  return __builtin_bswap16(x) != __builtin_bswap16(y);
#else
  return x != y;
#endif
}

int test3s(short x)
{
#if __SIZEOF_SHORT__ == 2
  return __builtin_bswap16(x) == 12345;
#else
  return (int)x;
#endif
}

int test4s(short x)
{
#if __SIZEOF_SHORT__ == 2
  return __builtin_bswap16(x) != 12345;
#else
  return (int)x;
#endif
}

/* { dg-final { scan-tree-dump-times "__builtin_bswap" 0 "optimized" } } */