1 ; RUN: llc < %s -mtriple=i386-apple-darwin | FileCheck %s
3 ; There should be no stack manipulations between the inline asm and ret.
7 define x86_fp80 @test1() {
8 %tmp85 = call x86_fp80 asm sideeffect "fld0", "={st(0)}"()
13 ; CHECK: InlineAsm End
15 define double @test2() {
16 %tmp85 = call double asm sideeffect "fld0", "={st(0)}"()
20 ; Setting up argument in st(0) should be a single fld.
23 ; CHECK-NEXT: InlineAsm Start
24 ; Asm consumes stack, nothing should be popped.
25 ; CHECK: InlineAsm End
28 define void @test3(x86_fp80 %X) {
29 call void asm sideeffect "frob ", "{st(0)},~{st},~{dirflag},~{fpsr},~{flags}"( x86_fp80 %X)
35 ; CHECK-NEXT: InlineAsm Start
36 ; CHECK: InlineAsm End
39 define void @test4(double %X) {
40 call void asm sideeffect "frob ", "{st(0)},~{st},~{dirflag},~{fpsr},~{flags}"( double %X)
44 ; Same as test3/4, but using value from fadd.
45 ; The fadd can be done in xmm or x87 regs - we don't test that.
47 ; CHECK: InlineAsm End
50 define void @test5(double %X) {
51 %Y = fadd double %X, 123.0
52 call void asm sideeffect "frob ", "{st(0)},~{st},~{dirflag},~{fpsr},~{flags}"( double %Y)
57 define void @test6(double %A, double %B, double %C,
58 double %D, double %E) nounwind {
60 ; Uses the same value twice, should have one fstp after the asm.
62 ; CHECK: InlineAsm End
65 tail call void asm sideeffect "foo $0 $1", "f,f,~{dirflag},~{fpsr},~{flags}"( double %A, double %A ) nounwind
66 ; Uses two different values, should be in st(0)/st(1) and both be popped.
68 ; CHECK: InlineAsm End
71 tail call void asm sideeffect "bar $0 $1", "f,f,~{dirflag},~{fpsr},~{flags}"( double %B, double %C ) nounwind
72 ; Uses two different values, one of which isn't killed in this asm, it
73 ; should not be popped after the asm.
75 ; CHECK: InlineAsm End
78 tail call void asm sideeffect "baz $0 $1", "f,f,~{dirflag},~{fpsr},~{flags}"( double %D, double %E ) nounwind
79 ; This is the last use of %D, so it should be popped after.
81 ; CHECK: InlineAsm End
85 tail call void asm sideeffect "baz $0", "f,~{dirflag},~{fpsr},~{flags}"( double %D ) nounwind
90 ; Passing a non-killed value to asm in {st}.
91 ; Make sure it is duped before.
92 ; asm kills st(0), so we shouldn't pop anything
100 ; A valid alternative would be to remat the constant pool load before each
102 define void @testPR4185() {
104 call void asm sideeffect "fistpl $0", "{st},~{st}"(double 1.000000e+06)
105 call void asm sideeffect "fistpl $0", "{st},~{st}"(double 1.000000e+06)
110 ; The return value from ceil must be duped before being consumed by asm.
119 define void @testPR4459(x86_fp80 %a) {
121 %0 = call x86_fp80 @ceil(x86_fp80 %a)
122 call void asm sideeffect "fistpl $0", "{st},~{st}"( x86_fp80 %0)
123 call void @test3(x86_fp80 %0 )
126 declare x86_fp80 @ceil(x86_fp80)
129 ; test1 leaves a value on the stack that is needed after the asm.
133 ; Load %a from stack after ceil
138 ; Set up call to test.
141 define void @testPR4484(x86_fp80 %a) {
143 %0 = call x86_fp80 @test1()
144 call void asm sideeffect "fistpl $0", "{st},~{st}"(x86_fp80 %a)
145 call void @test3(x86_fp80 %0)
151 define void @testPR4485(x86_fp80* %a) {
153 %0 = load x86_fp80* %a, align 16
154 %1 = fmul x86_fp80 %0, 0xK4006B400000000000000
155 %2 = fmul x86_fp80 %1, 0xK4012F424000000000000
156 tail call void asm sideeffect "fistpl $0", "{st},~{st}"(x86_fp80 %2)
157 %3 = load x86_fp80* %a, align 16
158 %4 = fmul x86_fp80 %3, 0xK4006B400000000000000
159 %5 = fmul x86_fp80 %4, 0xK4012F424000000000000
160 tail call void asm sideeffect "fistpl $0", "{st},~{st}"(x86_fp80 %5)