1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=ppc32-- | FileCheck %s \
3 ; RUN: -check-prefix=PPC32
4 ; RUN: llc -verify-machineinstrs < %s -mcpu=ppc -mtriple=powerpc64 | FileCheck %s \
5 ; RUN: -check-prefix=PPC64
6 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le -mattr=-direct-move \
7 ; RUN: | FileCheck %s -check-prefix=PPC64LE
8 ; RUN: llc -verify-machineinstrs < %s -mtriple=ppc32-- -mcpu=pwr9 \
9 ; RUN: | FileCheck %s -check-prefix=P9_32
10 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le -mcpu=pwr9 \
11 ; RUN: | FileCheck %s -check-prefix=P9
12 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le | FileCheck %s \
13 ; RUN: -check-prefix=DM
15 define i32 @foo() #0 {
17 ; PPC32: # %bb.0: # %entry
18 ; PPC32-NEXT: stwu 1, -32(1)
20 ; PPC32-NEXT: stfd 0, 16(1)
21 ; PPC32-NEXT: lwz 3, 20(1)
22 ; PPC32-NEXT: clrlwi 4, 3, 30
23 ; PPC32-NEXT: not 3, 3
24 ; PPC32-NEXT: rlwinm 3, 3, 31, 31, 31
25 ; PPC32-NEXT: xor 3, 4, 3
26 ; PPC32-NEXT: stw 3, 24(1)
27 ; PPC32-NEXT: stw 3, 28(1)
28 ; PPC32-NEXT: addi 1, 1, 32
32 ; PPC64: # %bb.0: # %entry
34 ; PPC64-NEXT: stfd 0, -16(1)
35 ; PPC64-NEXT: lwz 3, -12(1)
36 ; PPC64-NEXT: clrlwi 4, 3, 30
37 ; PPC64-NEXT: not 3, 3
38 ; PPC64-NEXT: rlwinm 3, 3, 31, 31, 31
39 ; PPC64-NEXT: xor 3, 4, 3
40 ; PPC64-NEXT: stw 3, -8(1)
41 ; PPC64-NEXT: stw 3, -4(1)
45 ; PPC64LE: # %bb.0: # %entry
46 ; PPC64LE-NEXT: mffs 0
47 ; PPC64LE-NEXT: stfd 0, -16(1)
48 ; PPC64LE-NEXT: lwz 3, -16(1)
49 ; PPC64LE-NEXT: clrlwi 4, 3, 30
50 ; PPC64LE-NEXT: not 3, 3
51 ; PPC64LE-NEXT: rlwinm 3, 3, 31, 31, 31
52 ; PPC64LE-NEXT: xor 3, 4, 3
53 ; PPC64LE-NEXT: stw 3, -8(1)
54 ; PPC64LE-NEXT: stw 3, -4(1)
58 ; P9_32: # %bb.0: # %entry
59 ; P9_32-NEXT: stwu 1, -32(1)
61 ; P9_32-NEXT: stfd 0, 16(1)
62 ; P9_32-NEXT: lwz 3, 20(1)
63 ; P9_32-NEXT: clrlwi 4, 3, 30
64 ; P9_32-NEXT: not 3, 3
65 ; P9_32-NEXT: rlwinm 3, 3, 31, 31, 31
66 ; P9_32-NEXT: xor 3, 4, 3
67 ; P9_32-NEXT: stw 3, 24(1)
68 ; P9_32-NEXT: stw 3, 28(1)
69 ; P9_32-NEXT: addi 1, 1, 32
73 ; P9: # %bb.0: # %entry
75 ; P9-NEXT: mffprd 3, 0
76 ; P9-NEXT: clrlwi 4, 3, 30
78 ; P9-NEXT: rlwinm 3, 3, 31, 31, 31
79 ; P9-NEXT: xor 3, 4, 3
80 ; P9-NEXT: stw 3, -8(1)
81 ; P9-NEXT: stw 3, -4(1)
85 ; DM: # %bb.0: # %entry
87 ; DM-NEXT: mffprd 3, 0
88 ; DM-NEXT: clrlwi 4, 3, 30
90 ; DM-NEXT: rlwinm 3, 3, 31, 31, 31
91 ; DM-NEXT: xor 3, 4, 3
92 ; DM-NEXT: stw 3, -8(1)
93 ; DM-NEXT: stw 3, -4(1)
96 %retval = alloca i32 ; <ptr> [#uses=2]
97 %tmp = alloca i32 ; <ptr> [#uses=2]
98 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
99 %tmp1 = call i32 @llvm.get.rounding( ) ; <i32> [#uses=1]
100 store i32 %tmp1, ptr %tmp, align 4
101 %tmp2 = load i32, ptr %tmp, align 4 ; <i32> [#uses=1]
102 store i32 %tmp2, ptr %retval, align 4
105 return: ; preds = %entry
106 %retval3 = load i32, ptr %retval ; <i32> [#uses=1]
110 define void @setrnd_tozero() #0 {
111 ; PPC32-LABEL: setrnd_tozero:
112 ; PPC32: # %bb.0: # %entry
113 ; PPC32-NEXT: mtfsb0 30
114 ; PPC32-NEXT: mtfsb1 31
117 ; PPC64-LABEL: setrnd_tozero:
118 ; PPC64: # %bb.0: # %entry
119 ; PPC64-NEXT: mtfsb0 30
120 ; PPC64-NEXT: mtfsb1 31
123 ; PPC64LE-LABEL: setrnd_tozero:
124 ; PPC64LE: # %bb.0: # %entry
125 ; PPC64LE-NEXT: mtfsb0 30
126 ; PPC64LE-NEXT: mtfsb1 31
129 ; P9_32-LABEL: setrnd_tozero:
130 ; P9_32: # %bb.0: # %entry
131 ; P9_32-NEXT: mffscrni 0, 1
134 ; P9-LABEL: setrnd_tozero:
135 ; P9: # %bb.0: # %entry
136 ; P9-NEXT: mffscrni 0, 1
139 ; DM-LABEL: setrnd_tozero:
140 ; DM: # %bb.0: # %entry
145 call void @llvm.set.rounding(i32 0)
149 define void @setrnd_tonearest_tieeven() #0 {
150 ; PPC32-LABEL: setrnd_tonearest_tieeven:
151 ; PPC32: # %bb.0: # %entry
152 ; PPC32-NEXT: mtfsb0 30
153 ; PPC32-NEXT: mtfsb0 31
156 ; PPC64-LABEL: setrnd_tonearest_tieeven:
157 ; PPC64: # %bb.0: # %entry
158 ; PPC64-NEXT: mtfsb0 30
159 ; PPC64-NEXT: mtfsb0 31
162 ; PPC64LE-LABEL: setrnd_tonearest_tieeven:
163 ; PPC64LE: # %bb.0: # %entry
164 ; PPC64LE-NEXT: mtfsb0 30
165 ; PPC64LE-NEXT: mtfsb0 31
168 ; P9_32-LABEL: setrnd_tonearest_tieeven:
169 ; P9_32: # %bb.0: # %entry
170 ; P9_32-NEXT: mffscrni 0, 0
173 ; P9-LABEL: setrnd_tonearest_tieeven:
174 ; P9: # %bb.0: # %entry
175 ; P9-NEXT: mffscrni 0, 0
178 ; DM-LABEL: setrnd_tonearest_tieeven:
179 ; DM: # %bb.0: # %entry
184 call void @llvm.set.rounding(i32 1)
188 define void @setrnd_toposinf() #0 {
189 ; PPC32-LABEL: setrnd_toposinf:
190 ; PPC32: # %bb.0: # %entry
191 ; PPC32-NEXT: mtfsb1 30
192 ; PPC32-NEXT: mtfsb0 31
195 ; PPC64-LABEL: setrnd_toposinf:
196 ; PPC64: # %bb.0: # %entry
197 ; PPC64-NEXT: mtfsb1 30
198 ; PPC64-NEXT: mtfsb0 31
201 ; PPC64LE-LABEL: setrnd_toposinf:
202 ; PPC64LE: # %bb.0: # %entry
203 ; PPC64LE-NEXT: mtfsb1 30
204 ; PPC64LE-NEXT: mtfsb0 31
207 ; P9_32-LABEL: setrnd_toposinf:
208 ; P9_32: # %bb.0: # %entry
209 ; P9_32-NEXT: mffscrni 0, 2
212 ; P9-LABEL: setrnd_toposinf:
213 ; P9: # %bb.0: # %entry
214 ; P9-NEXT: mffscrni 0, 2
217 ; DM-LABEL: setrnd_toposinf:
218 ; DM: # %bb.0: # %entry
223 call void @llvm.set.rounding(i32 2)
227 define void @setrnd_toneginf() #0 {
228 ; PPC32-LABEL: setrnd_toneginf:
229 ; PPC32: # %bb.0: # %entry
230 ; PPC32-NEXT: mtfsb1 30
231 ; PPC32-NEXT: mtfsb1 31
234 ; PPC64-LABEL: setrnd_toneginf:
235 ; PPC64: # %bb.0: # %entry
236 ; PPC64-NEXT: mtfsb1 30
237 ; PPC64-NEXT: mtfsb1 31
240 ; PPC64LE-LABEL: setrnd_toneginf:
241 ; PPC64LE: # %bb.0: # %entry
242 ; PPC64LE-NEXT: mtfsb1 30
243 ; PPC64LE-NEXT: mtfsb1 31
246 ; P9_32-LABEL: setrnd_toneginf:
247 ; P9_32: # %bb.0: # %entry
248 ; P9_32-NEXT: mffscrni 0, 3
251 ; P9-LABEL: setrnd_toneginf:
252 ; P9: # %bb.0: # %entry
253 ; P9-NEXT: mffscrni 0, 3
256 ; DM-LABEL: setrnd_toneginf:
257 ; DM: # %bb.0: # %entry
262 call void @llvm.set.rounding(i32 3)
266 define void @setrnd_var(i32 %x) #0 {
267 ; PPC32-LABEL: setrnd_var:
268 ; PPC32: # %bb.0: # %entry
269 ; PPC32-NEXT: stwu 1, -16(1)
271 ; PPC32-NEXT: stfd 0, 8(1)
272 ; PPC32-NEXT: clrlwi 4, 3, 30
273 ; PPC32-NEXT: lwz 5, 12(1)
274 ; PPC32-NEXT: rlwinm 3, 3, 31, 31, 31
275 ; PPC32-NEXT: xor 3, 3, 4
276 ; PPC32-NEXT: xori 3, 3, 1
277 ; PPC32-NEXT: rlwimi 5, 3, 0, 30, 31
278 ; PPC32-NEXT: stw 5, 12(1)
279 ; PPC32-NEXT: lfd 0, 8(1)
280 ; PPC32-NEXT: mtfsf 255, 0
281 ; PPC32-NEXT: addi 1, 1, 16
284 ; PPC64-LABEL: setrnd_var:
285 ; PPC64: # %bb.0: # %entry
287 ; PPC64-NEXT: stfd 0, -16(1)
288 ; PPC64-NEXT: clrlwi 4, 3, 30
289 ; PPC64-NEXT: rlwinm 3, 3, 31, 31, 31
290 ; PPC64-NEXT: ld 5, -16(1)
291 ; PPC64-NEXT: xor 3, 3, 4
292 ; PPC64-NEXT: xori 3, 3, 1
293 ; PPC64-NEXT: clrldi 3, 3, 32
294 ; PPC64-NEXT: rldimi 5, 3, 0, 62
295 ; PPC64-NEXT: std 5, -8(1)
296 ; PPC64-NEXT: lfd 0, -8(1)
297 ; PPC64-NEXT: mtfsf 255, 0
300 ; PPC64LE-LABEL: setrnd_var:
301 ; PPC64LE: # %bb.0: # %entry
302 ; PPC64LE-NEXT: mffs 0
303 ; PPC64LE-NEXT: clrlwi 4, 3, 30
304 ; PPC64LE-NEXT: rlwinm 3, 3, 31, 31, 31
305 ; PPC64LE-NEXT: stfd 0, -16(1)
306 ; PPC64LE-NEXT: xor 3, 3, 4
307 ; PPC64LE-NEXT: ld 4, -16(1)
308 ; PPC64LE-NEXT: xori 3, 3, 1
309 ; PPC64LE-NEXT: clrldi 3, 3, 32
310 ; PPC64LE-NEXT: rldimi 4, 3, 0, 62
311 ; PPC64LE-NEXT: std 4, -8(1)
312 ; PPC64LE-NEXT: lfd 0, -8(1)
313 ; PPC64LE-NEXT: mtfsf 255, 0
316 ; P9_32-LABEL: setrnd_var:
317 ; P9_32: # %bb.0: # %entry
318 ; P9_32-NEXT: stwu 1, -16(1)
319 ; P9_32-NEXT: clrlwi 4, 3, 30
320 ; P9_32-NEXT: rlwinm 3, 3, 31, 31, 31
321 ; P9_32-NEXT: xor 3, 3, 4
322 ; P9_32-NEXT: xori 3, 3, 1
323 ; P9_32-NEXT: stw 3, 12(1)
324 ; P9_32-NEXT: lfd 0, 8(1)
325 ; P9_32-NEXT: mffscrn 0, 0
326 ; P9_32-NEXT: addi 1, 1, 16
329 ; P9-LABEL: setrnd_var:
330 ; P9: # %bb.0: # %entry
331 ; P9-NEXT: clrlwi 4, 3, 30
332 ; P9-NEXT: rlwinm 3, 3, 31, 31, 31
333 ; P9-NEXT: xor 3, 3, 4
334 ; P9-NEXT: xori 3, 3, 1
335 ; P9-NEXT: mtfprd 0, 3
336 ; P9-NEXT: mffscrn 0, 0
339 ; DM-LABEL: setrnd_var:
340 ; DM: # %bb.0: # %entry
341 ; DM-NEXT: clrlwi 4, 3, 30
342 ; DM-NEXT: rlwinm 3, 3, 31, 31, 31
343 ; DM-NEXT: xor 3, 3, 4
344 ; DM-NEXT: xori 3, 3, 1
345 ; DM-NEXT: clrldi 3, 3, 32
347 ; DM-NEXT: mffprd 4, 0
348 ; DM-NEXT: rldimi 4, 3, 0, 62
349 ; DM-NEXT: mtfprd 0, 4
350 ; DM-NEXT: mtfsf 255, 0
353 call void @llvm.set.rounding(i32 %x)
357 declare i32 @llvm.get.rounding() #0
358 declare void @llvm.set.rounding(i32) #0
360 attributes #0 = { nounwind }