blob: 248e98549c9f7d92847862a176609a3ae35a2f38 [file] [log] [blame]
James Y Knight51208ea2016-04-25 22:54:09 +00001; 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
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +00003; 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
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +00005; RUN: llc -mtriple=sparc64-unknown-linux < %s | FileCheck %s -check-prefix=SPARC64
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +00006
Stephen Linf799e3f2013-07-13 20:38:47 +00007; V8-LABEL: test_neg:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +00008; V8: call get_double
James Y Knight51208ea2016-04-25 22:54:09 +00009; V8-BE: fnegs %f0, %f0
10; V8-EL: fnegs %f1, %f1
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000011
Stephen Lind24ab202013-07-14 06:24:09 +000012; V8-UNOPT-LABEL: test_neg:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000013; V8-UNOPT: fnegs
14; V8-UNOPT: ! implicit-def
15; V8-UNOPT: fmovs {{.+}}, %f0
16; V8-UNOPT: fmovs {{.+}}, %f1
17
Stephen Linf799e3f2013-07-13 20:38:47 +000018; V9-LABEL: test_neg:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000019; V9: fnegd %f0, %f0
20
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000021; SPARC64-LABEL: test_neg:
22; SPARC64: fnegd %f0, %f0
23
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000024define double @test_neg() {
25entry:
26 %0 = tail call double @get_double()
27 %1 = fsub double -0.000000e+00, %0
28 ret double %1
29}
30
Stephen Linf799e3f2013-07-13 20:38:47 +000031; V8-LABEL: test_abs:
James Y Knight51208ea2016-04-25 22:54:09 +000032; V8-BE: fabss %f0, %f0
33; V8-EL: fabss %f1, %f1
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000034
Stephen Lind24ab202013-07-14 06:24:09 +000035; V8-UNOPT-LABEL: test_abs:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000036; V8-UNOPT: fabss
37; V8-UNOPT: ! implicit-def
38; V8-UNOPT: fmovs {{.+}}, %f0
39; V8-UNOPT: fmovs {{.+}}, %f1
40
Stephen Linf799e3f2013-07-13 20:38:47 +000041; V9-LABEL: test_abs:
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000042; V9: fabsd %f0, %f0
43
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000044
45; SPARC64-LABEL: test_abs:
46; SPARC64: fabsd %f0, %f0
47
Venkatraman Govindaraju7dae9ce2013-06-08 15:32:59 +000048define double @test_abs() {
49entry:
50 %0 = tail call double @get_double()
51 %1 = tail call double @llvm.fabs.f64(double %0)
52 ret double %1
53}
54
55declare double @get_double()
56declare double @llvm.fabs.f64(double) nounwind readonly
57
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000058; V8-LABEL: test_v9_floatreg:
James Y Knight1f3e6af2015-09-10 21:49:06 +000059; V8: fsubd {{.+}}, {{.+}}, [[R:%f(((1|2)?(0|2|4|6|8))|30)]]
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000060; V8: std [[R]], [%{{.+}}]
61; V8: ldd [%{{.+}}], %f0
James Y Knight1f3e6af2015-09-10 21:49:06 +000062; V8: faddd {{.+}}, {{.+}}, {{.+}}
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000063
64; V9-LABEL: test_v9_floatreg:
65; V9: fsubd {{.+}}, {{.+}}, {{.+}}
James Y Knight1f3e6af2015-09-10 21:49:06 +000066; V9: faddd {{.+}}, {{.+}}, %f0
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000067
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000068; SPARC64-LABEL: test_v9_floatreg:
69; SPARC64: fsubd {{.+}}, {{.+}}, {{.+}}
James Y Knight1f3e6af2015-09-10 21:49:06 +000070; SPARC64: faddd {{.+}}, {{.+}}, %f0
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000071
72define double @test_v9_floatreg() {
73entry:
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
79 ret double %3
80}
81
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000082; V8-LABEL: test_xtos_stox
83; V8: call __floatdisf
84; V8: call __fixsfdi
Venkatraman Govindaraju12d80892013-08-25 17:03:02 +000085
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +000086; V9-LABEL: test_xtos_stox
87; V9: call __floatdisf
88; V9: call __fixsfdi
89
90; SPARC64-LABEL: test_xtos_stox
91; SPARC64: fxtos
92; SPARC64: fstox
93
94define void @test_xtos_stox(i64 %a, i64* %ptr0, float* %ptr1) {
95entry:
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
100 ret void
101}
102
103; V8-LABEL: test_itos_stoi
104; V8: fitos
105; V8: fstoi
106
107; V9-LABEL: test_itos_stoi
108; V9: fitos
109; V9: fstoi
110
111; SPARC64-LABEL: test_itos_stoi
112; SPARC64: fitos
113; SPARC64: fstoi
114
115define void @test_itos_stoi(i32 %a, i32* %ptr0, float* %ptr1) {
116entry:
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
121 ret void
122}
123
124
125; V8-LABEL: test_xtod_dtox
126; V8: call __floatdidf
127; V8: call __fixdfdi
128
129; V9-LABEL: test_xtod_dtox
130; V9: call __floatdidf
131; V9: call __fixdfdi
132
133; SPARC64-LABEL: test_xtod_dtox
134; SPARC64: fxtod
135; SPARC64: fdtox
136
137define void @test_xtod_dtox(i64 %a, i64* %ptr0, double* %ptr1) {
138entry:
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
143 ret void
144}
145
146; V8-LABEL: test_itod_dtoi
147; V8: fitod
148; V8: fdtoi
149
150; V9-LABEL: test_itod_dtoi
151; V9: fitod
152; V9: fdtoi
153
154; SPARC64-LABEL: test_itod_dtoi
155; SPARC64: fitod
156; SPARC64: fdtoi
157
Mehdi Amini3e0023b2015-02-16 21:47:58 +0000158define void @test_itod_dtoi(i32 %a, double %b, i32* %ptr0, double* %ptr1) {
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +0000159entry:
160 %0 = sitofp i32 %a to double
161 store double %0, double* %ptr1, align 8
Mehdi Amini3e0023b2015-02-16 21:47:58 +0000162 %1 = fptosi double %b to i32
Venkatraman Govindaraju5ae77f72013-11-03 12:28:40 +0000163 store i32 %1, i32* %ptr0, align 8
164 ret void
165}
166
167; V8-LABEL: test_uxtos_stoux
168; V8: call __floatundisf
169; V8: call __fixunssfdi
170
171; V9-LABEL: test_uxtos_stoux
172; V9: call __floatundisf
173; V9: call __fixunssfdi
174
175; SPARC64-LABEL: test_uxtos_stoux
176; SPARC64-NOT: call __floatundisf
177; SPARC64-NOT: call __fixunssfdi
178
179define void @test_uxtos_stoux(i64 %a, i64* %ptr0, float* %ptr1) {
180entry:
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
185 ret void
186}
187
188; V8-LABEL: test_utos_stou
189; V8: fdtos
190; V8: fstoi
191
192; V9-LABEL: test_utos_stou
193; V9: fdtos
194; V9: fstoi
195
196; SPARC64-LABEL: test_utos_stou
197; SPARC64: fdtos
198; SPARC64: fstoi
199
200define void @test_utos_stou(i32 %a, i32* %ptr0, float* %ptr1) {
201entry:
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
206 ret void
207}
208
209
210; V8-LABEL: test_uxtod_dtoux
211; V8: call __floatundidf
212; V8: call __fixunsdfdi
213
214; V9-LABEL: test_uxtod_dtoux
215; V9: call __floatundidf
216; V9: call __fixunsdfdi
217
218; SPARC64-LABEL: test_uxtod_dtoux
219; SPARC64-NOT: call __floatundidf
220; SPARC64-NOT: call __floatunsdfdi
221
222define void @test_uxtod_dtoux(i64 %a, i64* %ptr0, double* %ptr1) {
223entry:
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
228 ret void
229}
230
231; V8-LABEL: test_utod_dtou
232; V8-NOT: fitod
233; V8: fdtoi
234
235; V9-LABEL: test_utod_dtou
236; V9-NOT: fitod
237; V9: fdtoi
238
239; SPARC64-LABEL: test_utod_dtou
240; SPARC64-NOT: fitod
241; SPARC64: fdtoi
242
243define void @test_utod_dtou(i32 %a, double %b, i32* %ptr0, double* %ptr1) {
244entry:
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
249 ret void
250}