blob: 4df94829f572ed37edc3ac01b412d98172073b37 [file] [log] [blame]
Nuno Lopes729e6a02012-05-09 21:21:49 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s
Eric Christopher85e51562011-07-26 22:17:02 +00002
3int* foo(int** a, int* b, int* c) {
4return __sync_val_compare_and_swap (a, b, c);
5}
Stephen Lin43622612013-08-15 06:47:53 +00006// CHECK-LABEL: define i32* @foo
Eli Friedmane9f81132011-09-07 01:41:24 +00007// CHECK: cmpxchg
Eric Christopher85e51562011-07-26 22:17:02 +00008
9int foo2(int** a, int* b, int* c) {
10return __sync_bool_compare_and_swap (a, b, c);
11}
Stephen Lin43622612013-08-15 06:47:53 +000012// CHECK-LABEL: define i32 @foo2
Eli Friedmane9f81132011-09-07 01:41:24 +000013// CHECK: cmpxchg
Eric Christopher85e51562011-07-26 22:17:02 +000014
15int* foo3(int** a, int b) {
16 return __sync_fetch_and_add (a, b);
17}
Stephen Lin43622612013-08-15 06:47:53 +000018// CHECK-LABEL: define i32* @foo3
Eli Friedmane9f81132011-09-07 01:41:24 +000019// CHECK: atomicrmw add
20
Eric Christopher85e51562011-07-26 22:17:02 +000021
22int* foo4(int** a, int b) {
23 return __sync_fetch_and_sub (a, b);
24}
Stephen Lin43622612013-08-15 06:47:53 +000025// CHECK-LABEL: define i32* @foo4
Eli Friedmane9f81132011-09-07 01:41:24 +000026// CHECK: atomicrmw sub
27
Eric Christopher85e51562011-07-26 22:17:02 +000028
29int* foo5(int** a, int* b) {
30 return __sync_lock_test_and_set (a, b);
31}
Stephen Lin43622612013-08-15 06:47:53 +000032// CHECK-LABEL: define i32* @foo5
Eli Friedmane9f81132011-09-07 01:41:24 +000033// CHECK: atomicrmw xchg
34
Eric Christopher85e51562011-07-26 22:17:02 +000035
36int* foo6(int** a, int*** b) {
37 return __sync_lock_test_and_set (a, b);
38}
Stephen Lin43622612013-08-15 06:47:53 +000039// CHECK-LABEL: define i32* @foo6
Eli Friedmane9f81132011-09-07 01:41:24 +000040// CHECK: atomicrmw xchg