1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-apple-macosx -mcpu=core2 < %s | FileCheck %s
6 define i64 @test_trivial() {
7 ; CHECK-LABEL: test_trivial:
8 ; CHECK: ## %bb.0: ## %entry
9 ; CHECK-NEXT: jmp _testi ## TAILCALL
11 %A = tail call i64 @testi()
15 define i64 @test_noop_bitcast() {
16 ; CHECK-LABEL: test_noop_bitcast:
17 ; CHECK: ## %bb.0: ## %entry
18 ; CHECK-NEXT: jmp _testi ## TAILCALL
20 %A = tail call i64 @testi()
21 %B = bitcast i64 %A to i64
25 ; Tail call shouldn't be blocked by no-op inttoptr.
26 define ptr @test_inttoptr() {
27 ; CHECK-LABEL: test_inttoptr:
28 ; CHECK: ## %bb.0: ## %entry
29 ; CHECK-NEXT: jmp _testi ## TAILCALL
31 %A = tail call i64 @testi()
32 %B = inttoptr i64 %A to ptr
36 declare <4 x float> @testv()
38 define <4 x i32> @test_vectorbitcast() {
39 ; CHECK-LABEL: test_vectorbitcast:
40 ; CHECK: ## %bb.0: ## %entry
41 ; CHECK-NEXT: jmp _testv ## TAILCALL
43 %A = tail call <4 x float> @testv()
44 %B = bitcast <4 x float> %A to <4 x i32>
48 declare { i64, i64 } @testp()
50 define {i64, i64} @test_pair_trivial() {
51 ; CHECK-LABEL: test_pair_trivial:
52 ; CHECK: ## %bb.0: ## %entry
53 ; CHECK-NEXT: jmp _testp ## TAILCALL
55 %A = tail call { i64, i64} @testp()
59 define {i64, i64} @test_pair_notail() {
60 ; CHECK-LABEL: test_pair_notail:
61 ; CHECK: ## %bb.0: ## %entry
62 ; CHECK-NEXT: pushq %rax
63 ; CHECK-NEXT: .cfi_def_cfa_offset 16
64 ; CHECK-NEXT: callq _testi
65 ; CHECK-NEXT: movq %rax, %rdx
66 ; CHECK-NEXT: popq %rcx
69 %A = tail call i64 @testi()
71 %b = insertvalue {i64, i64} undef, i64 %A, 0
72 %c = insertvalue {i64, i64} %b, i64 %A, 1
77 define {i64, i64} @test_pair_extract_trivial() {
78 ; CHECK-LABEL: test_pair_extract_trivial:
79 ; CHECK: ## %bb.0: ## %entry
80 ; CHECK-NEXT: jmp _testp ## TAILCALL
82 %A = tail call { i64, i64} @testp()
83 %x = extractvalue { i64, i64} %A, 0
84 %y = extractvalue { i64, i64} %A, 1
86 %b = insertvalue {i64, i64} undef, i64 %x, 0
87 %c = insertvalue {i64, i64} %b, i64 %y, 1
92 define {i64, i64} @test_pair_extract_notail() {
93 ; CHECK-LABEL: test_pair_extract_notail:
94 ; CHECK: ## %bb.0: ## %entry
95 ; CHECK-NEXT: pushq %rax
96 ; CHECK-NEXT: .cfi_def_cfa_offset 16
97 ; CHECK-NEXT: callq _testp
98 ; CHECK-NEXT: movq %rax, %rcx
99 ; CHECK-NEXT: movq %rdx, %rax
100 ; CHECK-NEXT: movq %rcx, %rdx
101 ; CHECK-NEXT: popq %rcx
104 %A = tail call { i64, i64} @testp()
105 %x = extractvalue { i64, i64} %A, 0
106 %y = extractvalue { i64, i64} %A, 1
108 %b = insertvalue {i64, i64} undef, i64 %y, 0
109 %c = insertvalue {i64, i64} %b, i64 %x, 1
114 define {ptr, i64} @test_pair_extract_conv() {
115 ; CHECK-LABEL: test_pair_extract_conv:
116 ; CHECK: ## %bb.0: ## %entry
117 ; CHECK-NEXT: jmp _testp ## TAILCALL
119 %A = tail call { i64, i64} @testp()
120 %x = extractvalue { i64, i64} %A, 0
121 %y = extractvalue { i64, i64} %A, 1
123 %x1 = inttoptr i64 %x to ptr
125 %b = insertvalue {ptr, i64} undef, ptr %x1, 0
126 %c = insertvalue {ptr, i64} %b, i64 %y, 1
131 define {i64, i64} @test_pair_extract_multiple() {
132 ; CHECK-LABEL: test_pair_extract_multiple:
133 ; CHECK: ## %bb.0: ## %entry
134 ; CHECK-NEXT: jmp _testp ## TAILCALL
136 %A = tail call { i64, i64} @testp()
137 %x = extractvalue { i64, i64} %A, 0
138 %y = extractvalue { i64, i64} %A, 1
140 %b = insertvalue {i64, i64} undef, i64 %x, 0
141 %c = insertvalue {i64, i64} %b, i64 %y, 1
143 %x1 = extractvalue { i64, i64} %b, 0
144 %y1 = extractvalue { i64, i64} %c, 1
146 %d = insertvalue {i64, i64} undef, i64 %x1, 0
147 %e = insertvalue {i64, i64} %b, i64 %y1, 1
152 define {i64, i64} @test_pair_extract_undef() {
153 ; CHECK-LABEL: test_pair_extract_undef:
154 ; CHECK: ## %bb.0: ## %entry
155 ; CHECK-NEXT: jmp _testp ## TAILCALL
157 %A = tail call { i64, i64} @testp()
158 %x = extractvalue { i64, i64} %A, 0
160 %b = insertvalue {i64, i64} undef, i64 %x, 0
165 declare { i64, { i32, i32 } } @testn()
167 define {i64, {i32, i32}} @test_nest() {
168 ; CHECK-LABEL: test_nest:
169 ; CHECK: ## %bb.0: ## %entry
170 ; CHECK-NEXT: jmp _testn ## TAILCALL
172 %A = tail call { i64, { i32, i32 } } @testn()
173 %x = extractvalue { i64, { i32, i32}} %A, 0
174 %y = extractvalue { i64, { i32, i32}} %A, 1
175 %y1 = extractvalue { i32, i32} %y, 0
176 %y2 = extractvalue { i32, i32} %y, 1
178 %b = insertvalue {i64, {i32, i32}} undef, i64 %x, 0
179 %c1 = insertvalue {i32, i32} undef, i32 %y1, 0
180 %c2 = insertvalue {i32, i32} %c1, i32 %y2, 1
181 %c = insertvalue {i64, {i32, i32}} %b, {i32, i32} %c2, 1
183 ret { i64, { i32, i32}} %c
186 %struct.A = type { i32 }
187 %struct.B = type { %struct.A, i32 }
191 define ptr @test_upcast() {
192 ; CHECK-LABEL: test_upcast:
193 ; CHECK: ## %bb.0: ## %entry
194 ; CHECK-NEXT: jmp _testu ## TAILCALL
196 %A = tail call ptr @testu()
201 define { i64, i64 } @crash(ptr %this) {
202 ; CHECK-LABEL: crash:
203 ; CHECK: ## %bb.0: ## %entry
204 ; CHECK-NEXT: jmp _testp ## TAILCALL
206 %c = tail call { i64, i64 } @testp()
207 %mrv7 = insertvalue { i64, i64 } %c, i64 undef, 1
208 ret { i64, i64 } %mrv7
211 %struct.funcs = type { ptr, ptr, ptr, ptr, i32 }
213 @func_table = external global [0 x %struct.funcs]
215 ; Check that we can fold an indexed load into a tail call instruction.
216 define void @fold_indexed_load(ptr %mbstr, i64 %idxprom) nounwind uwtable ssp {
217 ; CHECK-LABEL: fold_indexed_load:
218 ; CHECK: ## %bb.0: ## %entry
219 ; CHECK-NEXT: leaq (%rsi,%rsi,4), %rax
220 ; CHECK-NEXT: movq _func_table@GOTPCREL(%rip), %rcx
221 ; CHECK-NEXT: jmpq *16(%rcx,%rax,8) ## TAILCALL
223 %dsplen = getelementptr inbounds [0 x %struct.funcs], ptr @func_table, i64 0, i64 %idxprom, i32 2
224 %x1 = load ptr, ptr %dsplen, align 8
225 %call = tail call i32 %x1(ptr %mbstr) nounwind
229 @funcs = external constant [0 x ptr]
231 ; <rdar://problem/12282281> Fold an indexed load into the tail call instruction.
232 ; Calling a varargs function with 6 arguments requires 7 registers (%al is the
233 ; vector count for varargs functions). This leaves %r11 as the only available
236 ; It is not possible to fold an indexed load into TCRETURNmi64 in that case.
238 ; typedef int (*funcptr)(ptr, ...);
239 ; extern const funcptr funcs[];
241 ; return funcs[n](0, 0, 0, 0, 0, 0);
243 define i32 @rdar12282281(i32 %n) nounwind uwtable ssp {
244 ; CHECK-LABEL: rdar12282281:
245 ; CHECK: ## %bb.0: ## %entry
246 ; CHECK-NEXT: movslq %edi, %rax
247 ; CHECK-NEXT: movq _funcs@GOTPCREL(%rip), %rcx
248 ; CHECK-NEXT: movq (%rcx,%rax,8), %r11
249 ; CHECK-NEXT: xorl %edi, %edi
250 ; CHECK-NEXT: xorl %esi, %esi
251 ; CHECK-NEXT: xorl %edx, %edx
252 ; CHECK-NEXT: xorl %ecx, %ecx
253 ; CHECK-NEXT: xorl %r8d, %r8d
254 ; CHECK-NEXT: xorl %r9d, %r9d
255 ; CHECK-NEXT: xorl %eax, %eax
256 ; CHECK-NEXT: jmpq *%r11 ## TAILCALL
258 %idxprom = sext i32 %n to i64
259 %arrayidx = getelementptr inbounds [0 x ptr], ptr @funcs, i64 0, i64 %idxprom
260 %0 = load ptr, ptr %arrayidx, align 8
261 %call = tail call i32 (ptr, ...) %0(ptr null, i32 0, i32 0, i32 0, i32 0, i32 0) nounwind
265 declare x86_fp80 @fp80_callee(x86_fp80)
267 define x86_fp80 @fp80_call(x86_fp80 %x) nounwind {
268 ; CHECK-LABEL: fp80_call:
269 ; CHECK: ## %bb.0: ## %entry
270 ; CHECK-NEXT: jmp _fp80_callee ## TAILCALL
272 %call = tail call x86_fp80 @fp80_callee(x86_fp80 %x) nounwind
276 declare double @trunc(double) nounwind readnone
278 ; rdar://12229511 - Don't tail call trunc here.
279 define x86_fp80 @trunc_fp80(x86_fp80 %x) nounwind {
280 ; CHECK-LABEL: trunc_fp80:
281 ; CHECK: ## %bb.0: ## %entry
282 ; CHECK-NEXT: subq $24, %rsp
283 ; CHECK-NEXT: fldt {{[0-9]+}}(%rsp)
284 ; CHECK-NEXT: fstpl {{[0-9]+}}(%rsp)
285 ; CHECK-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
286 ; CHECK-NEXT: callq _trunc
287 ; CHECK-NEXT: movsd %xmm0, {{[0-9]+}}(%rsp)
288 ; CHECK-NEXT: fldl {{[0-9]+}}(%rsp)
289 ; CHECK-NEXT: addq $24, %rsp
292 %conv = fptrunc x86_fp80 %x to double
293 %call = tail call double @trunc(double %conv) nounwind readnone
294 %conv1 = fpext double %call to x86_fp80