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