1 # RUN: llc -run-pass ppc-mi-peepholes -ppc-convert-rr-to-ri %s -o - | FileCheck %s
2 # RUN: llc -start-after ppc-mi-peepholes -ppc-late-peephole %s -o - | FileCheck %s --check-prefix=CHECK-LATE
4 ; ModuleID = 'rlwinm_rldicl_to_andi.ll'
5 source_filename = "rlwinm_rldicl_to_andi.c"
6 target datalayout = "e-m:e-i64:64-n32:64"
7 target triple = "powerpc64le-unknown-linux-gnu"
9 ; Function Attrs: norecurse nounwind readnone
10 define signext i32 @testRLWINMSingleUseDef(i32 signext %a, i32 signext %b) local_unnamed_addr #0 {
12 %shl.mask = and i32 %a, 1048575
13 %tobool = icmp eq i32 %shl.mask, 0
14 %cond = select i1 %tobool, i32 %a, i32 %b
18 ; Function Attrs: norecurse nounwind readnone
19 define signext i32 @testRLWINMNoGPRUseZero(i32 signext %a, i32 signext %b) local_unnamed_addr #0 {
21 %shl.mask = and i32 %a, 1048575
22 %tobool = icmp eq i32 %shl.mask, 0
23 %cond = select i1 %tobool, i32 %a, i32 %b
27 ; Function Attrs: norecurse nounwind readnone
28 define signext i32 @testRLWINMNoGPRUseNonZero(i32 signext %a, i32 signext %b) local_unnamed_addr #0 {
30 %shl.mask = and i32 %a, 1048575
31 %tobool = icmp eq i32 %shl.mask, 0
32 %cond = select i1 %tobool, i32 %a, i32 %b
36 ; Function Attrs: norecurse nounwind readnone
37 define i64 @testRLDICLSingleUseDef(i64 %a, i64 %b) local_unnamed_addr #0 {
39 %shl.mask = and i64 %a, 4503599627370495
40 %tobool = icmp eq i64 %shl.mask, 0
41 %cond = select i1 %tobool, i64 %a, i64 %b
45 ; Function Attrs: norecurse nounwind readnone
46 define i64 @testRLDICLNoGPRUseZero(i64 %a, i64 %b) local_unnamed_addr #0 {
48 %shl.mask = and i64 %a, 4503599627370495
49 %tobool = icmp eq i64 %shl.mask, 0
50 %cond = select i1 %tobool, i64 %a, i64 %b
54 ; Function Attrs: norecurse nounwind readnone
55 define i64 @testRLDICLNoGPRUseNonZero(i64 %a, i64 %b) local_unnamed_addr #0 {
57 %shl.mask = and i64 %a, 4503599627370495
58 %tobool = icmp eq i64 %shl.mask, 0
59 %cond = select i1 %tobool, i64 %a, i64 %b
63 attributes #0 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64le" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+htm,+power8-vector,+vsx,-power9-vector" "unsafe-fp-math"="false" "use-soft-float"="false" }
65 !llvm.module.flags = !{!0, !1}
68 !0 = !{i32 1, !"wchar_size", i32 4}
69 !1 = !{i32 7, !"PIC Level", i32 2}
70 !2 = !{!"clang version 7.0.0 (trunk 322378)"}
74 name: testRLWINMSingleUseDef
75 # CHECK: testRLWINMSingleUseDef
76 # CHECK-LATE: testRLWINMSingleUseDef
78 exposesReturnsTwice: false
80 regBankSelected: false
82 tracksRegLiveness: true
84 - { id: 0, class: g8rc, preferred-register: '' }
85 - { id: 1, class: g8rc, preferred-register: '' }
86 - { id: 2, class: gprc_and_gprc_nor0, preferred-register: '' }
87 - { id: 3, class: gprc, preferred-register: '' }
88 - { id: 4, class: gprc_and_gprc_nor0, preferred-register: '' }
89 - { id: 5, class: crrc, preferred-register: '' }
90 - { id: 6, class: gprc, preferred-register: '' }
91 - { id: 7, class: g8rc, preferred-register: '' }
93 - { reg: '$x3', virtual-reg: '%0' }
94 - { reg: '$x4', virtual-reg: '%1' }
96 isFrameAddressTaken: false
97 isReturnAddressTaken: false
106 maxCallFrameSize: 4294967295
107 hasOpaqueSPAdjustment: false
109 hasMustTailInVarArgFunc: false
121 %2:gprc_and_gprc_nor0 = COPY %1.sub_32
123 %4:gprc_and_gprc_nor0 = RLWINM_rec %3, 2, 20, 31, implicit-def $cr0
125 ; CHECK: ANDI_rec killed %3, 4055
126 ; CHECK-LATE-NOT: andi.
127 ; CHECK-LATE: rlwinm.
128 %5:crrc = COPY killed $cr0
129 %6:gprc = ISEL %4, %2, %5.sub_eq
130 %7:g8rc = EXTSW_32_64 killed %6
132 BLR8 implicit $lr8, implicit $rm, implicit $x3
136 name: testRLWINMNoGPRUseZero
138 exposesReturnsTwice: false
140 regBankSelected: false
142 tracksRegLiveness: true
144 - { id: 0, class: g8rc, preferred-register: '' }
145 - { id: 1, class: g8rc, preferred-register: '' }
146 - { id: 2, class: gprc_and_gprc_nor0, preferred-register: '' }
147 - { id: 3, class: gprc_and_gprc_nor0, preferred-register: '' }
148 - { id: 4, class: gprc, preferred-register: '' }
149 - { id: 5, class: crrc, preferred-register: '' }
150 - { id: 6, class: gprc, preferred-register: '' }
151 - { id: 7, class: g8rc, preferred-register: '' }
153 - { reg: '$x3', virtual-reg: '%0' }
154 - { reg: '$x4', virtual-reg: '%1' }
156 isFrameAddressTaken: false
157 isReturnAddressTaken: false
166 maxCallFrameSize: 4294967295
167 hasOpaqueSPAdjustment: false
169 hasMustTailInVarArgFunc: false
181 %2:gprc_and_gprc_nor0 = COPY %1.sub_32
182 %3:gprc_and_gprc_nor0 = LI 1
183 %4:gprc = RLWINM_rec %3, 21, 20, 31, implicit-def $cr0
185 ; CHECK: ANDI_rec %3, 0
186 ; CHECK-LATE: li [[IMM:[0-9]+]], 1
187 ; CHECK-LATE: andi. {{[0-9]+}}, [[IMM]], 0
188 %5:crrc = COPY killed $cr0
189 %6:gprc = ISEL %3, %2, %5.sub_eq
190 %7:g8rc = EXTSW_32_64 killed %6
192 BLR8 implicit $lr8, implicit $rm, implicit $x3
196 name: testRLWINMNoGPRUseNonZero
198 exposesReturnsTwice: false
200 regBankSelected: false
202 tracksRegLiveness: true
204 - { id: 0, class: g8rc, preferred-register: '' }
205 - { id: 1, class: g8rc, preferred-register: '' }
206 - { id: 2, class: gprc_and_gprc_nor0, preferred-register: '' }
207 - { id: 3, class: gprc_and_gprc_nor0, preferred-register: '' }
208 - { id: 4, class: gprc, preferred-register: '' }
209 - { id: 5, class: crrc, preferred-register: '' }
210 - { id: 6, class: gprc, preferred-register: '' }
211 - { id: 7, class: g8rc, preferred-register: '' }
213 - { reg: '$x3', virtual-reg: '%0' }
214 - { reg: '$x4', virtual-reg: '%1' }
216 isFrameAddressTaken: false
217 isReturnAddressTaken: false
226 maxCallFrameSize: 4294967295
227 hasOpaqueSPAdjustment: false
229 hasMustTailInVarArgFunc: false
241 %2:gprc_and_gprc_nor0 = COPY %1.sub_32
242 %3:gprc_and_gprc_nor0 = LI -11
243 %4:gprc = RLWINM_rec %3, 2, 20, 31, implicit-def $cr0
245 ; CHECK: ANDI_rec %3, 65525
246 ; CHECK-LATE-NOT: andi.
247 ; CHECK-LATE: rlwinm.
248 %5:crrc = COPY killed $cr0
249 %6:gprc = ISEL %3, %2, %5.sub_eq
250 %7:g8rc = EXTSW_32_64 killed %6
252 BLR8 implicit $lr8, implicit $rm, implicit $x3
256 name: testRLDICLSingleUseDef
258 exposesReturnsTwice: false
260 regBankSelected: false
262 tracksRegLiveness: true
264 - { id: 0, class: g8rc, preferred-register: '' }
265 - { id: 1, class: g8rc_and_g8rc_nox0, preferred-register: '' }
266 - { id: 2, class: g8rc_and_g8rc_nox0, preferred-register: '' }
267 - { id: 3, class: crrc, preferred-register: '' }
268 - { id: 4, class: g8rc, preferred-register: '' }
270 - { reg: '$x3', virtual-reg: '%0' }
271 - { reg: '$x4', virtual-reg: '%1' }
273 isFrameAddressTaken: false
274 isReturnAddressTaken: false
283 maxCallFrameSize: 4294967295
284 hasOpaqueSPAdjustment: false
286 hasMustTailInVarArgFunc: false
296 %1:g8rc_and_g8rc_nox0 = COPY $x4
298 %2:g8rc_and_g8rc_nox0 = RLDICL_rec %0, 2, 49, implicit-def $cr0
300 ; CHECK: ANDI8_rec killed %0, 32727
301 ; CHECK-LATE-NOT: andi.
302 ; CHECK-LATE: rldicl.
303 %3:crrc = COPY killed $cr0
304 %4:g8rc = ISEL8 %2, %1, %3.sub_eq
306 BLR8 implicit $lr8, implicit $rm, implicit $x3
310 name: testRLDICLNoGPRUseZero
312 exposesReturnsTwice: false
314 regBankSelected: false
316 tracksRegLiveness: true
318 - { id: 0, class: g8rc_and_g8rc_nox0, preferred-register: '' }
319 - { id: 1, class: g8rc_and_g8rc_nox0, preferred-register: '' }
320 - { id: 2, class: g8rc, preferred-register: '' }
321 - { id: 3, class: crrc, preferred-register: '' }
322 - { id: 4, class: g8rc, preferred-register: '' }
324 - { reg: '$x3', virtual-reg: '%0' }
325 - { reg: '$x4', virtual-reg: '%1' }
327 isFrameAddressTaken: false
328 isReturnAddressTaken: false
337 maxCallFrameSize: 4294967295
338 hasOpaqueSPAdjustment: false
340 hasMustTailInVarArgFunc: false
350 %1:g8rc_and_g8rc_nox0 = COPY $x4
351 %0:g8rc_and_g8rc_nox0 = LI8 1
352 %2:g8rc = RLDICL_rec %0, 32, 33, implicit-def $cr0
354 ; CHECK: ANDI8_rec %0, 0
355 ; CHECK-LATE: li [[IMM:[0-9]+]], 1
356 ; CHECK-LATE: andi. {{[0-9]+}}, [[IMM]], 0
357 %3:crrc = COPY killed $cr0
358 %4:g8rc = ISEL8 %0, %1, %3.sub_eq
360 BLR8 implicit $lr8, implicit $rm, implicit $x3
364 name: testRLDICLNoGPRUseNonZero
366 exposesReturnsTwice: false
368 regBankSelected: false
370 tracksRegLiveness: true
372 - { id: 0, class: g8rc_and_g8rc_nox0, preferred-register: '' }
373 - { id: 1, class: g8rc_and_g8rc_nox0, preferred-register: '' }
374 - { id: 2, class: g8rc, preferred-register: '' }
375 - { id: 3, class: crrc, preferred-register: '' }
376 - { id: 4, class: g8rc, preferred-register: '' }
378 - { reg: '$x3', virtual-reg: '%0' }
379 - { reg: '$x4', virtual-reg: '%1' }
381 isFrameAddressTaken: false
382 isReturnAddressTaken: false
391 maxCallFrameSize: 4294967295
392 hasOpaqueSPAdjustment: false
394 hasMustTailInVarArgFunc: false
404 %1:g8rc_and_g8rc_nox0 = COPY $x4
405 %0:g8rc_and_g8rc_nox0 = LI8 -11
406 %2:g8rc = RLDICL_rec %0, 2, 49, implicit-def $cr0
408 ; CHECK: ANDI8_rec %0, 65525
409 ; CHECK-LATE-NOT: andi.
410 ; CHECK-LATE: rldicl.
411 %3:crrc = COPY killed $cr0
412 %4:g8rc = ISEL8 %0, %1, %3.sub_eq
414 BLR8 implicit $lr8, implicit $rm, implicit $x3