• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-pc-elfiamcu | FileCheck %s
3
4%struct.st12_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
5
6define i32 @test_ints(i32 %a, i32 %b, i32 %c, i32 %d) #0 {
7; CHECK-LABEL: test_ints:
8; CHECK:       # %bb.0: # %entry
9; CHECK-NEXT:    addl %edx, %eax
10; CHECK-NEXT:    imull %ecx, %eax
11; CHECK-NEXT:    addl {{[0-9]+}}(%esp), %eax
12; CHECK-NEXT:    retl
13entry:
14  %r1 = add i32 %b, %a
15  %r2 = mul i32 %c, %r1
16  %r3 = add i32 %d, %r2
17  ret i32 %r3
18}
19
20define i32 @test_floats(i32 %a, i32 %b, float %c, float %d) #0 {
21; CHECK-LABEL: test_floats:
22; CHECK:       # %bb.0: # %entry
23; CHECK-NEXT:    addl %edx, %eax
24; CHECK-NEXT:    imull %ecx, %eax
25; CHECK-NEXT:    addl {{[0-9]+}}(%esp), %eax
26; CHECK-NEXT:    retl
27entry:
28  %ci = bitcast float %c to i32
29  %di = bitcast float %d to i32
30  %r1 = add i32 %b, %a
31  %r2 = mul i32 %ci, %r1
32  %r3 = add i32 %di, %r2
33  ret i32 %r3
34}
35
36define double @test_doubles(double %d1, double %d2) #0 {
37; CHECK-LABEL: test_doubles:
38; CHECK:       # %bb.0: # %entry
39; CHECK-NEXT:    addl {{[0-9]+}}(%esp), %eax
40; CHECK-NEXT:    adcl {{[0-9]+}}(%esp), %edx
41; CHECK-NEXT:    retl
42entry:
43    %d1i = bitcast double %d1 to i64
44    %d2i = bitcast double %d2 to i64
45    %r = add i64 %d1i, %d2i
46    %rd = bitcast i64 %r to double
47    ret double %rd
48}
49
50define double @test_mixed_doubles(double %d2, i32 %i) #0 {
51; CHECK-LABEL: test_mixed_doubles:
52; CHECK:       # %bb.0: # %entry
53; CHECK-NEXT:    addl %ecx, %eax
54; CHECK-NEXT:    adcl $0, %edx
55; CHECK-NEXT:    retl
56entry:
57    %iext = zext i32 %i to i64
58    %d2i = bitcast double %d2 to i64
59    %r = add i64 %iext, %d2i
60    %rd = bitcast i64 %r to double
61    ret double %rd
62}
63
64define void @ret_large_struct(%struct.st12_t* noalias nocapture sret(%struct.st12_t) %agg.result, %struct.st12_t* byval(%struct.st12_t) nocapture readonly align 4 %r) #0 {
65; CHECK-LABEL: ret_large_struct:
66; CHECK:       # %bb.0: # %entry
67; CHECK-NEXT:    pushl %esi
68; CHECK-NEXT:    movl %eax, %esi
69; CHECK-NEXT:    leal {{[0-9]+}}(%esp), %edx
70; CHECK-NEXT:    movl $48, %ecx
71; CHECK-NEXT:    calll memcpy
72; CHECK-NEXT:    movl %esi, %eax
73; CHECK-NEXT:    popl %esi
74; CHECK-NEXT:    retl
75entry:
76  %0 = bitcast %struct.st12_t* %agg.result to i8*
77  %1 = bitcast %struct.st12_t* %r to i8*
78  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 48, i1 false)
79  ret void
80}
81
82define i32 @var_args(i32 %i1, ...) #0 {
83; CHECK-LABEL: var_args:
84; CHECK:       # %bb.0: # %entry
85; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
86; CHECK-NEXT:    retl
87entry:
88  ret i32 %i1
89}
90
91%struct.S = type { i8 }
92
93define i32 @test_lib_args(float %a, float %b) #0 {
94; CHECK-LABEL: test_lib_args:
95; CHECK:       # %bb.0:
96; CHECK-NEXT:    movl %edx, %eax
97; CHECK-NEXT:    calll __fixsfsi
98; CHECK-NEXT:    retl
99  %ret = fptosi float %b to i32
100  ret i32 %ret
101}
102
103define i32 @test_fp128(fp128* %ptr) #0 {
104; CHECK-LABEL: test_fp128:
105; CHECK:       # %bb.0:
106; CHECK-NEXT:    pushl 12(%eax)
107; CHECK-NEXT:    pushl 8(%eax)
108; CHECK-NEXT:    pushl 4(%eax)
109; CHECK-NEXT:    pushl (%eax)
110; CHECK-NEXT:    calll __fixtfsi
111; CHECK-NEXT:    addl $16, %esp
112; CHECK-NEXT:    retl
113  %v = load fp128, fp128* %ptr
114  %ret = fptosi fp128 %v to i32
115  ret i32 %ret
116}
117
118declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1) #1
119
120define void @test_alignment_d() #0 {
121; CHECK-LABEL: test_alignment_d:
122; CHECK:       # %bb.0: # %entry
123; CHECK-NEXT:    subl $8, %esp
124; CHECK-NEXT:    movl $1073741824, {{[0-9]+}}(%esp) # imm = 0x40000000
125; CHECK-NEXT:    movl $0, (%esp)
126; CHECK-NEXT:    movl %esp, %eax
127; CHECK-NEXT:    calll food
128; CHECK-NEXT:    addl $8, %esp
129; CHECK-NEXT:    retl
130entry:
131  %d = alloca double
132  store double 2.000000e+00, double* %d
133  call void @food(double* inreg %d)
134  ret void
135}
136
137define void @test_alignment_i() #0 {
138; CHECK-LABEL: test_alignment_i:
139; CHECK:       # %bb.0: # %entry
140; CHECK-NEXT:    subl $8, %esp
141; CHECK-NEXT:    movl $0, {{[0-9]+}}(%esp)
142; CHECK-NEXT:    movl $2, (%esp)
143; CHECK-NEXT:    movl %esp, %eax
144; CHECK-NEXT:    calll fooi
145; CHECK-NEXT:    addl $8, %esp
146; CHECK-NEXT:    retl
147entry:
148  %i = alloca i64
149  store i64 2, i64* %i
150  call void @fooi(i64* inreg %i)
151  ret void
152}
153
154define void @test_alignment_s() #0 {
155; CHECK-LABEL: test_alignment_s:
156; CHECK:       # %bb.0:
157; CHECK-NEXT:    pushl %eax
158; CHECK-NEXT:    movl %esp, %eax
159; CHECK-NEXT:    calll foos
160; CHECK-NEXT:    popl %eax
161; CHECK-NEXT:    retl
162  %s = alloca %struct.S, align 4
163  call void @foos(%struct.S* inreg %s)
164  ret void
165}
166
167define void @test_alignment_fp() #0 {
168; CHECK-LABEL: test_alignment_fp:
169; CHECK:       # %bb.0: # %entry
170; CHECK-NEXT:    subl $16, %esp
171; CHECK-NEXT:    movl $1073741824, {{[0-9]+}}(%esp) # imm = 0x40000000
172; CHECK-NEXT:    movl $0, {{[0-9]+}}(%esp)
173; CHECK-NEXT:    movl $0, {{[0-9]+}}(%esp)
174; CHECK-NEXT:    movl $0, (%esp)
175; CHECK-NEXT:    movl %esp, %eax
176; CHECK-NEXT:    calll foofp
177; CHECK-NEXT:    addl $16, %esp
178; CHECK-NEXT:    retl
179entry:
180  %f = alloca fp128
181  store fp128 0xL00000000000000004000000000000000, fp128* %f
182  call void @foofp(fp128* inreg %f)
183  ret void
184}
185
186declare void @food(double* inreg)
187declare void @fooi(i64* inreg)
188declare void @foos(%struct.S* inreg)
189declare void @foofp(fp128* inreg)
190
191attributes #0 = { nounwind "use-soft-float"="true"}
192attributes #1 = { nounwind argmemonly }
193