1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
4 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
5 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
7 ; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu \
8 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
9 ; RUN: FileCheck %s --check-prefix=CHECK32
11 ; These test cases aim to test constant materialization using the pli instruction on Power10.
13 define signext i32 @t_16BitsMinRequiring34Bits() {
14 ; CHECK-LABEL: t_16BitsMinRequiring34Bits:
15 ; CHECK: pli r3, 32768
17 ; CHECK32-LABEL: t_16BitsMinRequiring34Bits:
18 ; CHECK32: pli r3, 32768
25 define signext i32 @t_16Bits() {
26 ; CHECK-LABEL: t_16Bits:
27 ; CHECK: pli r3, 62004
29 ; CHECK32-LABEL: t_16Bits:
30 ; CHECK32: pli r3, 62004
37 define signext i32 @t_lt32gt16BitsNonShiftable() {
38 ; CHECK-LABEL: t_lt32gt16BitsNonShiftable:
39 ; CHECK: pli r3, 1193046
41 ; CHECK32-LABEL: t_lt32gt16BitsNonShiftable:
42 ; CHECK32: pli r3, 1193046
49 define signext i32 @t_32Bits() {
50 ; CHECK-LABEL: t_32Bits:
51 ; CHECK: pli r3, -231451016
53 ; CHECK32-LABEL: t_32Bits:
54 ; CHECK32: pli r3, -231451016
61 define i64 @t_34BitsLargestPositive() {
62 ; CHECK-LABEL: t_34BitsLargestPositive:
63 ; CHECK: pli r3, 8589934591
65 ; CHECK32-LABEL: t_34BitsLargestPositive:
67 ; CHECK32-NEXT: li r4, -1
74 define i64 @t_neg34Bits() {
75 ; CHECK-LABEL: t_neg34Bits:
76 ; CHECK: pli r3, -8284514696
78 ; CHECK32-LABEL: t_neg34Bits:
80 ; CHECK32-NEXT: pli r4, 305419896
87 define signext i32 @t_16BitsMinRequiring34BitsMinusOne() {
88 ; CHECK-LABEL: t_16BitsMinRequiring34BitsMinusOne:
91 ; CHECK32-LABEL: t_16BitsMinRequiring34BitsMinusOne:
92 ; CHECK32: li r3, 32767
99 define signext i32 @t_lt16Bits() {
100 ; CHECK-LABEL: t_lt16Bits:
103 ; CHECK32-LABEL: t_lt16Bits:
104 ; CHECK32: li r3, 291
111 define signext i32 @t_neglt16Bits() {
112 ; CHECK-LABEL: t_neglt16Bits:
113 ; CHECK: li r3, -3805
115 ; CHECK32-LABEL: t_neglt16Bits:
116 ; CHECK32: li r3, -3805
123 define signext i32 @t_neg16Bits() {
124 ; CHECK-LABEL: t_neg16Bits:
125 ; CHECK: li r3, -32204
127 ; CHECK32-LABEL: t_neg16Bits:
128 ; CHECK32: li r3, -32204
135 define signext i32 @t_lt32gt16BitsShiftable() {
136 ; CHECK-LABEL: t_lt32gt16BitsShiftable:
139 ; CHECK32-LABEL: t_lt32gt16BitsShiftable:
140 ; CHECK32: lis r3, 18
147 define signext i32 @t_32gt16BitsShiftable() {
148 ; CHECK-LABEL: t_32gt16BitsShiftable:
149 ; CHECK: lis r3, -3532
151 ; CHECK32-LABEL: t_32gt16BitsShiftable:
152 ; CHECK32: lis r3, -3532
159 define signext i32 @t_32BitsZero() {
160 ; CHECK-LABEL: t_32BitsZero:
163 ; CHECK32-LABEL: t_32BitsZero:
171 define signext i32 @t_32BitsAllOnes() {
172 ; CHECK-LABEL: t_32BitsAllOnes:
175 ; CHECK32-LABEL: t_32BitsAllOnes:
183 define i64 @t_34BitsLargestPositivePlus() {
184 ; CHECK-LABEL: t_34BitsLargestPositivePlus:
186 ; CHECK-NEXT: rldic r3, r3, 33, 30
188 ; CHECK32-LABEL: t_34BitsLargestPositivePlus:
190 ; CHECK32-NEXT: li r4, 0
197 define i64 @t_34Bits() {
198 ; CHECK-LABEL: t_34Bits:
199 ; CHECK: pli r3, 1648790223
200 ; CHECK-NEXT: rldic r3, r3, 3, 30
202 ; CHECK32-LABEL: t_34Bits:
204 ; CHECK32-NEXT: pli r4, 305419896
211 define i64 @t_35Bits() {
212 ; CHECK-LABEL: t_35Bits:
213 ; CHECK: pli r3, 4266035919
214 ; CHECK-NEXT: rldic r3, r3, 3, 29
216 ; CHECK32-LABEL: t_35Bits:
218 ; CHECK32-NEXT: pli r4, -231451016
225 ; (Value >> Shift) can be expressed in 34 bits
226 define i64 @t_Shift() {
227 ; CHECK-LABEL: t_Shift:
228 ; CHECK: pli r3, 8522759166
229 ; CHECK-NEXT: rotldi r3, r3, 48
234 ret i64 18157950747604548606
237 ; Leading Zeros + Following Ones + Trailing Zeros > 30
238 define i64 @t_LZFOTZ() {
239 ; CHECK-LABEL: t_LZFOTZ:
240 ; CHECK: pli r3, -349233
241 ; CHECK-NEXT: rldic r3, r3, 4, 12
246 ret i64 4503599621782768
249 ; Leading Zeros + Trailing Ones > 30
250 define i64 @t_LZTO() {
251 ; CHECK-LABEL: t_LZTO:
252 ; CHECK: pli r3, -2684406441
253 ; CHECK-NEXT: rldicl r3, r3, 11, 19
257 ret i64 29686707699711
260 ; Leading Zeros + Trailing Ones + Following Zeros > 30
261 define i64 @t_LZTOFO() {
262 ; CHECK-LABEL: t_LZTOFO:
263 ; CHECK: pli r3, -5720033968
264 ; CHECK-NEXT: rldicl r3, r3, 11, 12
268 ret i64 4491884997806079
271 ; Requires full expansion
272 define i64 @t_Full64Bits1() {
273 ; CHECK-LABEL: t_Full64Bits1:
274 ; CHECK: pli r4, 2146500607
275 ; CHECK-NEXT: pli r3, 4043305214
276 ; CHECK-NEXT: rldimi r3, r4, 32, 0
280 ret i64 9219149911952453886
283 ; Requires full expansion
284 define i64 @t_Ful64Bits2() {
285 ; CHECK-LABEL: t_Ful64Bits2:
286 ; CHECK: pli r4, 4042326015
287 ; CHECK-NEXT: pli r3, 4043305214
288 ; CHECK-NEXT: rldimi r3, r4, 32, 0
292 ret i64 17361658038238310654
295 ; A splat of 32 bits: 32 Bits Low == 32 Bits High
296 define i64 @t_Splat32Bits() {
297 ; CHECK-LABEL: t_Splat32Bits:
298 ; CHECK: pli r3, 262916796
299 ; CHECK-NEXT: rldimi r3, r3, 32, 0
303 ret i64 1129219040652020412
306 ; Producing `pli` when the constant fits within 34-bits and the constant
307 ; is being produced in other transformations (such as complex bit permutations).
308 define i64 @t_34Bits_Complex(i64 %a, i64 %b) {
309 ; CHECK-LABEL: t_34Bits_Complex:
310 ; CHECK: # %bb.0: # %entry
311 ; CHECK-NEXT: rotldi r4, r4, 30
312 ; CHECK-NEXT: rldimi r3, r4, 34, 31
313 ; CHECK-NEXT: pli r4, -268435457
314 ; CHECK-NEXT: and r3, r3, r4
317 ; CHECK32-LABEL: t_34Bits_Complex:
318 ; CHECK32: # %bb.0: # %entry
319 ; CHECK32-NEXT: rlwinm r4, r6, 0, 4, 2
320 ; CHECK32-NEXT: rlwimi r3, r5, 0, 31, 29
323 %and = and i64 %a, 8589934592
324 %and1 = and i64 %b, -8858370049
325 %or = or i64 %and1, %and
329 ; The load immediates resulting from phi-nodes are needed to test whether
330 ; li/lis is preferred to pli by the instruction selector.
331 define dso_local void @t_phiNode() {
332 ; CHECK-LABEL: t_phiNode:
334 ; CHECK-NEXT: li r5, 291
335 ; CHECK-NEXT: li r4, 0
336 ; CHECK-NEXT: cmpwi r3, 1
337 ; CHECK-NEXT: li r3, -1
338 ; CHECK: pli r6, 2147483647
339 ; CHECK-NEXT: pli r5, 1193046
340 ; CHECK-NEXT: pli r4, 32768
341 ; CHECK-NEXT: pli r3, -231451016
342 ; CHECK32-LABEL: t_phiNode:
343 ; CHECK32: lis r6, 18
344 ; CHECK32-NEXT: li r5, 291
345 ; CHECK32-NEXT: li r4, 0
346 ; CHECK32-NEXT: cmpwi r3, 1
347 ; CHECK32-NEXT: li r3, -1
348 ; CHECK32: pli r6, 2147483647
349 ; CHECK32-NEXT: pli r5, 1193046
350 ; CHECK32-NEXT: pli r4, 32768
351 ; CHECK32-NEXT: pli r3, -231451016
356 while.body: ; preds = %if.else.i, %entry
357 br label %while.body.i
359 while.body.i: ; preds = %sw.epilog.i, %while.body
360 %a.1.i = phi i32 [ %a.2.i, %sw.epilog.i ], [ -1, %while.body ]
361 %b.1.i = phi i32 [ %b.2.i, %sw.epilog.i ], [ 0, %while.body ]
362 %c.1.i = phi i32 [ %c.2.i, %sw.epilog.i ], [ 291, %while.body ]
363 %d.1.i = phi i32 [ %d.2.i, %sw.epilog.i ], [ 1179648, %while.body ]
364 %0 = load i8, ptr null, align 1
365 %cmp1.i = icmp eq i8 %0, 1
366 br i1 %cmp1.i, label %if.then.i, label %if.else.i
368 if.then.i: ; preds = %while.body.i
369 switch i8 undef, label %sw.default.i [
370 i8 3, label %sw.epilog.i
371 i8 2, label %sw.bb1.i
374 sw.bb1.i: ; preds = %if.then.i
375 br label %sw.epilog.i
377 sw.default.i: ; preds = %if.then.i
380 sw.epilog.i: ; preds = %sw.bb2.i, %sw.bb1.i, %if.then.i
381 %a.2.i = phi i32 [ -231451016, %sw.bb1.i ], [ %a.1.i, %if.then.i ]
382 %b.2.i = phi i32 [ 32768, %sw.bb1.i ], [ %b.1.i, %if.then.i ]
383 %c.2.i = phi i32 [ 1193046, %sw.bb1.i ], [ %c.1.i, %if.then.i ]
384 %d.2.i = phi i32 [ 2147483647, %sw.bb1.i ], [ %d.1.i, %if.then.i ]
385 br label %while.body.i
387 if.else.i: ; preds = %while.body.i
388 call void @func2(i32 signext %a.1.i, i32 signext %b.1.i, i32 signext %c.1.i, i32 signext %d.1.i)
392 declare void @func2(i32, i32, i32, i32)