blob: d7a79cb05a82c51e5ef5ce885eafdb64f73502a0 [file] [log] [blame]
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +00001; RUN: llc -march=sparc < %s | FileCheck %s -check-prefix=V8
2; RUN: llc -march=sparc -O0 < %s | FileCheck %s -check-prefix=V8-UNOPT
3; RUN: llc -march=sparc -mattr=v9 < %s | FileCheck %s -check-prefix=V9
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +00004; RUN: llc -mtriple=sparc64-unknown-linux < %s | FileCheck %s -check-prefix=SPARC64
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +00005
Stephen Linf799e3f2013-07-13 20:38:47 +00006; V8-LABEL: test_neg:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +00007; V8: call get_double
8; V8: fnegs %f0, %f0
9
Stephen Lind24ab202013-07-14 06:24:09 +000010; V8-UNOPT-LABEL: test_neg:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000011; V8-UNOPT: fnegs
12; V8-UNOPT: ! implicit-def
13; V8-UNOPT: fmovs {{.+}}, %f0
14; V8-UNOPT: fmovs {{.+}}, %f1
15
Stephen Linf799e3f2013-07-13 20:38:47 +000016; V9-LABEL: test_neg:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000017; V9: fnegd %f0, %f0
18
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000019; SPARC64-LABEL: test_neg:
20; SPARC64: fnegd %f0, %f0
21
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000022define double @test_neg() {
23entry:
24 %0 = tail call double @get_double()
25 %1 = fsub double -0.000000e+00, %0
26 ret double %1
27}
28
Stephen Linf799e3f2013-07-13 20:38:47 +000029; V8-LABEL: test_abs:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000030; V8: fabss %f0, %f0
31
Stephen Lind24ab202013-07-14 06:24:09 +000032; V8-UNOPT-LABEL: test_abs:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000033; V8-UNOPT: fabss
34; V8-UNOPT: ! implicit-def
35; V8-UNOPT: fmovs {{.+}}, %f0
36; V8-UNOPT: fmovs {{.+}}, %f1
37
Stephen Linf799e3f2013-07-13 20:38:47 +000038; V9-LABEL: test_abs:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000039; V9: fabsd %f0, %f0
40
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000041
42; SPARC64-LABEL: test_abs:
43; SPARC64: fabsd %f0, %f0
44
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000045define double @test_abs() {
46entry:
47 %0 = tail call double @get_double()
48 %1 = tail call double @llvm.fabs.f64(double %0)
49 ret double %1
50}
51
52declare double @get_double()
53declare double @llvm.fabs.f64(double) nounwind readonly
54
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000055; V8-LABEL: test_v9_floatreg:
56; V8: fsubd {{.+}}, {{.+}}, {{.+}}
57; V8: faddd {{.+}}, {{.+}}, [[R:%f(((1|2)?(0|2|4|6|8))|30)]]
58; V8: std [[R]], [%{{.+}}]
59; V8: ldd [%{{.+}}], %f0
60
61; V9-LABEL: test_v9_floatreg:
62; V9: fsubd {{.+}}, {{.+}}, {{.+}}
63; V9: faddd {{.+}}, {{.+}}, [[R:%f((3(2|4|6|8))|((4|5)(0|2|4|6|8))|(60|62))]]
64; V9: fmovd [[R]], %f0
65
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000066; SPARC64-LABEL: test_v9_floatreg:
67; SPARC64: fsubd {{.+}}, {{.+}}, {{.+}}
68; SPARC64: faddd {{.+}}, {{.+}}, [[R:%f((3(2|4|6|8))|((4|5)(0|2|4|6|8))|(60|62))]]
69; SPARC64: fmovd [[R]], %f0
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000070
71define double @test_v9_floatreg() {
72entry:
73 %0 = tail call double @get_double()
74 %1 = tail call double @get_double()
75 %2 = fsub double %0, %1
76 tail call void asm sideeffect "", "~{f0},~{f2},~{f3},~{f4},~{f5},~{f6},~{f7},~{f8},~{f9},~{f10},~{f11},~{f12},~{f13},~{f14},~{f15},~{f16},~{f17},~{f18},~{f19},~{f20},~{f21},~{f22},~{f23},~{f24},~{f25},~{f26},~{f27},~{f28},~{f29},~{f30},~{f31}"()
77 %3 = fadd double %2, %2
78 ret double %3
79}
80
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000081; V8-LABEL: test_xtos_stox
82; V8: call __floatdisf
83; V8: call __fixsfdi
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000084
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000085; V9-LABEL: test_xtos_stox
86; V9: call __floatdisf
87; V9: call __fixsfdi
88
89; SPARC64-LABEL: test_xtos_stox
90; SPARC64: fxtos
91; SPARC64: fstox
92
93define void @test_xtos_stox(i64 %a, i64* %ptr0, float* %ptr1) {
94entry:
95 %0 = sitofp i64 %a to float
96 store float %0, float* %ptr1, align 8
97 %1 = fptosi float %0 to i64
98 store i64 %1, i64* %ptr0, align 8
99 ret void
100}
101
102; V8-LABEL: test_itos_stoi
103; V8: fitos
104; V8: fstoi
105
106; V9-LABEL: test_itos_stoi
107; V9: fitos
108; V9: fstoi
109
110; SPARC64-LABEL: test_itos_stoi
111; SPARC64: fitos
112; SPARC64: fstoi
113
114define void @test_itos_stoi(i32 %a, i32* %ptr0, float* %ptr1) {
115entry:
116 %0 = sitofp i32 %a to float
117 store float %0, float* %ptr1, align 8
118 %1 = fptosi float %0 to i32
119 store i32 %1, i32* %ptr0, align 8
120 ret void
121}
122
123
124; V8-LABEL: test_xtod_dtox
125; V8: call __floatdidf
126; V8: call __fixdfdi
127
128; V9-LABEL: test_xtod_dtox
129; V9: call __floatdidf
130; V9: call __fixdfdi
131
132; SPARC64-LABEL: test_xtod_dtox
133; SPARC64: fxtod
134; SPARC64: fdtox
135
136define void @test_xtod_dtox(i64 %a, i64* %ptr0, double* %ptr1) {
137entry:
138 %0 = sitofp i64 %a to double
139 store double %0, double* %ptr1, align 8
140 %1 = fptosi double %0 to i64
141 store i64 %1, i64* %ptr0, align 8
142 ret void
143}
144
145; V8-LABEL: test_itod_dtoi
146; V8: fitod
147; V8: fdtoi
148
149; V9-LABEL: test_itod_dtoi
150; V9: fitod
151; V9: fdtoi
152
153; SPARC64-LABEL: test_itod_dtoi
154; SPARC64: fitod
155; SPARC64: fdtoi
156
Mehdi Amini3e0023b2015-02-16 21:47:58 +0000157define void @test_itod_dtoi(i32 %a, double %b, i32* %ptr0, double* %ptr1) {
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +0000158entry:
159 %0 = sitofp i32 %a to double
160 store double %0, double* %ptr1, align 8
Mehdi Amini3e0023b2015-02-16 21:47:58 +0000161 %1 = fptosi double %b to i32
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +0000162 store i32 %1, i32* %ptr0, align 8
163 ret void
164}
165
166; V8-LABEL: test_uxtos_stoux
167; V8: call __floatundisf
168; V8: call __fixunssfdi
169
170; V9-LABEL: test_uxtos_stoux
171; V9: call __floatundisf
172; V9: call __fixunssfdi
173
174; SPARC64-LABEL: test_uxtos_stoux
175; SPARC64-NOT: call __floatundisf
176; SPARC64-NOT: call __fixunssfdi
177
178define void @test_uxtos_stoux(i64 %a, i64* %ptr0, float* %ptr1) {
179entry:
180 %0 = uitofp i64 %a to float
181 store float %0, float* %ptr1, align 8
182 %1 = fptoui float %0 to i64
183 store i64 %1, i64* %ptr0, align 8
184 ret void
185}
186
187; V8-LABEL: test_utos_stou
188; V8: fdtos
189; V8: fstoi
190
191; V9-LABEL: test_utos_stou
192; V9: fdtos
193; V9: fstoi
194
195; SPARC64-LABEL: test_utos_stou
196; SPARC64: fdtos
197; SPARC64: fstoi
198
199define void @test_utos_stou(i32 %a, i32* %ptr0, float* %ptr1) {
200entry:
201 %0 = uitofp i32 %a to float
202 store float %0, float* %ptr1, align 8
203 %1 = fptoui float %0 to i32
204 store i32 %1, i32* %ptr0, align 8
205 ret void
206}
207
208
209; V8-LABEL: test_uxtod_dtoux
210; V8: call __floatundidf
211; V8: call __fixunsdfdi
212
213; V9-LABEL: test_uxtod_dtoux
214; V9: call __floatundidf
215; V9: call __fixunsdfdi
216
217; SPARC64-LABEL: test_uxtod_dtoux
218; SPARC64-NOT: call __floatundidf
219; SPARC64-NOT: call __floatunsdfdi
220
221define void @test_uxtod_dtoux(i64 %a, i64* %ptr0, double* %ptr1) {
222entry:
223 %0 = uitofp i64 %a to double
224 store double %0, double* %ptr1, align 8
225 %1 = fptoui double %0 to i64
226 store i64 %1, i64* %ptr0, align 8
227 ret void
228}
229
230; V8-LABEL: test_utod_dtou
231; V8-NOT: fitod
232; V8: fdtoi
233
234; V9-LABEL: test_utod_dtou
235; V9-NOT: fitod
236; V9: fdtoi
237
238; SPARC64-LABEL: test_utod_dtou
239; SPARC64-NOT: fitod
240; SPARC64: fdtoi
241
242define void @test_utod_dtou(i32 %a, double %b, i32* %ptr0, double* %ptr1) {
243entry:
244 %0 = uitofp i32 %a to double
245 store double %0, double* %ptr1, align 8
246 %1 = fptoui double %b to i32
247 store i32 %1, i32* %ptr0, align 8
248 ret void
249}