1 ; RUN: llc -march=sparc < %s | FileCheck %s -check-prefix=V8 -check-prefix=V8-BE
2 ; RUN: llc -march=sparcel < %s | FileCheck %s -check-prefix=V8 -check-prefix=V8-EL
3 ; RUN: llc -march=sparc -O0 < %s | FileCheck %s -check-prefix=V8-UNOPT
4 ; RUN: llc -march=sparc -mattr=v9 < %s | FileCheck %s -check-prefix=V9
5 ; RUN: llc -mtriple=sparc64-unknown-linux < %s | FileCheck %s -check-prefix=SPARC64
9 ; V8-BE: fnegs %f0, %f0
10 ; V8-EL: fnegs %f1, %f1
12 ; V8-UNOPT-LABEL: test_neg:
14 ; V8-UNOPT: ! implicit-def
15 ; V8-UNOPT: fmovs {{.+}}, %f0
16 ; V8-UNOPT: fmovs {{.+}}, %f1
21 ; SPARC64-LABEL: test_neg:
22 ; SPARC64: fnegd %f0, %f0
24 define double @test_neg() {
26 %0 = tail call double @get_double()
27 %1 = fsub double -0.000000e+00, %0
32 ; V8-BE: fabss %f0, %f0
33 ; V8-EL: fabss %f1, %f1
35 ; V8-UNOPT-LABEL: test_abs:
37 ; V8-UNOPT: ! implicit-def
38 ; V8-UNOPT: fmovs {{.+}}, %f0
39 ; V8-UNOPT: fmovs {{.+}}, %f1
45 ; SPARC64-LABEL: test_abs:
46 ; SPARC64: fabsd %f0, %f0
48 define double @test_abs() {
50 %0 = tail call double @get_double()
51 %1 = tail call double @llvm.fabs.f64(double %0)
55 declare double @get_double()
56 declare double @llvm.fabs.f64(double) nounwind readonly
58 ; V8-LABEL: test_v9_floatreg:
59 ; V8: fsubd {{.+}}, {{.+}}, [[R:%f(((1|2)?(0|2|4|6|8))|30)]]
60 ; V8: std [[R]], [%{{.+}}]
61 ; V8: ldd [%{{.+}}], %f0
62 ; V8: faddd {{.+}}, {{.+}}, {{.+}}
64 ; V9-LABEL: test_v9_floatreg:
65 ; V9: fsubd {{.+}}, {{.+}}, {{.+}}
66 ; V9: faddd {{.+}}, {{.+}}, %f0
68 ; SPARC64-LABEL: test_v9_floatreg:
69 ; SPARC64: fsubd {{.+}}, {{.+}}, {{.+}}
70 ; SPARC64: faddd {{.+}}, {{.+}}, %f0
72 define double @test_v9_floatreg() {
74 %0 = tail call double @get_double()
75 %1 = tail call double @get_double()
76 %2 = fsub double %0, %1
77 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}"()
78 %3 = fadd double %2, %2
82 ; V8-LABEL: test_xtos_stox
83 ; V8: call __floatdisf
86 ; V9-LABEL: test_xtos_stox
87 ; V9: call __floatdisf
90 ; SPARC64-LABEL: test_xtos_stox
94 define void @test_xtos_stox(i64 %a, i64* %ptr0, float* %ptr1) {
96 %0 = sitofp i64 %a to float
97 store float %0, float* %ptr1, align 8
98 %1 = fptosi float %0 to i64
99 store i64 %1, i64* %ptr0, align 8
103 ; V8-LABEL: test_itos_stoi
107 ; V9-LABEL: test_itos_stoi
111 ; SPARC64-LABEL: test_itos_stoi
115 define void @test_itos_stoi(i32 %a, i32* %ptr0, float* %ptr1) {
117 %0 = sitofp i32 %a to float
118 store float %0, float* %ptr1, align 8
119 %1 = fptosi float %0 to i32
120 store i32 %1, i32* %ptr0, align 8
125 ; V8-LABEL: test_xtod_dtox
126 ; V8: call __floatdidf
129 ; V9-LABEL: test_xtod_dtox
130 ; V9: call __floatdidf
133 ; SPARC64-LABEL: test_xtod_dtox
137 define void @test_xtod_dtox(i64 %a, i64* %ptr0, double* %ptr1) {
139 %0 = sitofp i64 %a to double
140 store double %0, double* %ptr1, align 8
141 %1 = fptosi double %0 to i64
142 store i64 %1, i64* %ptr0, align 8
146 ; V8-LABEL: test_itod_dtoi
150 ; V9-LABEL: test_itod_dtoi
154 ; SPARC64-LABEL: test_itod_dtoi
158 define void @test_itod_dtoi(i32 %a, double %b, i32* %ptr0, double* %ptr1) {
160 %0 = sitofp i32 %a to double
161 store double %0, double* %ptr1, align 8
162 %1 = fptosi double %b to i32
163 store i32 %1, i32* %ptr0, align 8
167 ; V8-LABEL: test_uxtos_stoux
168 ; V8: call __floatundisf
169 ; V8: call __fixunssfdi
171 ; V9-LABEL: test_uxtos_stoux
172 ; V9: call __floatundisf
173 ; V9: call __fixunssfdi
175 ; SPARC64-LABEL: test_uxtos_stoux
176 ; SPARC64-NOT: call __floatundisf
177 ; SPARC64-NOT: call __fixunssfdi
179 define void @test_uxtos_stoux(i64 %a, i64* %ptr0, float* %ptr1) {
181 %0 = uitofp i64 %a to float
182 store float %0, float* %ptr1, align 8
183 %1 = fptoui float %0 to i64
184 store i64 %1, i64* %ptr0, align 8
188 ; V8-LABEL: test_utos_stou
192 ; V9-LABEL: test_utos_stou
196 ; SPARC64-LABEL: test_utos_stou
200 define void @test_utos_stou(i32 %a, i32* %ptr0, float* %ptr1) {
202 %0 = uitofp i32 %a to float
203 store float %0, float* %ptr1, align 8
204 %1 = fptoui float %0 to i32
205 store i32 %1, i32* %ptr0, align 8
210 ; V8-LABEL: test_uxtod_dtoux
211 ; V8: call __floatundidf
212 ; V8: call __fixunsdfdi
214 ; V9-LABEL: test_uxtod_dtoux
215 ; V9: call __floatundidf
216 ; V9: call __fixunsdfdi
218 ; SPARC64-LABEL: test_uxtod_dtoux
219 ; SPARC64-NOT: call __floatundidf
220 ; SPARC64-NOT: call __floatunsdfdi
222 define void @test_uxtod_dtoux(i64 %a, i64* %ptr0, double* %ptr1) {
224 %0 = uitofp i64 %a to double
225 store double %0, double* %ptr1, align 8
226 %1 = fptoui double %0 to i64
227 store i64 %1, i64* %ptr0, align 8
231 ; V8-LABEL: test_utod_dtou
235 ; V9-LABEL: test_utod_dtou
239 ; SPARC64-LABEL: test_utod_dtou
243 define void @test_utod_dtou(i32 %a, double %b, i32* %ptr0, double* %ptr1) {
245 %0 = uitofp i32 %a to double
246 store double %0, double* %ptr1, align 8
247 %1 = fptoui double %b to i32
248 store i32 %1, i32* %ptr0, align 8