1 ; RUN: llc -mtriple=x86_64-pc-linux-gnu %s -o - -no-integrated-as | FileCheck %s
3 ; C code this came from
4 ;bool cas(float volatile *p, ptr expected, float desired) {
6 ; __asm__ __volatile__("lock; cmpxchg %[desired], %[mem]; "
7 ; "mov %[expected], %[expected_out]; "
9 ; : [success] "=a" (success),
10 ; [expected_out] "=rm" (*expected)
11 ; : [expected] "a" (*expected),
12 ; [desired] "q" (desired),
18 define zeroext i1 @cas(ptr %p, ptr %expected, float %desired) nounwind {
20 %p.addr = alloca ptr, align 8
21 %expected.addr = alloca ptr, align 8
22 %desired.addr = alloca float, align 4
23 %success = alloca i8, align 1
24 store ptr %p, ptr %p.addr, align 8
25 store ptr %expected, ptr %expected.addr, align 8
26 store float %desired, ptr %desired.addr, align 4
27 %0 = load ptr, ptr %expected.addr, align 8
28 %1 = load ptr, ptr %expected.addr, align 8
29 %2 = load float, ptr %1, align 4
30 %3 = load float, ptr %desired.addr, align 4
31 %4 = load ptr, ptr %p.addr, align 8
32 %5 = call i8 asm sideeffect "lock; cmpxchg $3, $4; mov $2, $1; sete $0", "={ax},=*rm,{ax},q,*m,~{memory},~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(float) %0, float %2, float %3, ptr elementtype(float) %4) nounwind
33 store i8 %5, ptr %success, align 1
34 %6 = load i8, ptr %success, align 1
35 %tobool = trunc i8 %6 to i1
40 ; Make sure we're emitting a move from eax.
42 ; CHECK-NEXT: lock;{{.*}}mov %eax,{{.*}}
45 define zeroext i1 @cas2(ptr %p, ptr %expected, i1 zeroext %desired) nounwind {
47 %p.addr = alloca ptr, align 8
48 %expected.addr = alloca ptr, align 8
49 %desired.addr = alloca i8, align 1
50 %success = alloca i8, align 1
51 store ptr %p, ptr %p.addr, align 8
52 store ptr %expected, ptr %expected.addr, align 8
53 %frombool = zext i1 %desired to i8
54 store i8 %frombool, ptr %desired.addr, align 1
55 %0 = load ptr, ptr %expected.addr, align 8
56 %1 = load ptr, ptr %expected.addr, align 8
57 %2 = load i8, ptr %1, align 1
58 %tobool = trunc i8 %2 to i1
59 %3 = load i8, ptr %desired.addr, align 1
60 %tobool1 = trunc i8 %3 to i1
61 %4 = load ptr, ptr %p.addr, align 8
62 %5 = call i8 asm sideeffect "lock; cmpxchg $3, $4; mov $2, $1; sete $0", "={ax},=*rm,{ax},q,*m,~{memory},~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i8) %0, i1 %tobool, i1 %tobool1, ptr elementtype(i8) %4) nounwind
63 store i8 %5, ptr %success, align 1
64 %6 = load i8, ptr %success, align 1
65 %tobool2 = trunc i8 %6 to i1
70 ; Make sure we're emitting a move from %al here.
72 ; CHECK-NEXT: lock;{{.*}}mov %al,{{.*}}