aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/SPARC/float.ll
blob: 66367042cad9af34b25591de16bade3891838337 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
; RUN: llc -march=sparc < %s | FileCheck %s -check-prefix=V8
; RUN: llc -march=sparc -O0 < %s | FileCheck %s -check-prefix=V8-UNOPT
; RUN: llc -march=sparc -mattr=v9 < %s | FileCheck %s -check-prefix=V9
; RUN: llc -mtriple=sparc64-unknown-linux < %s | FileCheck %s -check-prefix=SPARC64

; V8-LABEL:     test_neg:
; V8:     call get_double
; V8:     fnegs %f0, %f0

; V8-UNOPT-LABEL:     test_neg:
; V8-UNOPT:     fnegs
; V8-UNOPT:     ! implicit-def
; V8-UNOPT:     fmovs {{.+}}, %f0
; V8-UNOPT:     fmovs {{.+}}, %f1

; V9-LABEL:     test_neg:
; V9:     fnegd %f0, %f0

; SPARC64-LABEL: test_neg:
; SPARC64:       fnegd %f0, %f0

define double @test_neg() {
entry:
  %0 = tail call double @get_double()
  %1 = fsub double -0.000000e+00, %0
  ret double %1
}

; V8-LABEL:     test_abs:
; V8:     fabss %f0, %f0

; V8-UNOPT-LABEL:     test_abs:
; V8-UNOPT:     fabss
; V8-UNOPT:     ! implicit-def
; V8-UNOPT:     fmovs {{.+}}, %f0
; V8-UNOPT:     fmovs {{.+}}, %f1

; V9-LABEL:     test_abs:
; V9:     fabsd %f0, %f0


; SPARC64-LABEL:     test_abs:
; SPARC64:     fabsd %f0, %f0

define double @test_abs() {
entry:
  %0 = tail call double @get_double()
  %1 = tail call double @llvm.fabs.f64(double %0)
  ret double %1
}

declare double @get_double()
declare double @llvm.fabs.f64(double) nounwind readonly

; V8-LABEL:    test_v9_floatreg:
; V8:          fsubd {{.+}}, {{.+}}, {{.+}}
; V8:          faddd {{.+}}, {{.+}}, [[R:%f(((1|2)?(0|2|4|6|8))|30)]]
; V8:          std [[R]], [%{{.+}}]
; V8:          ldd [%{{.+}}], %f0

; V9-LABEL:    test_v9_floatreg:
; V9:          fsubd {{.+}}, {{.+}}, {{.+}}
; V9:          faddd {{.+}}, {{.+}}, [[R:%f((3(2|4|6|8))|((4|5)(0|2|4|6|8))|(60|62))]]
; V9:          fmovd [[R]], %f0

; SPARC64-LABEL:    test_v9_floatreg:
; SPARC64:          fsubd {{.+}}, {{.+}}, {{.+}}
; SPARC64:          faddd {{.+}}, {{.+}}, [[R:%f((3(2|4|6|8))|((4|5)(0|2|4|6|8))|(60|62))]]
; SPARC64:          fmovd [[R]], %f0

define double @test_v9_floatreg() {
entry:
  %0 = tail call double @get_double()
  %1 = tail call double @get_double()
  %2 = fsub double %0, %1
  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}"()
  %3 = fadd double %2, %2
  ret double %3
}

; V8-LABEL:    test_xtos_stox
; V8:          call __floatdisf
; V8:          call __fixsfdi

; V9-LABEL:    test_xtos_stox
; V9:          call __floatdisf
; V9:          call __fixsfdi

; SPARC64-LABEL:    test_xtos_stox
; SPARC64:          fxtos
; SPARC64:          fstox

define void @test_xtos_stox(i64 %a, i64* %ptr0, float* %ptr1) {
entry:
  %0 = sitofp i64 %a to float
  store float %0, float* %ptr1, align 8
  %1 = fptosi float %0 to i64
  store i64 %1, i64* %ptr0, align 8
  ret void
}

; V8-LABEL:    test_itos_stoi
; V8:          fitos
; V8:          fstoi

; V9-LABEL:    test_itos_stoi
; V9:          fitos
; V9:          fstoi

; SPARC64-LABEL:    test_itos_stoi
; SPARC64:          fitos
; SPARC64:          fstoi

define void @test_itos_stoi(i32 %a, i32* %ptr0, float* %ptr1) {
entry:
  %0 = sitofp i32 %a to float
  store float %0, float* %ptr1, align 8
  %1 = fptosi float %0 to i32
  store i32 %1, i32* %ptr0, align 8
  ret void
}


; V8-LABEL:    test_xtod_dtox
; V8:          call __floatdidf
; V8:          call __fixdfdi

; V9-LABEL:    test_xtod_dtox
; V9:          call __floatdidf
; V9:          call __fixdfdi

; SPARC64-LABEL:    test_xtod_dtox
; SPARC64:          fxtod
; SPARC64:          fdtox

define void @test_xtod_dtox(i64 %a, i64* %ptr0, double* %ptr1) {
entry:
  %0 = sitofp i64 %a to double
  store double %0, double* %ptr1, align 8
  %1 = fptosi double %0 to i64
  store i64 %1, i64* %ptr0, align 8
  ret void
}

; V8-LABEL:    test_itod_dtoi
; V8:          fitod
; V8:          fdtoi

; V9-LABEL:    test_itod_dtoi
; V9:          fitod
; V9:          fdtoi

; SPARC64-LABEL:    test_itod_dtoi
; SPARC64:          fitod
; SPARC64:          fdtoi

define void @test_itod_dtoi(i32 %a, i32* %ptr0, double* %ptr1) {
entry:
  %0 = sitofp i32 %a to double
  store double %0, double* %ptr1, align 8
  %1 = fptosi double %0 to i32
  store i32 %1, i32* %ptr0, align 8
  ret void
}

; V8-LABEL:    test_uxtos_stoux
; V8:          call __floatundisf
; V8:          call __fixunssfdi

; V9-LABEL:    test_uxtos_stoux
; V9:          call __floatundisf
; V9:          call __fixunssfdi

; SPARC64-LABEL:   test_uxtos_stoux
; SPARC64-NOT:     call __floatundisf
; SPARC64-NOT:     call __fixunssfdi

define void @test_uxtos_stoux(i64 %a, i64* %ptr0, float* %ptr1) {
entry:
  %0 = uitofp i64 %a to float
  store float %0, float* %ptr1, align 8
  %1 = fptoui float %0 to i64
  store i64 %1, i64* %ptr0, align 8
  ret void
}

; V8-LABEL:    test_utos_stou
; V8:          fdtos
; V8:          fstoi

; V9-LABEL:    test_utos_stou
; V9:          fdtos
; V9:          fstoi

; SPARC64-LABEL:    test_utos_stou
; SPARC64:     fdtos
; SPARC64:     fstoi

define void @test_utos_stou(i32 %a, i32* %ptr0, float* %ptr1) {
entry:
  %0 = uitofp i32 %a to float
  store float %0, float* %ptr1, align 8
  %1 = fptoui float %0 to i32
  store i32 %1, i32* %ptr0, align 8
  ret void
}


; V8-LABEL:    test_uxtod_dtoux
; V8:          call __floatundidf
; V8:          call __fixunsdfdi

; V9-LABEL:    test_uxtod_dtoux
; V9:          call __floatundidf
; V9:          call __fixunsdfdi

; SPARC64-LABEL:    test_uxtod_dtoux
; SPARC64-NOT:          call __floatundidf
; SPARC64-NOT:          call __floatunsdfdi

define void @test_uxtod_dtoux(i64 %a, i64* %ptr0, double* %ptr1) {
entry:
  %0 = uitofp i64 %a to double
  store double %0, double* %ptr1, align 8
  %1 = fptoui double %0 to i64
  store i64 %1, i64* %ptr0, align 8
  ret void
}

; V8-LABEL:    test_utod_dtou
; V8-NOT:      fitod
; V8:          fdtoi

; V9-LABEL:    test_utod_dtou
; V9-NOT:      fitod
; V9:          fdtoi

; SPARC64-LABEL:    test_utod_dtou
; SPARC64-NOT:      fitod
; SPARC64:          fdtoi

define void @test_utod_dtou(i32 %a, double %b, i32* %ptr0, double* %ptr1) {
entry:
  %0 = uitofp i32 %a to double
  store double %0, double* %ptr1, align 8
  %1 = fptoui double %b to i32
  store i32 %1, i32* %ptr0, align 8
  ret void
}