1 | // XFAIL: hexagon,sparc |
2 | // (due to not having native load atomic support) |
3 | // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s |
4 | // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s |
5 | |
6 | void foo(int x) |
7 | { |
8 | _Atomic(int) i = 0; |
9 | _Atomic(short) j = 0; |
10 | // Check that multiply / divides on atomics produce a cmpxchg loop |
11 | i *= 2; |
12 | // CHECK: mul nsw i32 |
13 | // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}} |
14 | i /= 2; |
15 | // CHECK: sdiv i32 |
16 | // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}} |
17 | j /= x; |
18 | // CHECK: sdiv i32 |
19 | // CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}} |
20 | |
21 | } |
22 | |
23 | extern _Atomic _Bool b; |
24 | |
25 | _Bool bar() { |
26 | // CHECK-LABEL: @bar |
27 | // CHECK: %[[load:.*]] = load atomic i8, i8* @b seq_cst |
28 | // CHECK: %[[tobool:.*]] = trunc i8 %[[load]] to i1 |
29 | // CHECK: ret i1 %[[tobool]] |
30 | return b; |
31 | } |
32 | |
33 | extern _Atomic(_Complex int) x; |
34 | |
35 | void baz(int y) { |
36 | // CHECK-LABEL: @baz |
37 | // CHECK: {{store atomic|call void @__atomic_store}} |
38 | x += y; |
39 | } |
40 | |