summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-01-31 00:50:46 +0000
committerEric Christopher <echristo@gmail.com>2013-01-31 00:50:46 +0000
commita9bd4b4647694f1384a8e1c891931ba7bdff364f (patch)
treec43bd4b8481956a86c973d63bf07f8e80e1587b3 /test
parent946317d07be338f25b554ab543308490a276b835 (diff)
downloadllvm-a9bd4b4647694f1384a8e1c891931ba7bdff364f.tar.gz
llvm-a9bd4b4647694f1384a8e1c891931ba7bdff364f.tar.bz2
llvm-a9bd4b4647694f1384a8e1c891931ba7bdff364f.tar.xz
Check and allow floating point registers to select the size of the
register for inline asm. This conforms to how gcc allows for effective casting of inputs into gprs (fprs is already handled). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGen/X86/cas.ll42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/CodeGen/X86/cas.ll b/test/CodeGen/X86/cas.ll
new file mode 100644
index 0000000000..12e49f9470
--- /dev/null
+++ b/test/CodeGen/X86/cas.ll
@@ -0,0 +1,42 @@
+; RUN: llc -mtriple=x86_64-pc-linux-gnu %s -o - | FileCheck %s
+
+; C code this came from
+;bool cas(float volatile *p, float *expected, float desired) {
+; bool success;
+; __asm__ __volatile__("lock; cmpxchg %[desired], %[mem]; "
+; "mov %[expected], %[expected_out]; "
+; "sete %[success]"
+; : [success] "=a" (success),
+; [expected_out] "=rm" (*expected)
+; : [expected] "a" (*expected),
+; [desired] "q" (desired),
+; [mem] "m" (*p)
+; : "memory", "cc");
+; return success;
+;}
+
+define zeroext i1 @cas(float* %p, float* %expected, float %desired) nounwind {
+entry:
+ %p.addr = alloca float*, align 8
+ %expected.addr = alloca float*, align 8
+ %desired.addr = alloca float, align 4
+ %success = alloca i8, align 1
+ store float* %p, float** %p.addr, align 8
+ store float* %expected, float** %expected.addr, align 8
+ store float %desired, float* %desired.addr, align 4
+ %0 = load float** %expected.addr, align 8
+ %1 = load float** %expected.addr, align 8
+ %2 = load float* %1, align 4
+ %3 = load float* %desired.addr, align 4
+ %4 = load float** %p.addr, align 8
+ %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
+ store i8 %5, i8* %success, align 1
+ %6 = load i8* %success, align 1
+ %tobool = trunc i8 %6 to i1
+ ret i1 %tobool
+}
+
+; Make sure we're emitting a move from
+; CHECK: #APP
+; CHECK-NEXT: lock;{{.*}}mov %eax,{{.*}}
+; CHECK-NEXT: #NO_APP