1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mcpu=a2 < %s | FileCheck %s -check-prefix=FPCVT
3 ; RUN: llc -verify-machineinstrs -mcpu=ppc64 < %s | FileCheck %s -check-prefix=PPC64
4 ; RUN: llc -verify-machineinstrs -mcpu=pwr9 < %s | FileCheck %s -check-prefix=PWR9
5 target datalayout = "E-m:e-i64:64-n32:64"
6 target triple = "powerpc64-unknown-linux-gnu"
8 ; Function Attrs: nounwind readnone
9 define float @fool(float %X) #0 {
11 ; FPCVT: # %bb.0: # %entry
12 ; FPCVT-NEXT: friz 1, 1
16 ; PPC64: # %bb.0: # %entry
17 ; PPC64-NEXT: fctidz 0, 1
18 ; PPC64-NEXT: fcfid 0, 0
19 ; PPC64-NEXT: frsp 1, 0
23 ; PWR9: # %bb.0: # %entry
24 ; PWR9-NEXT: xsrdpiz 1, 1
27 %conv = fptosi float %X to i64
28 %conv1 = sitofp i64 %conv to float
34 ; Function Attrs: nounwind readnone
35 define double @foodl(double %X) #0 {
37 ; FPCVT: # %bb.0: # %entry
38 ; FPCVT-NEXT: friz 1, 1
42 ; PPC64: # %bb.0: # %entry
43 ; PPC64-NEXT: fctidz 0, 1
44 ; PPC64-NEXT: fcfid 1, 0
48 ; PWR9: # %bb.0: # %entry
49 ; PWR9-NEXT: xsrdpiz 1, 1
52 %conv = fptosi double %X to i64
53 %conv1 = sitofp i64 %conv to double
59 ; Function Attrs: nounwind readnone
60 define float @fooul(float %X) #0 {
62 ; FPCVT: # %bb.0: # %entry
63 ; FPCVT-NEXT: friz 1, 1
67 ; PPC64: # %bb.0: # %entry
68 ; PPC64-NEXT: addis 3, 2, .LCPI2_0@toc@ha
70 ; PPC64-NEXT: lfs 0, .LCPI2_0@toc@l(3)
71 ; PPC64-NEXT: rldic 4, 4, 63, 0
72 ; PPC64-NEXT: fsubs 2, 1, 0
73 ; PPC64-NEXT: fcmpu 0, 1, 0
74 ; PPC64-NEXT: fctidz 2, 2
75 ; PPC64-NEXT: stfd 2, -8(1)
76 ; PPC64-NEXT: fctidz 2, 1
77 ; PPC64-NEXT: stfd 2, -16(1)
78 ; PPC64-NEXT: ld 3, -8(1)
79 ; PPC64-NEXT: ld 5, -16(1)
80 ; PPC64-NEXT: xor 3, 3, 4
81 ; PPC64-NEXT: bc 12, 0, .LBB2_1
82 ; PPC64-NEXT: b .LBB2_2
83 ; PPC64-NEXT: .LBB2_1: # %entry
84 ; PPC64-NEXT: addi 3, 5, 0
85 ; PPC64-NEXT: .LBB2_2: # %entry
86 ; PPC64-NEXT: sradi 4, 3, 53
87 ; PPC64-NEXT: rldicl 5, 3, 63, 1
88 ; PPC64-NEXT: addi 4, 4, 1
89 ; PPC64-NEXT: clrldi 6, 3, 63
90 ; PPC64-NEXT: cmpldi 4, 1
91 ; PPC64-NEXT: clrldi 4, 3, 53
92 ; PPC64-NEXT: or 6, 6, 5
93 ; PPC64-NEXT: clrldi 7, 6, 53
94 ; PPC64-NEXT: addi 4, 4, 2047
95 ; PPC64-NEXT: addi 7, 7, 2047
96 ; PPC64-NEXT: or 4, 4, 3
97 ; PPC64-NEXT: or 5, 7, 5
98 ; PPC64-NEXT: rldicl 7, 3, 10, 54
99 ; PPC64-NEXT: rldicr 4, 4, 0, 52
100 ; PPC64-NEXT: addi 7, 7, 1
101 ; PPC64-NEXT: bc 12, 1, .LBB2_4
102 ; PPC64-NEXT: # %bb.3: # %entry
103 ; PPC64-NEXT: ori 4, 3, 0
104 ; PPC64-NEXT: b .LBB2_4
105 ; PPC64-NEXT: .LBB2_4: # %entry
106 ; PPC64-NEXT: rldicl 5, 5, 53, 11
107 ; PPC64-NEXT: std 4, -32(1)
108 ; PPC64-NEXT: rldicl 4, 5, 11, 1
109 ; PPC64-NEXT: cmpldi 7, 1
110 ; PPC64-NEXT: bc 12, 1, .LBB2_6
111 ; PPC64-NEXT: # %bb.5: # %entry
112 ; PPC64-NEXT: ori 4, 6, 0
113 ; PPC64-NEXT: b .LBB2_6
114 ; PPC64-NEXT: .LBB2_6: # %entry
115 ; PPC64-NEXT: cmpdi 3, 0
116 ; PPC64-NEXT: std 4, -24(1)
117 ; PPC64-NEXT: bc 12, 0, .LBB2_8
118 ; PPC64-NEXT: # %bb.7: # %entry
119 ; PPC64-NEXT: lfd 0, -32(1)
120 ; PPC64-NEXT: fcfid 0, 0
121 ; PPC64-NEXT: frsp 1, 0
123 ; PPC64-NEXT: .LBB2_8:
124 ; PPC64-NEXT: lfd 0, -24(1)
125 ; PPC64-NEXT: fcfid 0, 0
126 ; PPC64-NEXT: frsp 0, 0
127 ; PPC64-NEXT: fadds 1, 0, 0
131 ; PWR9: # %bb.0: # %entry
132 ; PWR9-NEXT: xsrdpiz 1, 1
135 %conv = fptoui float %X to i64
136 %conv1 = uitofp i64 %conv to float
141 ; Function Attrs: nounwind readnone
142 define double @fooudl(double %X) #0 {
143 ; FPCVT-LABEL: fooudl:
144 ; FPCVT: # %bb.0: # %entry
145 ; FPCVT-NEXT: friz 1, 1
148 ; PPC64-LABEL: fooudl:
149 ; PPC64: # %bb.0: # %entry
150 ; PPC64-NEXT: addis 3, 2, .LCPI3_0@toc@ha
151 ; PPC64-NEXT: li 4, 1
152 ; PPC64-NEXT: lfs 0, .LCPI3_0@toc@l(3)
153 ; PPC64-NEXT: rldic 4, 4, 63, 0
154 ; PPC64-NEXT: fsub 2, 1, 0
155 ; PPC64-NEXT: fcmpu 0, 1, 0
156 ; PPC64-NEXT: fctidz 2, 2
157 ; PPC64-NEXT: stfd 2, -8(1)
158 ; PPC64-NEXT: fctidz 2, 1
159 ; PPC64-NEXT: stfd 2, -16(1)
160 ; PPC64-NEXT: ld 3, -8(1)
161 ; PPC64-NEXT: ld 5, -16(1)
162 ; PPC64-NEXT: xor 3, 3, 4
163 ; PPC64-NEXT: li 4, 1107
164 ; PPC64-NEXT: rldic 4, 4, 52, 1
165 ; PPC64-NEXT: bc 12, 0, .LBB3_1
166 ; PPC64-NEXT: b .LBB3_2
167 ; PPC64-NEXT: .LBB3_1: # %entry
168 ; PPC64-NEXT: addi 3, 5, 0
169 ; PPC64-NEXT: .LBB3_2: # %entry
170 ; PPC64-NEXT: rldicl 5, 3, 32, 32
171 ; PPC64-NEXT: clrldi 3, 3, 32
172 ; PPC64-NEXT: or 4, 5, 4
173 ; PPC64-NEXT: addis 5, 2, .LCPI3_1@toc@ha
174 ; PPC64-NEXT: std 4, -24(1)
175 ; PPC64-NEXT: li 4, 1075
176 ; PPC64-NEXT: rldic 4, 4, 52, 1
177 ; PPC64-NEXT: or 3, 3, 4
178 ; PPC64-NEXT: lfd 0, .LCPI3_1@toc@l(5)
179 ; PPC64-NEXT: std 3, -32(1)
180 ; PPC64-NEXT: lfd 1, -24(1)
181 ; PPC64-NEXT: lfd 2, -32(1)
182 ; PPC64-NEXT: fsub 0, 1, 0
183 ; PPC64-NEXT: fadd 1, 2, 0
186 ; PWR9-LABEL: fooudl:
187 ; PWR9: # %bb.0: # %entry
188 ; PWR9-NEXT: xsrdpiz 1, 1
191 %conv = fptoui double %X to i64
192 %conv1 = uitofp i64 %conv to double
197 ; Function Attrs: nounwind readnone
198 define i1 @f64_to_si1(double %X) #0 {
199 ; FPCVT-LABEL: f64_to_si1:
200 ; FPCVT: # %bb.0: # %entry
201 ; FPCVT-NEXT: fctiwz 0, 1
202 ; FPCVT-NEXT: addi 3, 1, -4
203 ; FPCVT-NEXT: stfiwx 0, 0, 3
204 ; FPCVT-NEXT: lwz 3, -4(1)
207 ; PPC64-LABEL: f64_to_si1:
208 ; PPC64: # %bb.0: # %entry
209 ; PPC64-NEXT: addi 3, 1, -4
210 ; PPC64-NEXT: fctiwz 0, 1
211 ; PPC64-NEXT: stfiwx 0, 0, 3
212 ; PPC64-NEXT: lwz 3, -4(1)
215 ; PWR9-LABEL: f64_to_si1:
216 ; PWR9: # %bb.0: # %entry
217 ; PWR9-NEXT: xscvdpsxws 0, 1
218 ; PWR9-NEXT: mffprwz 3, 0
221 %conv = fptosi double %X to i1
226 ; Function Attrs: nounwind readnone
227 define i1 @f64_to_ui1(double %X) #0 {
228 ; FPCVT-LABEL: f64_to_ui1:
229 ; FPCVT: # %bb.0: # %entry
230 ; FPCVT-NEXT: fctiwz 0, 1
231 ; FPCVT-NEXT: addi 3, 1, -4
232 ; FPCVT-NEXT: stfiwx 0, 0, 3
233 ; FPCVT-NEXT: lwz 3, -4(1)
236 ; PPC64-LABEL: f64_to_ui1:
237 ; PPC64: # %bb.0: # %entry
238 ; PPC64-NEXT: addi 3, 1, -4
239 ; PPC64-NEXT: fctiwz 0, 1
240 ; PPC64-NEXT: stfiwx 0, 0, 3
241 ; PPC64-NEXT: lwz 3, -4(1)
244 ; PWR9-LABEL: f64_to_ui1:
245 ; PWR9: # %bb.0: # %entry
246 ; PWR9-NEXT: xscvdpsxws 0, 1
247 ; PWR9-NEXT: mffprwz 3, 0
250 %conv = fptoui double %X to i1
255 ; Function Attrs: nounwind readnone
256 define double @si1_to_f64(i1 %X) #0 {
257 ; FPCVT-LABEL: si1_to_f64:
258 ; FPCVT: # %bb.0: # %entry
259 ; FPCVT-NEXT: andi. 3, 3, 1
260 ; FPCVT-NEXT: li 4, 0
261 ; FPCVT-NEXT: li 3, -1
262 ; FPCVT-NEXT: iselgt 3, 3, 4
263 ; FPCVT-NEXT: addi 4, 1, -4
264 ; FPCVT-NEXT: stw 3, -4(1)
265 ; FPCVT-NEXT: lfiwax 0, 0, 4
266 ; FPCVT-NEXT: fcfid 1, 0
269 ; PPC64-LABEL: si1_to_f64:
270 ; PPC64: # %bb.0: # %entry
271 ; PPC64-NEXT: andi. 3, 3, 1
272 ; PPC64-NEXT: li 4, -1
273 ; PPC64-NEXT: li 3, 0
274 ; PPC64-NEXT: bc 12, 1, .LBB6_1
275 ; PPC64-NEXT: b .LBB6_2
276 ; PPC64-NEXT: .LBB6_1: # %entry
277 ; PPC64-NEXT: addi 3, 4, 0
278 ; PPC64-NEXT: .LBB6_2: # %entry
279 ; PPC64-NEXT: std 3, -8(1)
280 ; PPC64-NEXT: lfd 0, -8(1)
281 ; PPC64-NEXT: fcfid 1, 0
284 ; PWR9-LABEL: si1_to_f64:
285 ; PWR9: # %bb.0: # %entry
286 ; PWR9-NEXT: andi. 3, 3, 1
288 ; PWR9-NEXT: li 4, -1
289 ; PWR9-NEXT: iselgt 3, 4, 3
290 ; PWR9-NEXT: mtfprwa 0, 3
291 ; PWR9-NEXT: xscvsxddp 1, 0
294 %conv = sitofp i1 %X to double
299 ; Function Attrs: nounwind readnone
300 define double @ui1_to_f64(i1 %X) #0 {
301 ; FPCVT-LABEL: ui1_to_f64:
302 ; FPCVT: # %bb.0: # %entry
303 ; FPCVT-NEXT: clrlwi 3, 3, 31
304 ; FPCVT-NEXT: addi 4, 1, -4
305 ; FPCVT-NEXT: stw 3, -4(1)
306 ; FPCVT-NEXT: lfiwax 0, 0, 4
307 ; FPCVT-NEXT: fcfid 1, 0
310 ; PPC64-LABEL: ui1_to_f64:
311 ; PPC64: # %bb.0: # %entry
312 ; PPC64-NEXT: clrldi 3, 3, 63
313 ; PPC64-NEXT: std 3, -8(1)
314 ; PPC64-NEXT: lfd 0, -8(1)
315 ; PPC64-NEXT: fcfid 1, 0
318 ; PWR9-LABEL: ui1_to_f64:
319 ; PWR9: # %bb.0: # %entry
320 ; PWR9-NEXT: clrlwi 3, 3, 31
321 ; PWR9-NEXT: mtfprwa 0, 3
322 ; PWR9-NEXT: xscvsxddp 1, 0
325 %conv = uitofp i1 %X to double
329 attributes #0 = { nounwind readnone "no-signed-zeros-fp-math"="true" }