xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/atomic_ops.c (revision bdb565187c0f1a04513dd488df843317b27f86c8)
1 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
2 
3 void foo(int x)
4 {
5   _Atomic(int) i = 0;
6   _Atomic(short) j = 0;
7   // Check that multiply / divides on atomics produce a cmpxchg loop
8   i *= 2;
9   // CHECK: mul nsw i32
10   // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4,)}}
11   i /= 2;
12   // CHECK: sdiv i32
13   // CHECK: {{(cmpxchg i32*|i1 @__atomic_compare_exchange\(i32 4, )}}
14   j /= x;
15   // CHECK: sdiv i32
16   // CHECK: {{(cmpxchg i16*|i1 @__atomic_compare_exchange\(i32 2, )}}
17 
18 }
19