PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / ia64-sync-3.c
blobad2716943abfdc76bfd49f7f6e72eeb507a7e9e0
1 /* { dg-do run } */
2 /* { dg-require-effective-target sync_int_long } */
3 /* { dg-options } */
4 /* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
5 /* { dg-options "-mcpu=v9" { target sparc*-*-* } } */
7 /* Test basic functionality of the intrinsics. */
9 __extension__ typedef __SIZE_TYPE__ size_t;
11 extern void abort (void);
12 extern void *memcpy (void *, const void *, size_t);
13 extern int memcmp (const void *, const void *, size_t);
15 static int AI[4];
16 static int init_si[4] = { -30,-30,-50,-50 };
17 static int test_si[4] = { -115,-115,25,25 };
19 static void
20 do_si (void)
22 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -30)
23 abort ();
24 if (__sync_val_compare_and_swap(AI+0, -30, -115) != -115)
25 abort ();
26 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 1)
27 abort ();
28 if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 0)
29 abort ();
31 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != -50)
32 abort ();
33 if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != 25)
34 abort ();
35 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
36 abort ();
37 if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1)
38 abort ();
41 static long AL[4];
42 static long init_di[4] = { -30,-30,-50,-50 };
43 static long test_di[4] = { -115,-115,25,25 };
45 static void
46 do_di (void)
48 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -30)
49 abort ();
50 if (__sync_val_compare_and_swap(AL+0, -30, -115) != -115)
51 abort ();
52 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 1)
53 abort ();
54 if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 0)
55 abort ();
57 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != -50)
58 abort ();
59 if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != 25)
60 abort ();
61 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
62 abort ();
63 if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1)
64 abort ();
67 int main()
69 memcpy(AI, init_si, sizeof(init_si));
70 memcpy(AL, init_di, sizeof(init_di));
72 do_si ();
73 do_di ();
75 if (memcmp (AI, test_si, sizeof(test_si)))
76 abort ();
77 if (memcmp (AL, test_di, sizeof(test_di)))
78 abort ();
80 return 0;