| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
int test1(int x, int y) |
| 5 |
{ |
| 6 |
#if __SIZEOF_INT__ == 4 |
| 7 |
return __builtin_bswap32(x) == __builtin_bswap32(y); |
| 8 |
#else |
| 9 |
return x == y; |
| 10 |
#endif |
| 11 |
} |
| 12 |
|
| 13 |
int test2(int x, int y) |
| 14 |
{ |
| 15 |
#if __SIZEOF_INT__ == 4 |
| 16 |
return __builtin_bswap32(x) != __builtin_bswap32(y); |
| 17 |
#else |
| 18 |
return x != y; |
| 19 |
#endif |
| 20 |
} |
| 21 |
|
| 22 |
int test3(int x) |
| 23 |
{ |
| 24 |
#if __SIZEOF_INT__ == 4 |
| 25 |
return __builtin_bswap32(x) == 12345; |
| 26 |
#else |
| 27 |
return x; |
| 28 |
#endif |
| 29 |
} |
| 30 |
|
| 31 |
int test4(int x) |
| 32 |
{ |
| 33 |
#if __SIZEOF_INT__ == 4 |
| 34 |
return __builtin_bswap32(x) != 12345; |
| 35 |
#else |
| 36 |
return x; |
| 37 |
#endif |
| 38 |
} |
| 39 |
|
| 40 |
int test1ll(long long x, long long y) |
| 41 |
{ |
| 42 |
#if __SIZEOF_LONG_LONG__ == 8 |
| 43 |
return __builtin_bswap64(x) == __builtin_bswap64(y); |
| 44 |
#else |
| 45 |
return x == y; |
| 46 |
#endif |
| 47 |
} |
| 48 |
|
| 49 |
int test2ll(long long x, long long y) |
| 50 |
{ |
| 51 |
#if __SIZEOF_LONG_LONG__ == 8 |
| 52 |
return __builtin_bswap64(x) != __builtin_bswap64(y); |
| 53 |
#else |
| 54 |
return x != y; |
| 55 |
#endif |
| 56 |
} |
| 57 |
|
| 58 |
int test3ll(long long x) |
| 59 |
{ |
| 60 |
#if __SIZEOF_LONG_LONG__ == 8 |
| 61 |
return __builtin_bswap64(x) == 12345; |
| 62 |
#else |
| 63 |
return (int)x; |
| 64 |
#endif |
| 65 |
} |
| 66 |
|
| 67 |
int test4ll(long long x) |
| 68 |
{ |
| 69 |
#if __SIZEOF_LONG_LONG__ == 8 |
| 70 |
return __builtin_bswap64(x) != 12345; |
| 71 |
#else |
| 72 |
return (int)x; |
| 73 |
#endif |
| 74 |
} |
| 75 |
|
| 76 |
int test1s(short x, short y) |
| 77 |
{ |
| 78 |
#if __SIZEOF_SHORT__ == 2 |
| 79 |
return __builtin_bswap16(x) == __builtin_bswap16(y); |
| 80 |
#else |
| 81 |
return x == y; |
| 82 |
#endif |
| 83 |
} |
| 84 |
|
| 85 |
int test2s(short x, short y) |
| 86 |
{ |
| 87 |
#if __SIZEOF_SHORT__ == 2 |
| 88 |
return __builtin_bswap16(x) != __builtin_bswap16(y); |
| 89 |
#else |
| 90 |
return x != y; |
| 91 |
#endif |
| 92 |
} |
| 93 |
|
| 94 |
int test3s(short x) |
| 95 |
{ |
| 96 |
#if __SIZEOF_SHORT__ == 2 |
| 97 |
return __builtin_bswap16(x) == 12345; |
| 98 |
#else |
| 99 |
return (int)x; |
| 100 |
#endif |
| 101 |
} |
| 102 |
|
| 103 |
int test4s(short x) |
| 104 |
{ |
| 105 |
#if __SIZEOF_SHORT__ == 2 |
| 106 |
return __builtin_bswap16(x) != 12345; |
| 107 |
#else |
| 108 |
return (int)x; |
| 109 |
#endif |
| 110 |
} |
| 111 |
|
| 112 |
/* { dg-final { scan-tree-dump-times "__builtin_bswap" 0 "optimized" } } */ |
| 113 |
|