Eric Christopher | 4e3e94c | 2013-01-31 00:50:46 +0000 | [diff] [blame^] | 1 | ; RUN: llc -mtriple=x86_64-pc-linux-gnu %s -o - | FileCheck %s |
| 2 | |
| 3 | ; C code this came from |
| 4 | ;bool cas(float volatile *p, float *expected, float desired) { |
| 5 | ; bool success; |
| 6 | ; __asm__ __volatile__("lock; cmpxchg %[desired], %[mem]; " |
| 7 | ; "mov %[expected], %[expected_out]; " |
| 8 | ; "sete %[success]" |
| 9 | ; : [success] "=a" (success), |
| 10 | ; [expected_out] "=rm" (*expected) |
| 11 | ; : [expected] "a" (*expected), |
| 12 | ; [desired] "q" (desired), |
| 13 | ; [mem] "m" (*p) |
| 14 | ; : "memory", "cc"); |
| 15 | ; return success; |
| 16 | ;} |
| 17 | |
| 18 | define zeroext i1 @cas(float* %p, float* %expected, float %desired) nounwind { |
| 19 | entry: |
| 20 | %p.addr = alloca float*, align 8 |
| 21 | %expected.addr = alloca float*, align 8 |
| 22 | %desired.addr = alloca float, align 4 |
| 23 | %success = alloca i8, align 1 |
| 24 | store float* %p, float** %p.addr, align 8 |
| 25 | store float* %expected, float** %expected.addr, align 8 |
| 26 | store float %desired, float* %desired.addr, align 4 |
| 27 | %0 = load float** %expected.addr, align 8 |
| 28 | %1 = load float** %expected.addr, align 8 |
| 29 | %2 = load float* %1, align 4 |
| 30 | %3 = load float* %desired.addr, align 4 |
| 31 | %4 = load float** %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}"(float* %0, float %2, float %3, float* %4) nounwind |
| 33 | store i8 %5, i8* %success, align 1 |
| 34 | %6 = load i8* %success, align 1 |
| 35 | %tobool = trunc i8 %6 to i1 |
| 36 | ret i1 %tobool |
| 37 | } |
| 38 | |
| 39 | ; Make sure we're emitting a move from |
| 40 | ; CHECK: #APP |
| 41 | ; CHECK-NEXT: lock;{{.*}}mov %eax,{{.*}} |
| 42 | ; CHECK-NEXT: #NO_APP |