blob: a80d4666cbf400b9946410a16520aca39aa7a860 [file] [log] [blame]
Mon P Wangbf020f32008-05-09 22:40:52 +00001// RUN: clang %s -emit-llvm -o - > %t1
2// RUN: grep @llvm.atomic.las.i32 %t1
3// RUN: grep @llvm.atomic.lss.i32 %t1
4// RUN: grep @llvm.atomic.load.min.i32 %t1
5// RUN: grep @llvm.atomic.load.max.i32 %t1
6// RUN: grep @llvm.atomic.load.umin.i32 %t1
7// RUN: grep @llvm.atomic.load.umax.i32 %t1
8// RUN: grep @llvm.atomic.swap.i32 %t1
9// RUN: grep @llvm.atomic.lcs.i32 %t1
10// RUN: grep @llvm.atomic.load.and.i32 %t1
11// RUN: grep @llvm.atomic.load.or.i32 %t1
12// RUN: grep @llvm.atomic.load.xor.i32 %t1
13
14
15int atomic(void)
16{
17 // nonsenical test for sync functions
18 int old;
19 int val = 1;
20 unsigned int uval = 1;
21 int cmp = 0;
22
23 old = __sync_fetch_and_add(&val, 1);
24 old = __sync_fetch_and_sub(&val, 2);
25 old = __sync_fetch_and_min(&val, 3);
26 old = __sync_fetch_and_max(&val, 4);
27 old = __sync_fetch_and_umin(&uval, 5u);
28 old = __sync_fetch_and_umax(&uval, 6u);
29 old = __sync_lock_test_and_set(&val, 7);
30 old = __sync_val_compare_and_swap(&val, 4, 1976);
31 old = __sync_fetch_and_and(&val, 0x9);
32 old = __sync_fetch_and_or(&val, 0xa);
33 old = __sync_fetch_and_xor(&val, 0xb);
34 return old;
35}