blob: 784295ce6890f59720acd2a2e1115ff3cbe1394c [file] [log] [blame]
Eli Friedmanc83b9752011-09-07 01:41:24 +00001// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
Eric Christopher3883e662011-07-26 22:17:02 +00002
3int* foo(int** a, int* b, int* c) {
4return __sync_val_compare_and_swap (a, b, c);
5}
Eli Friedmanc83b9752011-09-07 01:41:24 +00006// CHECK: define i32* @foo
7// CHECK: cmpxchg
Eric Christopher3883e662011-07-26 22:17:02 +00008
9int foo2(int** a, int* b, int* c) {
10return __sync_bool_compare_and_swap (a, b, c);
11}
Eli Friedmanc83b9752011-09-07 01:41:24 +000012// CHECK: define i32 @foo2
13// CHECK: cmpxchg
Eric Christopher3883e662011-07-26 22:17:02 +000014
15int* foo3(int** a, int b) {
16 return __sync_fetch_and_add (a, b);
17}
Eli Friedmanc83b9752011-09-07 01:41:24 +000018// CHECK: define i32* @foo3
19// CHECK: atomicrmw add
20
Eric Christopher3883e662011-07-26 22:17:02 +000021
22int* foo4(int** a, int b) {
23 return __sync_fetch_and_sub (a, b);
24}
Eli Friedmanc83b9752011-09-07 01:41:24 +000025// CHECK: define i32* @foo4
26// CHECK: atomicrmw sub
27
Eric Christopher3883e662011-07-26 22:17:02 +000028
29int* foo5(int** a, int* b) {
30 return __sync_lock_test_and_set (a, b);
31}
Eli Friedmanc83b9752011-09-07 01:41:24 +000032// CHECK: define i32* @foo5
33// CHECK: atomicrmw xchg
34
Eric Christopher3883e662011-07-26 22:17:02 +000035
36int* foo6(int** a, int*** b) {
37 return __sync_lock_test_and_set (a, b);
38}
Eli Friedmanc83b9752011-09-07 01:41:24 +000039// CHECK: define i32* @foo6
40// CHECK: atomicrmw xchg