Use conditional internal functions in if-conversion
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / quad-atomic.c
blobe5824c2a92fc8febae86049f5c1da277dd3e89aa
1 /* { dg-do run { target { powerpc*-*-linux* && lp64 } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-skip-if "" { powerpc*-*-*spe* } } */
4 /* { dg-require-effective-target p8vector_hw } */
5 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
6 /* { dg-options "-mcpu=power8 -O2 -Wno-shift-overflow" } */
8 /* Test whether we get the right bits for quad word atomic instructions. */
9 #include <stdlib.h>
11 static __int128_t quad_fetch_and (__int128_t *, __int128_t value) __attribute__((__noinline__));
12 static __int128_t quad_fetch_or (__int128_t *, __int128_t value) __attribute__((__noinline__));
13 static __int128_t quad_fetch_add (__int128_t *, __int128_t value) __attribute__((__noinline__));
15 static __int128_t
16 quad_fetch_and (__int128_t *ptr, __int128_t value)
18 return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
21 static __int128_t
22 quad_fetch_or (__int128_t *ptr, __int128_t value)
24 return __atomic_fetch_or (ptr, value, __ATOMIC_ACQUIRE);
27 static __int128_t
28 quad_fetch_add (__int128_t *ptr, __int128_t value)
30 return __atomic_fetch_add (ptr, value, __ATOMIC_ACQUIRE);
33 int
34 main (void)
36 __int128_t result;
37 __int128_t value;
38 __int128_t and_input = ((((__int128_t) 0x1234567890abcdefULL) << 64) | ((__int128_t) 0xfedcba0987654321ULL));
39 __int128_t and_value = ((((__int128_t) 0xfffffffffffffff0ULL) << 64) | ((__int128_t) 0xfffffffffffffff0ULL));
40 __int128_t and_exp = ((((__int128_t) 0x1234567890abcde0ULL) << 64) | ((__int128_t) 0xfedcba0987654320ULL));
42 __int128_t or_input = ((((__int128_t) 0x1234567890abcdefULL) << 64) | ((__int128_t) 0xfedcba0987654321ULL));
43 __int128_t or_value = ((((__int128_t) 0x0000000000000010ULL) << 64) | ((__int128_t) 0x000000000000000eULL));
44 __int128_t or_exp = ((((__int128_t) 0x1234567890abcdffULL) << 64) | ((__int128_t) 0xfedcba098765432fULL));
46 __int128_t add_input = ((((__int128_t) 0x1234567890abcdefULL) << 64) | ((__int128_t) 0xfedcba0987654321ULL));
47 __int128_t add_value = ((((__int128_t) 0x0000000001000000ULL) << 64) | ((__int128_t) 0x0000001000000000ULL));
48 __int128_t add_exp = ((((__int128_t) 0x1234567891abcdefULL) << 64) | ((__int128_t) 0xfedcba1987654321ULL));
51 value = and_input;
52 result = quad_fetch_and (&value, and_value);
53 if (result != and_input || value != and_exp)
54 abort ();
56 value = or_input;
57 result = quad_fetch_or (&value, or_value);
58 if (result != or_input || value != or_exp)
59 abort ();
61 value = add_input;
62 result = quad_fetch_add (&value, add_value);
63 if (result != add_input || value != add_exp)
64 abort ();
66 return 0;