[AVX512] Bring back vector-shuffle lowering support through broadcasts
[oota-llvm.git] / test / CodeGen / X86 / musttail.ll
1 ; RUN: llc -march=x86 < %s | FileCheck %s
2 ; RUN: llc -march=x86 -O0 < %s | FileCheck %s
3 ; RUN: llc -march=x86 -disable-tail-calls < %s | FileCheck %s
4
5 declare void @t1_callee(i8*)
6 define void @t1(i32* %a) {
7 ; CHECK-LABEL: t1:
8 ; CHECK: jmp {{_?}}t1_callee
9   %b = bitcast i32* %a to i8*
10   musttail call void @t1_callee(i8* %b)
11   ret void
12 }
13
14 declare i8* @t2_callee()
15 define i32* @t2() {
16 ; CHECK-LABEL: t2:
17 ; CHECK: jmp {{_?}}t2_callee
18   %v = musttail call i8* @t2_callee()
19   %w = bitcast i8* %v to i32*
20   ret i32* %w
21 }
22
23 ; Complex frame layout: stack realignment with dynamic alloca.
24 define void @t3(i32 %n) alignstack(32) nounwind {
25 entry:
26 ; CHECK: t3:
27 ; CHECK: pushl %ebp
28 ; CHECK: pushl %esi
29 ; CHECK: andl $-32, %esp
30 ; CHECK: movl %esp, %esi
31 ; CHECK: popl %esi
32 ; CHECK: popl %ebp
33 ; CHECK-NEXT: jmp {{_?}}t3_callee
34   %a = alloca i8, i32 %n
35   call void @capture(i8* %a)
36   musttail call void @t3_callee(i32 %n) nounwind
37   ret void
38 }
39
40 declare void @capture(i8*)
41 declare void @t3_callee(i32)
42
43 ; Test that we actually copy in and out stack arguments that aren't forwarded
44 ; without modification.
45 define i32 @t4({}* %fn, i32 %n, i32 %r) {
46 ; CHECK-LABEL: t4:
47 ; CHECK: incl %[[r:.*]]
48 ; CHECK: decl %[[n:.*]]
49 ; CHECK: movl %[[r]], {{[0-9]+}}(%esp)
50 ; CHECK: movl %[[n]], {{[0-9]+}}(%esp)
51 ; CHECK: jmpl *%{{.*}}
52
53 entry:
54   %r1 = add i32 %r, 1
55   %n1 = sub i32 %n, 1
56   %fn_cast = bitcast {}* %fn to i32 ({}*, i32, i32)*
57   %r2 = musttail call i32 %fn_cast({}* %fn, i32 %n1, i32 %r1)
58   ret i32 %r2
59 }
60
61 ; Combine the complex stack frame with the parameter modification.
62 define i32 @t5({}* %fn, i32 %n, i32 %r) alignstack(32) {
63 ; CHECK-LABEL: t5:
64 ; CHECK: pushl %ebp
65 ; CHECK: movl %esp, %ebp
66 ; CHECK: pushl %esi
67 ;       Align the stack.
68 ; CHECK: andl $-32, %esp
69 ; CHECK: movl %esp, %esi
70 ;       Modify the args.
71 ; CHECK: incl %[[r:.*]]
72 ; CHECK: decl %[[n:.*]]
73 ;       Store them through ebp, since that's the only stable arg pointer.
74 ; CHECK: movl %[[r]], {{[0-9]+}}(%ebp)
75 ; CHECK: movl %[[n]], {{[0-9]+}}(%ebp)
76 ;       Epilogue.
77 ; CHECK: leal {{[-0-9]+}}(%ebp), %esp
78 ; CHECK: popl %esi
79 ; CHECK: popl %ebp
80 ; CHECK: jmpl *%{{.*}}
81
82 entry:
83   %a = alloca i8, i32 %n
84   call void @capture(i8* %a)
85   %r1 = add i32 %r, 1
86   %n1 = sub i32 %n, 1
87   %fn_cast = bitcast {}* %fn to i32 ({}*, i32, i32)*
88   %r2 = musttail call i32 %fn_cast({}* %fn, i32 %n1, i32 %r1)
89   ret i32 %r2
90 }