| 1 |
/* PR target/98737 */ |
| 2 |
/* { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-* aarch64*-*-* } } */ |
| 3 |
/* { dg-options "-O2 -fdump-tree-optimized -fcompare-debug" } */ |
| 4 |
/* { dg-additional-options "-march=i686" { target ia32 } } */ |
| 5 |
/* { dg-final { scan-tree-dump-not "__atomic_\[^f]" "optimized" } } */ |
| 6 |
/* { dg-final { scan-tree-dump-not "__sync_\[^f]" "optimized" } } */ |
| 7 |
|
| 8 |
typedef signed char schar; |
| 9 |
typedef unsigned long ulong; |
| 10 |
typedef unsigned int uint; |
| 11 |
typedef unsigned short ushort; |
| 12 |
typedef unsigned char uchar; |
| 13 |
long vlong; |
| 14 |
int vint; |
| 15 |
short vshort; |
| 16 |
schar vschar; |
| 17 |
ulong vulong; |
| 18 |
uint vuint; |
| 19 |
ushort vushort; |
| 20 |
uchar vuchar; |
| 21 |
#define A(n, t, ut, f, o, ...) \ |
| 22 |
t fn##n (t x) \ |
| 23 |
{ \ |
| 24 |
ut z = f (&v##t, x, ##__VA_ARGS__); \ |
| 25 |
t w = (t) z; \ |
| 26 |
return w o x; \ |
| 27 |
} |
| 28 |
#define B(n, f, o, ...) \ |
| 29 |
A(n##0, long, ulong, f, o, ##__VA_ARGS__) \ |
| 30 |
A(n##1, int, uint, f, o, ##__VA_ARGS__) \ |
| 31 |
A(n##2, short, ushort, f, o, ##__VA_ARGS__) \ |
| 32 |
A(n##3, schar, uchar, f, o, ##__VA_ARGS__) \ |
| 33 |
A(n##4, ulong, ulong, f, o, ##__VA_ARGS__) \ |
| 34 |
A(n##5, uint, uint, f, o, ##__VA_ARGS__) \ |
| 35 |
A(n##6, ushort, ushort, f, o, ##__VA_ARGS__) \ |
| 36 |
A(n##7, uchar, uchar, f, o, ##__VA_ARGS__) |
| 37 |
|
| 38 |
B(00, __atomic_add_fetch, -, __ATOMIC_RELAXED) |
| 39 |
B(01, __atomic_sub_fetch, +, __ATOMIC_RELAXED) |
| 40 |
B(03, __atomic_xor_fetch, ^, __ATOMIC_RELAXED) |
| 41 |
B(05, __sync_add_and_fetch, -) |
| 42 |
B(06, __sync_sub_and_fetch, +) |
| 43 |
B(08, __sync_xor_and_fetch, ^) |
| 44 |
|
| 45 |
#undef A |
| 46 |
#define A(n, t, ut, f, o, ...) \ |
| 47 |
t fn##n (void) \ |
| 48 |
{ \ |
| 49 |
ut z = f (&v##t, 42, ##__VA_ARGS__); \ |
| 50 |
t w = (t) z; \ |
| 51 |
return w o 42; \ |
| 52 |
} |
| 53 |
|
| 54 |
B(10, __atomic_add_fetch, -, __ATOMIC_RELAXED) |
| 55 |
B(11, __atomic_sub_fetch, +, __ATOMIC_RELAXED) |
| 56 |
B(13, __atomic_xor_fetch, ^, __ATOMIC_RELAXED) |
| 57 |
B(15, __sync_add_and_fetch, -) |
| 58 |
B(16, __sync_sub_and_fetch, +) |
| 59 |
B(18, __sync_xor_and_fetch, ^) |
| 60 |
|
| 61 |
#undef A |
| 62 |
#define A(n, t, ut, f, o, ...) \ |
| 63 |
t fn##n (t x) \ |
| 64 |
{ \ |
| 65 |
ut z = f (&v##t, x, ##__VA_ARGS__); \ |
| 66 |
t w = (t) z; \ |
| 67 |
t v = w o x; \ |
| 68 |
return v == 0; \ |
| 69 |
} |
| 70 |
|
| 71 |
B(20, __atomic_add_fetch, -, __ATOMIC_RELAXED) |
| 72 |
B(21, __atomic_sub_fetch, +, __ATOMIC_RELAXED) |
| 73 |
B(23, __atomic_xor_fetch, ^, __ATOMIC_RELAXED) |
| 74 |
B(25, __sync_add_and_fetch, -) |
| 75 |
B(26, __sync_sub_and_fetch, +) |
| 76 |
B(28, __sync_xor_and_fetch, ^) |
| 77 |
|
| 78 |
#undef A |
| 79 |
#define A(n, t, ut, f, o, ...) \ |
| 80 |
t fn##n (void) \ |
| 81 |
{ \ |
| 82 |
ut z = f (&v##t, 42, ##__VA_ARGS__); \ |
| 83 |
t w = (t) z; \ |
| 84 |
t v = w o 42; \ |
| 85 |
return v != 0; \ |
| 86 |
} |
| 87 |
|
| 88 |
B(30, __atomic_add_fetch, -, __ATOMIC_RELAXED) |
| 89 |
B(31, __atomic_sub_fetch, +, __ATOMIC_RELAXED) |
| 90 |
B(33, __atomic_xor_fetch, ^, __ATOMIC_RELAXED) |
| 91 |
B(35, __sync_add_and_fetch, -) |
| 92 |
B(36, __sync_sub_and_fetch, +) |
| 93 |
B(38, __sync_xor_and_fetch, ^) |
| 94 |
|
| 95 |
#undef A |
| 96 |
#define A(n, t, ut, f, o, ...) \ |
| 97 |
t fn##n (t x) \ |
| 98 |
{ \ |
| 99 |
return (t) (((t) f (&v##t, x, ##__VA_ARGS__)) \ |
| 100 |
o x) != 0; \ |
| 101 |
} |
| 102 |
|
| 103 |
B(40, __atomic_add_fetch, -, __ATOMIC_RELAXED) |
| 104 |
B(41, __atomic_sub_fetch, +, __ATOMIC_RELAXED) |
| 105 |
B(43, __atomic_xor_fetch, ^, __ATOMIC_RELAXED) |
| 106 |
B(45, __sync_add_and_fetch, -) |
| 107 |
B(46, __sync_sub_and_fetch, +) |
| 108 |
B(48, __sync_xor_and_fetch, ^) |
| 109 |
|
| 110 |
#undef A |
| 111 |
#define A(n, t, ut, f, o, ...) \ |
| 112 |
t fn##n (void) \ |
| 113 |
{ \ |
| 114 |
return (t) (((t) f (&v##t, 42, ##__VA_ARGS__))\ |
| 115 |
o 42) == 0; \ |
| 116 |
} |
| 117 |
|
| 118 |
B(50, __atomic_add_fetch, -, __ATOMIC_RELAXED) |
| 119 |
B(51, __atomic_sub_fetch, +, __ATOMIC_RELAXED) |
| 120 |
B(53, __atomic_xor_fetch, ^, __ATOMIC_RELAXED) |
| 121 |
B(55, __sync_add_and_fetch, -) |
| 122 |
B(56, __sync_sub_and_fetch, +) |
| 123 |
B(58, __sync_xor_and_fetch, ^) |