2015-03-05 07:40:38 +08:00
|
|
|
// XFAIL: hexagon
|
2012-01-17 01:27:18 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
|
2015-02-18 23:08:37 +08:00
|
|
|
// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm %s -o - | FileCheck %s
|
2012-01-17 01:27:18 +08:00
|
|
|
|
2012-06-16 10:19:17 +08:00
|
|
|
void foo(int x)
|
2012-01-17 01:27:18 +08:00
|
|
|
{
|
|
|
|
_Atomic(int) i = 0;
|
2012-06-16 10:19:17 +08:00
|
|
|
_Atomic(short) j = 0;
|
2012-01-17 01:27:18 +08:00
|
|
|
// Check that multiply / divides on atomics produce a cmpxchg loop
|
2012-06-16 10:19:17 +08:00
|
|
|
i *= 2;
|
|
|
|
// CHECK: mul nsw i32
|
2014-12-15 14:12:42 +08:00
|
|
|
// CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}}
|
2012-06-16 10:19:17 +08:00
|
|
|
i /= 2;
|
|
|
|
// CHECK: sdiv i32
|
2014-12-15 14:12:42 +08:00
|
|
|
// CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}}
|
2012-06-16 10:19:17 +08:00
|
|
|
j /= x;
|
|
|
|
// CHECK: sdiv i32
|
2014-12-15 14:12:42 +08:00
|
|
|
// CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}}
|
2012-06-16 10:19:17 +08:00
|
|
|
|
2012-01-17 01:27:18 +08:00
|
|
|
}
|
2015-02-14 09:35:07 +08:00
|
|
|
|
|
|
|
extern _Atomic _Bool b;
|
|
|
|
|
|
|
|
_Bool bar() {
|
|
|
|
// CHECK-LABEL: @bar
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: %[[load:.*]] = load atomic i8, i8* @b seq_cst
|
2015-02-14 09:35:07 +08:00
|
|
|
// CHECK: %[[tobool:.*]] = trunc i8 %[[load]] to i1
|
|
|
|
// CHECK: ret i1 %[[tobool]]
|
|
|
|
return b;
|
|
|
|
}
|
2015-02-14 09:48:17 +08:00
|
|
|
|
|
|
|
extern _Atomic(_Complex int) x;
|
|
|
|
|
|
|
|
void baz(int y) {
|
|
|
|
// CHECK-LABEL: @baz
|
2015-02-18 23:08:37 +08:00
|
|
|
// CHECK: {{store atomic|call void @__atomic_store}}
|
2015-02-14 09:48:17 +08:00
|
|
|
x += y;
|
|
|
|
}
|