long double testinc(_Atomic long double *addr) { return ++*addr; }


x86 assembly (clang, -O0):
<testinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    %rsi,-0x58(%rbp)
mov    $0x10,%edi
lea    -0x20(%rbp),%rdx
mov    $0x5,%ecx
call   1040 <__atomic_load@plt>
fldt   -0x20(%rbp)
fstpt  -0x4c(%rbp)
fldt   -0x4c(%rbp)
mov    -0x58(%rbp),%rsi
fld1
fadd   %st(1),%st
fld    %st(0)
fstpt  -0x64(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
fxch   %st(1)
fstpt  -0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
fstpt  -0x40(%rbp)
mov    $0x10,%edi
lea    -0x30(%rbp),%rdx
lea    -0x40(%rbp),%rcx
mov    $0x5,%r9d
mov    %r9d,%r8d
call   1030 <__atomic_compare_exchange@plt>
fldt   -0x30(%rbp)
test   $0x1,%al
fstpt  -0x4c(%rbp)
jne    119e <testinc+0x7e>
jmp    114d <testinc+0x2d>
fldt   -0x64(%rbp)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testinc>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%rbx
lea    0x40(%rsp),%rdx
mov    $0x10,%edi
mov    %rbx,%rsi
mov    $0x5,%ecx
call   1040 <__atomic_load@plt>
fldt   0x40(%rsp)
fld1
fld    %st(0)
fstpt  0x34(%rsp)
fadd   %st(1),%st
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
fxch   %st(1)
fstpt  (%rsp)
movaps %xmm0,0x10(%rsp)
fld    %st(0)
fstpt  0x28(%rsp)
fstpt  0x10(%rsp)
mov    %rsp,%rdx
lea    0x10(%rsp),%rcx
mov    $0x10,%edi
mov    %rbx,%rsi
mov    $0x5,%r8d
mov    $0x5,%r9d
call   1030 <__atomic_compare_exchange@plt>
test   %al,%al
jne    11e7 <testinc+0xc7>
mov    %rsp,%r14
lea    0x10(%rsp),%r15
nopl   0x0(%rax)
fldt   (%rsp)
fldt   0x34(%rsp)
fadd   %st(1),%st
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
fxch   %st(1)
fstpt  (%rsp)
movaps %xmm0,0x10(%rsp)
fld    %st(0)
fstpt  0x28(%rsp)
fstpt  0x10(%rsp)
mov    $0x10,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    $0x5,%r8d
mov    $0x5,%r9d
call   1030 <__atomic_compare_exchange@plt>
test   %al,%al
je     11a0 <testinc+0x80>
fldt   0x28(%rsp)
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define x86_fp80 @testinc(x86_fp80* %0) {
%2 = alloca x86_fp80*
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
store x86_fp80* %0, x86_fp80** %2
%6 = load x86_fp80*, x86_fp80** %2
%7 = bitcast x86_fp80* %6 to i8*
%8 = bitcast x86_fp80* %3 to i8*
%9 = load x86_fp80, x86_fp80* %3
br label %10
10: ; preds = %10, %1
%11 = phi x86_fp80 [ %9, %1 ], [ %19, %10 ]
%12 = fadd x86_fp80 %11, 0xK3FFF8000000000000000
%13 = bitcast x86_fp80* %4 to i8*
store x86_fp80 %11, x86_fp80* %4
%14 = bitcast x86_fp80* %5 to i8*
store x86_fp80 %12, x86_fp80* %5
%15 = bitcast x86_fp80* %6 to i8*
%16 = bitcast x86_fp80* %4 to i8*
%17 = bitcast x86_fp80* %5 to i8*
%18 = call zeroext i1 @__atomic_compare_exchange(i64 16, i8* %15, i8* %16, i8* %17, i32 5, i32 5)
%19 = load x86_fp80, x86_fp80* %4
br i1 %18, label %20, label %10
20: ; preds = %10
ret x86_fp80 %12
}

LLVM IR (-O2):
define x86_fp80 @testinc(x86_fp80* %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = bitcast x86_fp80* %0 to i8*
%6 = bitcast x86_fp80* %2 to i8*
%7 = bitcast x86_fp80* %3 to i8*
%8 = bitcast x86_fp80* %4 to i8*
%9 = load x86_fp80, x86_fp80* %2
%10 = fadd x86_fp80 %9, 0xK3FFF8000000000000000
store x86_fp80 %9, x86_fp80* %3
store x86_fp80 %10, x86_fp80* %4
%11 = call zeroext i1 @__atomic_compare_exchange(i64 16, i8* %5, i8* %7, i8* %8, i32 5, i32 5)
br i1 %11, label %16, label %12
12: ; preds = %1, %12
%13 = load x86_fp80, x86_fp80* %3
%14 = fadd x86_fp80 %13, 0xK3FFF8000000000000000
store x86_fp80 %13, x86_fp80* %3
store x86_fp80 %14, x86_fp80* %4
%15 = call zeroext i1 @__atomic_compare_exchange(i64 16, i8* %5, i8* %7, i8* %8, i32 5, i32 5)
br i1 %15, label %16, label %12
16: ; preds = %12, %1
%17 = phi x86_fp80 [ %10, %1 ], [ %14, %12 ]
ret x86_fp80 %17
}