- Generate atomicrmw operations in most of the cases when it's sensible to do so. - Don't crash in several common cases (and hopefully don't crash in more of them). - Add some better tests. We now generate significantly better code for things like: _Atomic(int) x; ... x++; On MIPS, this now generates a 4-instruction ll/sc loop, where previously it generated about 30 instructions in two nested loops. On x86-64, we generate a single lock incl, instead of a lock cmpxchgl loop (one instruction instead of ten). llvm-svn: 176420
19 lines
361 B
C
19 lines
361 B
C
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
|
|
|
|
void foo(int x)
|
|
{
|
|
_Atomic(int) i = 0;
|
|
_Atomic(short) j = 0;
|
|
// Check that multiply / divides on atomics produce a cmpxchg loop
|
|
i *= 2;
|
|
// CHECK: mul nsw i32
|
|
// CHECK: cmpxchg i32*
|
|
i /= 2;
|
|
// CHECK: sdiv i32
|
|
// CHECK: cmpxchg i32*
|
|
j /= x;
|
|
// CHECK: sdiv i32
|
|
// CHECK: cmpxchg i16*
|
|
|
|
}
|