1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -enable-cse-in-irtranslator=0 -enable-cse-in-legalizer=0 -mtriple=i386-linux-gnu -mattr=+sse2 -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X32
3 ; RUN: llc -enable-cse-in-irtranslator=0 -enable-cse-in-legalizer=0 -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
5 define i32 @test_ret_i32() {
6 ; X32-LABEL: test_ret_i32:
8 ; X32-NEXT: movl $20, %eax
11 ; X64-LABEL: test_ret_i32:
13 ; X64-NEXT: movl $20, %eax
18 define i64 @test_ret_i64() {
19 ; X32-LABEL: test_ret_i64:
21 ; X32-NEXT: movl $-1, %eax
22 ; X32-NEXT: movl $15, %edx
25 ; X64-LABEL: test_ret_i64:
27 ; X64-NEXT: movabsq $68719476735, %rax # imm = 0xFFFFFFFFF
32 define i8 @test_arg_i8(i8 %a) {
33 ; X32-LABEL: test_arg_i8:
35 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
36 ; X32-NEXT: # kill: def $al killed $al killed $eax
39 ; X64-LABEL: test_arg_i8:
41 ; X64-NEXT: movl %edi, %eax
42 ; X64-NEXT: # kill: def $al killed $al killed $eax
47 define i16 @test_arg_i16(i16 %a) {
48 ; X32-LABEL: test_arg_i16:
50 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
51 ; X32-NEXT: # kill: def $ax killed $ax killed $eax
54 ; X64-LABEL: test_arg_i16:
56 ; X64-NEXT: movl %edi, %eax
57 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
62 define i32 @test_arg_i32(i32 %a) {
63 ; X32-LABEL: test_arg_i32:
65 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
68 ; X64-LABEL: test_arg_i32:
70 ; X64-NEXT: movl %edi, %eax
75 define i64 @test_arg_i64(i64 %a) {
76 ; X32-LABEL: test_arg_i64:
78 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
79 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
82 ; X64-LABEL: test_arg_i64:
84 ; X64-NEXT: movq %rdi, %rax
89 define i64 @test_i64_args_8(i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %arg5, i64 %arg6, i64 %arg7, i64 %arg8) {
90 ; X32-LABEL: test_i64_args_8:
92 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
93 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
96 ; X64-LABEL: test_i64_args_8:
98 ; X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
103 define <4 x i32> @test_v4i32_args(<4 x i32> %arg1, <4 x i32> %arg2) {
104 ; X32-LABEL: test_v4i32_args:
106 ; X32-NEXT: movaps %xmm1, %xmm0
109 ; X64-LABEL: test_v4i32_args:
111 ; X64-NEXT: movaps %xmm1, %xmm0
116 define <8 x i32> @test_v8i32_args(<8 x i32> %arg1, <8 x i32> %arg2) {
117 ; X32-LABEL: test_v8i32_args:
119 ; X32-NEXT: subl $12, %esp
120 ; X32-NEXT: .cfi_def_cfa_offset 16
121 ; X32-NEXT: movaps %xmm2, %xmm0
122 ; X32-NEXT: movaps {{[0-9]+}}(%esp), %xmm1
123 ; X32-NEXT: addl $12, %esp
124 ; X32-NEXT: .cfi_def_cfa_offset 4
127 ; X64-LABEL: test_v8i32_args:
129 ; X64-NEXT: movaps %xmm2, %xmm0
130 ; X64-NEXT: movaps %xmm3, %xmm1
135 declare void @trivial_callee()
136 define void @test_trivial_call() {
137 ; X32-LABEL: test_trivial_call:
139 ; X32-NEXT: subl $12, %esp
140 ; X32-NEXT: .cfi_def_cfa_offset 16
141 ; X32-NEXT: calll trivial_callee
142 ; X32-NEXT: addl $12, %esp
143 ; X32-NEXT: .cfi_def_cfa_offset 4
146 ; X64-LABEL: test_trivial_call:
148 ; X64-NEXT: pushq %rax
149 ; X64-NEXT: .cfi_def_cfa_offset 16
150 ; X64-NEXT: callq trivial_callee
151 ; X64-NEXT: popq %rax
152 ; X64-NEXT: .cfi_def_cfa_offset 8
154 call void @trivial_callee()
158 declare void @simple_arg_callee(i32 %in0, i32 %in1)
159 define void @test_simple_arg_call(i32 %in0, i32 %in1) {
160 ; X32-LABEL: test_simple_arg_call:
162 ; X32-NEXT: subl $12, %esp
163 ; X32-NEXT: .cfi_def_cfa_offset 16
164 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
165 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
166 ; X32-NEXT: movl %ecx, (%esp)
167 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
168 ; X32-NEXT: calll simple_arg_callee
169 ; X32-NEXT: addl $12, %esp
170 ; X32-NEXT: .cfi_def_cfa_offset 4
173 ; X64-LABEL: test_simple_arg_call:
175 ; X64-NEXT: pushq %rax
176 ; X64-NEXT: .cfi_def_cfa_offset 16
177 ; X64-NEXT: movl %edi, %eax
178 ; X64-NEXT: movl %esi, %edi
179 ; X64-NEXT: movl %eax, %esi
180 ; X64-NEXT: callq simple_arg_callee
181 ; X64-NEXT: popq %rax
182 ; X64-NEXT: .cfi_def_cfa_offset 8
184 call void @simple_arg_callee(i32 %in1, i32 %in0)
188 declare void @simple_arg8_callee(i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7, i32 %arg8)
189 define void @test_simple_arg8_call(i32 %in0) {
190 ; X32-LABEL: test_simple_arg8_call:
192 ; X32-NEXT: subl $44, %esp
193 ; X32-NEXT: .cfi_def_cfa_offset 48
194 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
195 ; X32-NEXT: movl %eax, (%esp)
196 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
197 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
198 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
199 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
200 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
201 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
202 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
203 ; X32-NEXT: calll simple_arg8_callee
204 ; X32-NEXT: addl $44, %esp
205 ; X32-NEXT: .cfi_def_cfa_offset 4
208 ; X64-LABEL: test_simple_arg8_call:
210 ; X64-NEXT: subq $24, %rsp
211 ; X64-NEXT: .cfi_def_cfa_offset 32
212 ; X64-NEXT: movl %edi, (%rsp)
213 ; X64-NEXT: movl %edi, {{[0-9]+}}(%rsp)
214 ; X64-NEXT: movl %edi, %esi
215 ; X64-NEXT: movl %edi, %edx
216 ; X64-NEXT: movl %edi, %ecx
217 ; X64-NEXT: movl %edi, %r8d
218 ; X64-NEXT: movl %edi, %r9d
219 ; X64-NEXT: callq simple_arg8_callee
220 ; X64-NEXT: addq $24, %rsp
221 ; X64-NEXT: .cfi_def_cfa_offset 8
223 call void @simple_arg8_callee(i32 %in0, i32 %in0, i32 %in0, i32 %in0,i32 %in0, i32 %in0, i32 %in0, i32 %in0)
227 declare i32 @simple_return_callee(i32 %in0)
228 define i32 @test_simple_return_callee() {
229 ; X32-LABEL: test_simple_return_callee:
231 ; X32-NEXT: subl $12, %esp
232 ; X32-NEXT: .cfi_def_cfa_offset 16
233 ; X32-NEXT: movl $5, %eax
234 ; X32-NEXT: movl %eax, (%esp)
235 ; X32-NEXT: calll simple_return_callee
236 ; X32-NEXT: addl %eax, %eax
237 ; X32-NEXT: addl $12, %esp
238 ; X32-NEXT: .cfi_def_cfa_offset 4
241 ; X64-LABEL: test_simple_return_callee:
243 ; X64-NEXT: pushq %rax
244 ; X64-NEXT: .cfi_def_cfa_offset 16
245 ; X64-NEXT: movl $5, %edi
246 ; X64-NEXT: callq simple_return_callee
247 ; X64-NEXT: addl %eax, %eax
248 ; X64-NEXT: popq %rcx
249 ; X64-NEXT: .cfi_def_cfa_offset 8
251 %call = call i32 @simple_return_callee(i32 5)
252 %r = add i32 %call, %call
256 declare <8 x i32> @split_return_callee(<8 x i32> %in0)
257 define <8 x i32> @test_split_return_callee(<8 x i32> %arg1, <8 x i32> %arg2) {
258 ; X32-LABEL: test_split_return_callee:
260 ; X32-NEXT: subl $44, %esp
261 ; X32-NEXT: .cfi_def_cfa_offset 48
262 ; X32-NEXT: movaps %xmm0, (%esp) # 16-byte Spill
263 ; X32-NEXT: movaps %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
264 ; X32-NEXT: movdqa %xmm2, %xmm0
265 ; X32-NEXT: movdqa {{[0-9]+}}(%esp), %xmm1
266 ; X32-NEXT: calll split_return_callee
267 ; X32-NEXT: paddd (%esp), %xmm0 # 16-byte Folded Reload
268 ; X32-NEXT: paddd {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Folded Reload
269 ; X32-NEXT: addl $44, %esp
270 ; X32-NEXT: .cfi_def_cfa_offset 4
273 ; X64-LABEL: test_split_return_callee:
275 ; X64-NEXT: subq $40, %rsp
276 ; X64-NEXT: .cfi_def_cfa_offset 48
277 ; X64-NEXT: movaps %xmm0, (%rsp) # 16-byte Spill
278 ; X64-NEXT: movaps %xmm1, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
279 ; X64-NEXT: movdqa %xmm2, %xmm0
280 ; X64-NEXT: movdqa %xmm3, %xmm1
281 ; X64-NEXT: callq split_return_callee
282 ; X64-NEXT: paddd (%rsp), %xmm0 # 16-byte Folded Reload
283 ; X64-NEXT: paddd {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Folded Reload
284 ; X64-NEXT: addq $40, %rsp
285 ; X64-NEXT: .cfi_def_cfa_offset 8
287 %call = call <8 x i32> @split_return_callee(<8 x i32> %arg2)
288 %r = add <8 x i32> %arg1, %call
292 define void @test_indirect_call(ptr %func) {
293 ; X32-LABEL: test_indirect_call:
295 ; X32-NEXT: subl $12, %esp
296 ; X32-NEXT: .cfi_def_cfa_offset 16
297 ; X32-NEXT: calll *{{[0-9]+}}(%esp)
298 ; X32-NEXT: addl $12, %esp
299 ; X32-NEXT: .cfi_def_cfa_offset 4
302 ; X64-LABEL: test_indirect_call:
304 ; X64-NEXT: pushq %rax
305 ; X64-NEXT: .cfi_def_cfa_offset 16
306 ; X64-NEXT: callq *%rdi
307 ; X64-NEXT: popq %rax
308 ; X64-NEXT: .cfi_def_cfa_offset 8
314 declare void @take_char(i8)
315 define void @test_abi_exts_call(ptr %addr) {
316 ; X32-LABEL: test_abi_exts_call:
318 ; X32-NEXT: pushl %ebx
319 ; X32-NEXT: .cfi_def_cfa_offset 8
320 ; X32-NEXT: pushl %esi
321 ; X32-NEXT: .cfi_def_cfa_offset 12
322 ; X32-NEXT: pushl %eax
323 ; X32-NEXT: .cfi_def_cfa_offset 16
324 ; X32-NEXT: .cfi_offset %esi, -12
325 ; X32-NEXT: .cfi_offset %ebx, -8
326 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
327 ; X32-NEXT: movzbl (%eax), %ebx
328 ; X32-NEXT: movzbl %bl, %esi
329 ; X32-NEXT: movl %esi, (%esp)
330 ; X32-NEXT: calll take_char
331 ; X32-NEXT: movsbl %bl, %eax
332 ; X32-NEXT: movl %eax, (%esp)
333 ; X32-NEXT: calll take_char
334 ; X32-NEXT: movl %esi, (%esp)
335 ; X32-NEXT: calll take_char
336 ; X32-NEXT: addl $4, %esp
337 ; X32-NEXT: .cfi_def_cfa_offset 12
338 ; X32-NEXT: popl %esi
339 ; X32-NEXT: .cfi_def_cfa_offset 8
340 ; X32-NEXT: popl %ebx
341 ; X32-NEXT: .cfi_def_cfa_offset 4
344 ; X64-LABEL: test_abi_exts_call:
346 ; X64-NEXT: pushq %rbx
347 ; X64-NEXT: .cfi_def_cfa_offset 16
348 ; X64-NEXT: .cfi_offset %rbx, -16
349 ; X64-NEXT: movzbl (%rdi), %eax
350 ; X64-NEXT: movzbl %al, %ebx
351 ; X64-NEXT: movl %ebx, %edi
352 ; X64-NEXT: callq take_char
353 ; X64-NEXT: movsbl %bl, %edi
354 ; X64-NEXT: callq take_char
355 ; X64-NEXT: movl %ebx, %edi
356 ; X64-NEXT: callq take_char
357 ; X64-NEXT: popq %rbx
358 ; X64-NEXT: .cfi_def_cfa_offset 8
360 %val = load i8, ptr %addr
361 call void @take_char(i8 %val)
362 call void @take_char(i8 signext %val)
363 call void @take_char(i8 zeroext %val)
367 declare void @variadic_callee(ptr, ...)
368 define void @test_variadic_call_1(ptr %addr_ptr, ptr %val_ptr) {
369 ; X32-LABEL: test_variadic_call_1:
371 ; X32-NEXT: subl $12, %esp
372 ; X32-NEXT: .cfi_def_cfa_offset 16
373 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
374 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
375 ; X32-NEXT: movl (%eax), %eax
376 ; X32-NEXT: movl (%ecx), %ecx
377 ; X32-NEXT: movl %eax, (%esp)
378 ; X32-NEXT: movl %ecx, {{[0-9]+}}(%esp)
379 ; X32-NEXT: calll variadic_callee
380 ; X32-NEXT: addl $12, %esp
381 ; X32-NEXT: .cfi_def_cfa_offset 4
384 ; X64-LABEL: test_variadic_call_1:
386 ; X64-NEXT: pushq %rax
387 ; X64-NEXT: .cfi_def_cfa_offset 16
388 ; X64-NEXT: movq (%rdi), %rdi
389 ; X64-NEXT: movl (%rsi), %esi
390 ; X64-NEXT: movb $0, %al
391 ; X64-NEXT: callq variadic_callee
392 ; X64-NEXT: popq %rax
393 ; X64-NEXT: .cfi_def_cfa_offset 8
396 %addr = load ptr, ptr %addr_ptr
397 %val = load i32, ptr %val_ptr
398 call void (ptr, ...) @variadic_callee(ptr %addr, i32 %val)
402 define void @test_variadic_call_2(ptr %addr_ptr, ptr %val_ptr) {
403 ; X32-LABEL: test_variadic_call_2:
405 ; X32-NEXT: subl $12, %esp
406 ; X32-NEXT: .cfi_def_cfa_offset 16
407 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
408 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
409 ; X32-NEXT: movl (%eax), %eax
410 ; X32-NEXT: movl (%ecx), %edx
411 ; X32-NEXT: movl 4(%ecx), %ecx
412 ; X32-NEXT: movl %eax, (%esp)
413 ; X32-NEXT: movl $4, %eax
414 ; X32-NEXT: addl %esp, %eax
415 ; X32-NEXT: movl %edx, {{[0-9]+}}(%esp)
416 ; X32-NEXT: movl %ecx, 4(%eax)
417 ; X32-NEXT: calll variadic_callee
418 ; X32-NEXT: addl $12, %esp
419 ; X32-NEXT: .cfi_def_cfa_offset 4
422 ; X64-LABEL: test_variadic_call_2:
424 ; X64-NEXT: pushq %rax
425 ; X64-NEXT: .cfi_def_cfa_offset 16
426 ; X64-NEXT: movq (%rdi), %rdi
427 ; X64-NEXT: movq (%rsi), %rax
428 ; X64-NEXT: movq %rax, %xmm0
429 ; X64-NEXT: movb $1, %al
430 ; X64-NEXT: callq variadic_callee
431 ; X64-NEXT: popq %rax
432 ; X64-NEXT: .cfi_def_cfa_offset 8
435 %addr = load ptr, ptr %addr_ptr
436 %val = load double, ptr %val_ptr
437 call void (ptr, ...) @variadic_callee(ptr %addr, double %val)