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=ALL --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=ALL --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 $4294967295, %eax # imm = 0xFFFFFFFF
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: movb {{[0-9]+}}(%esp), %al
38 ; X64-LABEL: test_arg_i8:
40 ; X64-NEXT: movl %edi, %eax
41 ; X64-NEXT: # kill: def $al killed $al killed $eax
46 define i16 @test_arg_i16(i16 %a) {
47 ; X32-LABEL: test_arg_i16:
49 ; X32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
52 ; X64-LABEL: test_arg_i16:
54 ; X64-NEXT: movl %edi, %eax
55 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
60 define i32 @test_arg_i32(i32 %a) {
61 ; X32-LABEL: test_arg_i32:
63 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
66 ; X64-LABEL: test_arg_i32:
68 ; X64-NEXT: movl %edi, %eax
73 define i64 @test_arg_i64(i64 %a) {
74 ; X32-LABEL: test_arg_i64:
76 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
77 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
80 ; X64-LABEL: test_arg_i64:
82 ; X64-NEXT: movq %rdi, %rax
87 define i64 @test_i64_args_8(i64 %arg1, i64 %arg2, i64 %arg3, i64 %arg4, i64 %arg5, i64 %arg6, i64 %arg7, i64 %arg8) {
88 ; X32-LABEL: test_i64_args_8:
90 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
91 ; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
94 ; X64-LABEL: test_i64_args_8:
96 ; X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
101 define <4 x i32> @test_v4i32_args(<4 x i32> %arg1, <4 x i32> %arg2) {
102 ; X32-LABEL: test_v4i32_args:
104 ; X32-NEXT: movaps %xmm1, %xmm0
107 ; X64-LABEL: test_v4i32_args:
109 ; X64-NEXT: movaps %xmm1, %xmm0
114 define <8 x i32> @test_v8i32_args(<8 x i32> %arg1, <8 x i32> %arg2) {
115 ; X32-LABEL: test_v8i32_args:
117 ; X32-NEXT: subl $12, %esp
118 ; X32-NEXT: .cfi_def_cfa_offset 16
119 ; X32-NEXT: movaps %xmm2, %xmm0
120 ; X32-NEXT: movups {{[0-9]+}}(%esp), %xmm1
121 ; X32-NEXT: addl $12, %esp
122 ; X32-NEXT: .cfi_def_cfa_offset 4
125 ; X64-LABEL: test_v8i32_args:
127 ; X64-NEXT: movaps %xmm2, %xmm0
128 ; X64-NEXT: movaps %xmm3, %xmm1
133 declare void @trivial_callee()
134 define void @test_trivial_call() {
135 ; X32-LABEL: test_trivial_call:
137 ; X32-NEXT: subl $12, %esp
138 ; X32-NEXT: .cfi_def_cfa_offset 16
139 ; X32-NEXT: calll trivial_callee
140 ; X32-NEXT: addl $12, %esp
141 ; X32-NEXT: .cfi_def_cfa_offset 4
144 ; X64-LABEL: test_trivial_call:
146 ; X64-NEXT: pushq %rax
147 ; X64-NEXT: .cfi_def_cfa_offset 16
148 ; X64-NEXT: callq trivial_callee
149 ; X64-NEXT: popq %rax
150 ; X64-NEXT: .cfi_def_cfa_offset 8
152 call void @trivial_callee()
156 declare void @simple_arg_callee(i32 %in0, i32 %in1)
157 define void @test_simple_arg_call(i32 %in0, i32 %in1) {
158 ; X32-LABEL: test_simple_arg_call:
160 ; X32-NEXT: subl $12, %esp
161 ; X32-NEXT: .cfi_def_cfa_offset 16
162 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
163 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
164 ; X32-NEXT: movl %ecx, (%esp)
165 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
166 ; X32-NEXT: calll simple_arg_callee
167 ; X32-NEXT: addl $12, %esp
168 ; X32-NEXT: .cfi_def_cfa_offset 4
171 ; X64-LABEL: test_simple_arg_call:
173 ; X64-NEXT: pushq %rax
174 ; X64-NEXT: .cfi_def_cfa_offset 16
175 ; X64-NEXT: movl %edi, %eax
176 ; X64-NEXT: movl %esi, %edi
177 ; X64-NEXT: movl %eax, %esi
178 ; X64-NEXT: callq simple_arg_callee
179 ; X64-NEXT: popq %rax
180 ; X64-NEXT: .cfi_def_cfa_offset 8
182 call void @simple_arg_callee(i32 %in1, i32 %in0)
186 declare void @simple_arg8_callee(i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7, i32 %arg8)
187 define void @test_simple_arg8_call(i32 %in0) {
188 ; X32-LABEL: test_simple_arg8_call:
190 ; X32-NEXT: subl $44, %esp
191 ; X32-NEXT: .cfi_def_cfa_offset 48
192 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
193 ; X32-NEXT: movl %eax, (%esp)
194 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
195 ; X32-NEXT: movl %eax, {{[0-9]+}}(%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: calll simple_arg8_callee
202 ; X32-NEXT: addl $44, %esp
203 ; X32-NEXT: .cfi_def_cfa_offset 4
206 ; X64-LABEL: test_simple_arg8_call:
208 ; X64-NEXT: subq $24, %rsp
209 ; X64-NEXT: .cfi_def_cfa_offset 32
210 ; X64-NEXT: movl %edi, (%rsp)
211 ; X64-NEXT: movl %edi, {{[0-9]+}}(%rsp)
212 ; X64-NEXT: movl %edi, %esi
213 ; X64-NEXT: movl %edi, %edx
214 ; X64-NEXT: movl %edi, %ecx
215 ; X64-NEXT: movl %edi, %r8d
216 ; X64-NEXT: movl %edi, %r9d
217 ; X64-NEXT: callq simple_arg8_callee
218 ; X64-NEXT: addq $24, %rsp
219 ; X64-NEXT: .cfi_def_cfa_offset 8
221 call void @simple_arg8_callee(i32 %in0, i32 %in0, i32 %in0, i32 %in0,i32 %in0, i32 %in0, i32 %in0, i32 %in0)
225 declare i32 @simple_return_callee(i32 %in0)
226 define i32 @test_simple_return_callee() {
227 ; X32-LABEL: test_simple_return_callee:
229 ; X32-NEXT: subl $12, %esp
230 ; X32-NEXT: .cfi_def_cfa_offset 16
231 ; X32-NEXT: movl $5, %eax
232 ; X32-NEXT: movl %eax, (%esp)
233 ; X32-NEXT: calll simple_return_callee
234 ; X32-NEXT: addl %eax, %eax
235 ; X32-NEXT: addl $12, %esp
236 ; X32-NEXT: .cfi_def_cfa_offset 4
239 ; X64-LABEL: test_simple_return_callee:
241 ; X64-NEXT: pushq %rax
242 ; X64-NEXT: .cfi_def_cfa_offset 16
243 ; X64-NEXT: movl $5, %edi
244 ; X64-NEXT: callq simple_return_callee
245 ; X64-NEXT: addl %eax, %eax
246 ; X64-NEXT: popq %rcx
247 ; X64-NEXT: .cfi_def_cfa_offset 8
249 %call = call i32 @simple_return_callee(i32 5)
250 %r = add i32 %call, %call
254 declare <8 x i32> @split_return_callee(<8 x i32> %in0)
255 define <8 x i32> @test_split_return_callee(<8 x i32> %arg1, <8 x i32> %arg2) {
256 ; X32-LABEL: test_split_return_callee:
258 ; X32-NEXT: subl $44, %esp
259 ; X32-NEXT: .cfi_def_cfa_offset 48
260 ; X32-NEXT: movaps %xmm0, (%esp) # 16-byte Spill
261 ; X32-NEXT: movaps %xmm1, {{[0-9]+}}(%esp) # 16-byte Spill
262 ; X32-NEXT: movdqa %xmm2, %xmm0
263 ; X32-NEXT: movdqu {{[0-9]+}}(%esp), %xmm1
264 ; X32-NEXT: calll split_return_callee
265 ; X32-NEXT: paddd (%esp), %xmm0 # 16-byte Folded Reload
266 ; X32-NEXT: paddd {{[0-9]+}}(%esp), %xmm1 # 16-byte Folded Reload
267 ; X32-NEXT: addl $44, %esp
268 ; X32-NEXT: .cfi_def_cfa_offset 4
271 ; X64-LABEL: test_split_return_callee:
273 ; X64-NEXT: subq $40, %rsp
274 ; X64-NEXT: .cfi_def_cfa_offset 48
275 ; X64-NEXT: movaps %xmm0, (%rsp) # 16-byte Spill
276 ; X64-NEXT: movaps %xmm1, {{[0-9]+}}(%rsp) # 16-byte Spill
277 ; X64-NEXT: movdqa %xmm2, %xmm0
278 ; X64-NEXT: movdqa %xmm3, %xmm1
279 ; X64-NEXT: callq split_return_callee
280 ; X64-NEXT: paddd (%rsp), %xmm0 # 16-byte Folded Reload
281 ; X64-NEXT: paddd {{[0-9]+}}(%rsp), %xmm1 # 16-byte Folded Reload
282 ; X64-NEXT: addq $40, %rsp
283 ; X64-NEXT: .cfi_def_cfa_offset 8
285 %call = call <8 x i32> @split_return_callee(<8 x i32> %arg2)
286 %r = add <8 x i32> %arg1, %call
290 define void @test_indirect_call(void()* %func) {
291 ; X32-LABEL: test_indirect_call:
293 ; X32-NEXT: subl $12, %esp
294 ; X32-NEXT: .cfi_def_cfa_offset 16
295 ; X32-NEXT: calll *{{[0-9]+}}(%esp)
296 ; X32-NEXT: addl $12, %esp
297 ; X32-NEXT: .cfi_def_cfa_offset 4
300 ; X64-LABEL: test_indirect_call:
302 ; X64-NEXT: pushq %rax
303 ; X64-NEXT: .cfi_def_cfa_offset 16
304 ; X64-NEXT: callq *%rdi
305 ; X64-NEXT: popq %rax
306 ; X64-NEXT: .cfi_def_cfa_offset 8
312 declare void @take_char(i8)
313 define void @test_abi_exts_call(i8* %addr) {
314 ; X32-LABEL: test_abi_exts_call:
316 ; X32-NEXT: pushl %ebx
317 ; X32-NEXT: .cfi_def_cfa_offset 8
318 ; X32-NEXT: pushl %esi
319 ; X32-NEXT: .cfi_def_cfa_offset 12
320 ; X32-NEXT: pushl %eax
321 ; X32-NEXT: .cfi_def_cfa_offset 16
322 ; X32-NEXT: .cfi_offset %esi, -12
323 ; X32-NEXT: .cfi_offset %ebx, -8
324 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
325 ; X32-NEXT: movb (%eax), %bl
326 ; X32-NEXT: movzbl %bl, %esi
327 ; X32-NEXT: movl %esi, (%esp)
328 ; X32-NEXT: calll take_char
329 ; X32-NEXT: movsbl %bl, %eax
330 ; X32-NEXT: movl %eax, (%esp)
331 ; X32-NEXT: calll take_char
332 ; X32-NEXT: movl %esi, (%esp)
333 ; X32-NEXT: calll take_char
334 ; X32-NEXT: addl $4, %esp
335 ; X32-NEXT: .cfi_def_cfa_offset 12
336 ; X32-NEXT: popl %esi
337 ; X32-NEXT: .cfi_def_cfa_offset 8
338 ; X32-NEXT: popl %ebx
339 ; X32-NEXT: .cfi_def_cfa_offset 4
342 ; X64-LABEL: test_abi_exts_call:
344 ; X64-NEXT: pushq %rbx
345 ; X64-NEXT: .cfi_def_cfa_offset 16
346 ; X64-NEXT: .cfi_offset %rbx, -16
347 ; X64-NEXT: movb (%rdi), %al
348 ; X64-NEXT: movzbl %al, %ebx
349 ; X64-NEXT: movl %ebx, %edi
350 ; X64-NEXT: callq take_char
351 ; X64-NEXT: movsbl %bl, %edi
352 ; X64-NEXT: callq take_char
353 ; X64-NEXT: movl %ebx, %edi
354 ; X64-NEXT: callq take_char
355 ; X64-NEXT: popq %rbx
356 ; X64-NEXT: .cfi_def_cfa_offset 8
358 %val = load i8, i8* %addr
359 call void @take_char(i8 %val)
360 call void @take_char(i8 signext %val)
361 call void @take_char(i8 zeroext %val)
365 declare void @variadic_callee(i8*, ...)
366 define void @test_variadic_call_1(i8** %addr_ptr, i32* %val_ptr) {
367 ; X32-LABEL: test_variadic_call_1:
369 ; X32-NEXT: subl $12, %esp
370 ; X32-NEXT: .cfi_def_cfa_offset 16
371 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
372 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
373 ; X32-NEXT: movl (%eax), %eax
374 ; X32-NEXT: movl (%ecx), %ecx
375 ; X32-NEXT: movl %eax, (%esp)
376 ; X32-NEXT: movl %ecx, {{[0-9]+}}(%esp)
377 ; X32-NEXT: calll variadic_callee
378 ; X32-NEXT: addl $12, %esp
379 ; X32-NEXT: .cfi_def_cfa_offset 4
382 ; X64-LABEL: test_variadic_call_1:
384 ; X64-NEXT: pushq %rax
385 ; X64-NEXT: .cfi_def_cfa_offset 16
386 ; X64-NEXT: movq (%rdi), %rdi
387 ; X64-NEXT: movl (%rsi), %esi
388 ; X64-NEXT: movb $0, %al
389 ; X64-NEXT: callq variadic_callee
390 ; X64-NEXT: popq %rax
391 ; X64-NEXT: .cfi_def_cfa_offset 8
394 %addr = load i8*, i8** %addr_ptr
395 %val = load i32, i32* %val_ptr
396 call void (i8*, ...) @variadic_callee(i8* %addr, i32 %val)
400 define void @test_variadic_call_2(i8** %addr_ptr, double* %val_ptr) {
401 ; X32-LABEL: test_variadic_call_2:
403 ; X32-NEXT: subl $12, %esp
404 ; X32-NEXT: .cfi_def_cfa_offset 16
405 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
406 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
407 ; X32-NEXT: movl (%eax), %eax
408 ; X32-NEXT: movl (%ecx), %edx
409 ; X32-NEXT: movl 4(%ecx), %ecx
410 ; X32-NEXT: movl %eax, (%esp)
411 ; X32-NEXT: movl $4, %eax
412 ; X32-NEXT: addl %esp, %eax
413 ; X32-NEXT: movl %edx, {{[0-9]+}}(%esp)
414 ; X32-NEXT: movl %ecx, 4(%eax)
415 ; X32-NEXT: calll variadic_callee
416 ; X32-NEXT: addl $12, %esp
417 ; X32-NEXT: .cfi_def_cfa_offset 4
420 ; X64-LABEL: test_variadic_call_2:
422 ; X64-NEXT: pushq %rax
423 ; X64-NEXT: .cfi_def_cfa_offset 16
424 ; X64-NEXT: movq (%rdi), %rdi
425 ; X64-NEXT: movq (%rsi), %rax
426 ; X64-NEXT: movq %rax, %xmm0
427 ; X64-NEXT: movb $1, %al
428 ; X64-NEXT: callq variadic_callee
429 ; X64-NEXT: popq %rax
430 ; X64-NEXT: .cfi_def_cfa_offset 8
433 %addr = load i8*, i8** %addr_ptr
434 %val = load double, double* %val_ptr
435 call void (i8*, ...) @variadic_callee(i8* %addr, double %val)