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
69 ; PPC64-NEXT: lfs 0, .LCPI2_0@toc@l(3)
70 ; PPC64-NEXT: fsubs 2, 1, 0
71 ; PPC64-NEXT: fcmpu 0, 1, 0
72 ; PPC64-NEXT: fctidz 2, 2
73 ; PPC64-NEXT: stfd 2, -8(1)
74 ; PPC64-NEXT: fctidz 2, 1
75 ; PPC64-NEXT: stfd 2, -16(1)
76 ; PPC64-NEXT: blt 0, .LBB2_2
77 ; PPC64-NEXT: # %bb.1: # %entry
78 ; PPC64-NEXT: ld 3, -8(1)
80 ; PPC64-NEXT: rldic 4, 4, 63, 0
81 ; PPC64-NEXT: xor 3, 3, 4
82 ; PPC64-NEXT: b .LBB2_3
83 ; PPC64-NEXT: .LBB2_2:
84 ; PPC64-NEXT: ld 3, -16(1)
85 ; PPC64-NEXT: .LBB2_3: # %entry
86 ; PPC64-NEXT: sradi 4, 3, 53
87 ; PPC64-NEXT: addi 4, 4, 1
88 ; PPC64-NEXT: cmpldi 4, 1
89 ; PPC64-NEXT: bgt 0, .LBB2_5
90 ; PPC64-NEXT: # %bb.4: # %entry
92 ; PPC64-NEXT: b .LBB2_6
93 ; PPC64-NEXT: .LBB2_5:
94 ; PPC64-NEXT: clrldi 4, 3, 53
95 ; PPC64-NEXT: addi 4, 4, 2047
96 ; PPC64-NEXT: or 4, 4, 3
97 ; PPC64-NEXT: rldicr 4, 4, 0, 52
98 ; PPC64-NEXT: .LBB2_6: # %entry
99 ; PPC64-NEXT: rldicl 5, 3, 10, 54
100 ; PPC64-NEXT: clrldi 6, 3, 63
101 ; PPC64-NEXT: std 4, -32(1)
102 ; PPC64-NEXT: addi 5, 5, 1
103 ; PPC64-NEXT: cmpldi 5, 1
104 ; PPC64-NEXT: rldicl 5, 3, 63, 1
105 ; PPC64-NEXT: or 4, 6, 5
106 ; PPC64-NEXT: ble 0, .LBB2_8
107 ; PPC64-NEXT: # %bb.7:
108 ; PPC64-NEXT: clrldi 4, 4, 53
109 ; PPC64-NEXT: addi 4, 4, 2047
110 ; PPC64-NEXT: or 4, 4, 5
111 ; PPC64-NEXT: rldicl 4, 4, 53, 11
112 ; PPC64-NEXT: rldicl 4, 4, 11, 1
113 ; PPC64-NEXT: .LBB2_8: # %entry
114 ; PPC64-NEXT: cmpdi 3, 0
115 ; PPC64-NEXT: std 4, -24(1)
116 ; PPC64-NEXT: bc 12, 0, .LBB2_10
117 ; PPC64-NEXT: # %bb.9: # %entry
118 ; PPC64-NEXT: lfd 0, -32(1)
119 ; PPC64-NEXT: fcfid 0, 0
120 ; PPC64-NEXT: frsp 1, 0
122 ; PPC64-NEXT: .LBB2_10:
123 ; PPC64-NEXT: lfd 0, -24(1)
124 ; PPC64-NEXT: fcfid 0, 0
125 ; PPC64-NEXT: frsp 0, 0
126 ; PPC64-NEXT: fadds 1, 0, 0
130 ; PWR9: # %bb.0: # %entry
131 ; PWR9-NEXT: xsrdpiz 1, 1
134 %conv = fptoui float %X to i64
135 %conv1 = uitofp i64 %conv to float
140 ; Function Attrs: nounwind readnone
141 define double @fooudl(double %X) #0 {
142 ; FPCVT-LABEL: fooudl:
143 ; FPCVT: # %bb.0: # %entry
144 ; FPCVT-NEXT: friz 1, 1
147 ; PPC64-LABEL: fooudl:
148 ; PPC64: # %bb.0: # %entry
149 ; PPC64-NEXT: addis 3, 2, .LCPI3_0@toc@ha
150 ; PPC64-NEXT: lfs 0, .LCPI3_0@toc@l(3)
151 ; PPC64-NEXT: fsub 2, 1, 0
152 ; PPC64-NEXT: fcmpu 0, 1, 0
153 ; PPC64-NEXT: fctidz 2, 2
154 ; PPC64-NEXT: stfd 2, -8(1)
155 ; PPC64-NEXT: fctidz 2, 1
156 ; PPC64-NEXT: stfd 2, -16(1)
157 ; PPC64-NEXT: blt 0, .LBB3_2
158 ; PPC64-NEXT: # %bb.1: # %entry
159 ; PPC64-NEXT: ld 3, -8(1)
160 ; PPC64-NEXT: li 4, 1
161 ; PPC64-NEXT: rldic 4, 4, 63, 0
162 ; PPC64-NEXT: xor 3, 3, 4
163 ; PPC64-NEXT: b .LBB3_3
164 ; PPC64-NEXT: .LBB3_2:
165 ; PPC64-NEXT: ld 3, -16(1)
166 ; PPC64-NEXT: .LBB3_3: # %entry
167 ; PPC64-NEXT: li 5, 1107
168 ; PPC64-NEXT: rldicl 4, 3, 32, 32
169 ; PPC64-NEXT: rldic 5, 5, 52, 1
170 ; PPC64-NEXT: clrldi 3, 3, 32
171 ; PPC64-NEXT: or 4, 4, 5
172 ; PPC64-NEXT: li 5, 1075
173 ; PPC64-NEXT: std 4, -24(1)
174 ; PPC64-NEXT: addis 4, 2, .LCPI3_1@toc@ha
175 ; PPC64-NEXT: lfd 0, .LCPI3_1@toc@l(4)
176 ; PPC64-NEXT: rldic 4, 5, 52, 1
177 ; PPC64-NEXT: or 3, 3, 4
178 ; PPC64-NEXT: std 3, -32(1)
179 ; PPC64-NEXT: lfd 1, -24(1)
180 ; PPC64-NEXT: lfd 2, -32(1)
181 ; PPC64-NEXT: fsub 0, 1, 0
182 ; PPC64-NEXT: fadd 1, 2, 0
185 ; PWR9-LABEL: fooudl:
186 ; PWR9: # %bb.0: # %entry
187 ; PWR9-NEXT: xsrdpiz 1, 1
190 %conv = fptoui double %X to i64
191 %conv1 = uitofp i64 %conv to double
196 ; Function Attrs: nounwind readnone
197 define i1 @f64_to_si1(double %X) #0 {
198 ; FPCVT-LABEL: f64_to_si1:
199 ; FPCVT: # %bb.0: # %entry
200 ; FPCVT-NEXT: fctiwz 0, 1
201 ; FPCVT-NEXT: addi 3, 1, -4
202 ; FPCVT-NEXT: stfiwx 0, 0, 3
203 ; FPCVT-NEXT: lwz 3, -4(1)
206 ; PPC64-LABEL: f64_to_si1:
207 ; PPC64: # %bb.0: # %entry
208 ; PPC64-NEXT: addi 3, 1, -4
209 ; PPC64-NEXT: fctiwz 0, 1
210 ; PPC64-NEXT: stfiwx 0, 0, 3
211 ; PPC64-NEXT: lwz 3, -4(1)
214 ; PWR9-LABEL: f64_to_si1:
215 ; PWR9: # %bb.0: # %entry
216 ; PWR9-NEXT: xscvdpsxws 0, 1
217 ; PWR9-NEXT: mffprwz 3, 0
220 %conv = fptosi double %X to i1
225 ; Function Attrs: nounwind readnone
226 define i1 @f64_to_ui1(double %X) #0 {
227 ; FPCVT-LABEL: f64_to_ui1:
228 ; FPCVT: # %bb.0: # %entry
229 ; FPCVT-NEXT: fctiwz 0, 1
230 ; FPCVT-NEXT: addi 3, 1, -4
231 ; FPCVT-NEXT: stfiwx 0, 0, 3
232 ; FPCVT-NEXT: lwz 3, -4(1)
235 ; PPC64-LABEL: f64_to_ui1:
236 ; PPC64: # %bb.0: # %entry
237 ; PPC64-NEXT: addi 3, 1, -4
238 ; PPC64-NEXT: fctiwz 0, 1
239 ; PPC64-NEXT: stfiwx 0, 0, 3
240 ; PPC64-NEXT: lwz 3, -4(1)
243 ; PWR9-LABEL: f64_to_ui1:
244 ; PWR9: # %bb.0: # %entry
245 ; PWR9-NEXT: xscvdpsxws 0, 1
246 ; PWR9-NEXT: mffprwz 3, 0
249 %conv = fptoui double %X to i1
254 ; Function Attrs: nounwind readnone
255 define double @si1_to_f64(i1 %X) #0 {
256 ; FPCVT-LABEL: si1_to_f64:
257 ; FPCVT: # %bb.0: # %entry
258 ; FPCVT-NEXT: andi. 3, 3, 1
259 ; FPCVT-NEXT: li 4, 0
260 ; FPCVT-NEXT: li 3, -1
261 ; FPCVT-NEXT: iselgt 3, 3, 4
262 ; FPCVT-NEXT: addi 4, 1, -4
263 ; FPCVT-NEXT: stw 3, -4(1)
264 ; FPCVT-NEXT: lfiwax 0, 0, 4
265 ; FPCVT-NEXT: fcfid 1, 0
268 ; PPC64-LABEL: si1_to_f64:
269 ; PPC64: # %bb.0: # %entry
270 ; PPC64-NEXT: andi. 3, 3, 1
271 ; PPC64-NEXT: li 3, -1
272 ; PPC64-NEXT: bc 12, 1, .LBB6_2
273 ; PPC64-NEXT: # %bb.1: # %entry
274 ; PPC64-NEXT: li 3, 0
275 ; PPC64-NEXT: .LBB6_2: # %entry
276 ; PPC64-NEXT: std 3, -8(1)
277 ; PPC64-NEXT: lfd 0, -8(1)
278 ; PPC64-NEXT: fcfid 1, 0
281 ; PWR9-LABEL: si1_to_f64:
282 ; PWR9: # %bb.0: # %entry
283 ; PWR9-NEXT: andi. 3, 3, 1
285 ; PWR9-NEXT: li 4, -1
286 ; PWR9-NEXT: iselgt 3, 4, 3
287 ; PWR9-NEXT: mtfprwa 0, 3
288 ; PWR9-NEXT: xscvsxddp 1, 0
291 %conv = sitofp i1 %X to double
296 ; Function Attrs: nounwind readnone
297 define double @ui1_to_f64(i1 %X) #0 {
298 ; FPCVT-LABEL: ui1_to_f64:
299 ; FPCVT: # %bb.0: # %entry
300 ; FPCVT-NEXT: clrlwi 3, 3, 31
301 ; FPCVT-NEXT: addi 4, 1, -4
302 ; FPCVT-NEXT: stw 3, -4(1)
303 ; FPCVT-NEXT: lfiwax 0, 0, 4
304 ; FPCVT-NEXT: fcfid 1, 0
307 ; PPC64-LABEL: ui1_to_f64:
308 ; PPC64: # %bb.0: # %entry
309 ; PPC64-NEXT: clrldi 3, 3, 63
310 ; PPC64-NEXT: std 3, -8(1)
311 ; PPC64-NEXT: lfd 0, -8(1)
312 ; PPC64-NEXT: fcfid 1, 0
315 ; PWR9-LABEL: ui1_to_f64:
316 ; PWR9: # %bb.0: # %entry
317 ; PWR9-NEXT: clrlwi 3, 3, 31
318 ; PWR9-NEXT: mtfprwa 0, 3
319 ; PWR9-NEXT: xscvsxddp 1, 0
322 %conv = uitofp i1 %X to double
326 attributes #0 = { nounwind readnone "no-signed-zeros-fp-math"="true" }