1 # RUN: llc -ppc-asm-full-reg-names -mtriple=powerpc64le-unknown-linux-gnu \
2 # RUN: -run-pass ppc-mi-peepholes %s -o - -verify-machineinstrs | FileCheck %s
6 #CHECK: name: testFoldRLWINM
7 tracksRegLiveness: true
12 %1:gprc = COPY %0.sub_32:g8rc
13 %2:gprc = RLWINM %1:gprc, 27, 5, 31
14 ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 5, 31
15 %3:gprc = RLWINM %2:gprc, 19, 0, 12
16 ; CHECK: %3:gprc = RLWINM %1, 14, 0, 12
17 BLR8 implicit $lr8, implicit $rm
20 name: testFoldRLWINMSrcFullMask1
21 #CHECK: name: testFoldRLWINMSrcFullMask1
22 tracksRegLiveness: true
27 %1:gprc = COPY %0.sub_32:g8rc
28 %2:gprc = RLWINM %1:gprc, 27, 0, 31
29 ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 0, 31
30 %3:gprc = RLWINM %2:gprc, 19, 0, 12
31 ; CHECK: %3:gprc = RLWINM %1, 14, 0, 12
32 BLR8 implicit $lr8, implicit $rm
35 name: testFoldRLWINMSrcFullMask2
36 #CHECK: name: testFoldRLWINMSrcFullMask2
37 tracksRegLiveness: true
42 %1:gprc = COPY %0.sub_32:g8rc
43 %2:gprc = RLWINM %1:gprc, 27, 10, 9
44 ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 10, 9
45 %3:gprc = RLWINM %2:gprc, 19, 10, 1
46 ; CHECK: %3:gprc = RLWINM %1, 14, 10, 1
47 BLR8 implicit $lr8, implicit $rm
50 name: testFoldRLWINMSrcWrapped
51 #CHECK: name: testFoldRLWINMSrcWrapped
52 tracksRegLiveness: true
57 %1:gprc = COPY %0.sub_32:g8rc
58 %2:gprc = RLWINM %1:gprc, 27, 30, 10
59 ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 30, 10
60 %3:gprc = RLWINM %2:gprc, 19, 0, 12
61 ; CHECK: %3:gprc = RLWINM %1, 14, 11, 12
62 BLR8 implicit $lr8, implicit $rm
65 name: testFoldRLWINMUserWrapped
66 #CHECK: name: testFoldRLWINMUserWrapped
67 tracksRegLiveness: true
72 %1:gprc = COPY %0.sub_32:g8rc
73 %2:gprc = RLWINM %1:gprc, 10, 5, 31
74 ; CHECK: %2:gprc = RLWINM %1, 10, 5, 31
75 %3:gprc = RLWINM %2:gprc, 10, 30, 5
76 ; CHECK: %3:gprc = RLWINM %2, 10, 30, 5
77 BLR8 implicit $lr8, implicit $rm
80 name: testFoldRLWINMResultWrapped
81 #CHECK: name: testFoldRLWINMResultWrapped
82 tracksRegLiveness: true
87 %1:gprc = COPY %0.sub_32:g8rc
88 %2:gprc = RLWINM %1:gprc, 10, 20, 10
89 ; CHECK: %2:gprc = RLWINM %1, 10, 20, 10
90 %3:gprc = RLWINM %2:gprc, 10, 0, 31
91 ; CHECK: %3:gprc = RLWINM %2, 10, 0, 31
92 BLR8 implicit $lr8, implicit $rm
95 name: testFoldRLWINMMultipleUses
96 #CHECK: name: testFoldRLWINMMultipleUses
97 tracksRegLiveness: true
102 %1:gprc = COPY %0.sub_32:g8rc
103 %2:gprc = RLWINM killed %1:gprc, 27, 5, 31
104 ; CHECK: %2:gprc = RLWINM %1, 27, 5, 31
105 %3:gprc = RLWINM %2:gprc, 19, 0, 12
106 ; CHECK: %3:gprc = RLWINM killed %1, 14, 0, 12
107 STW %3:gprc, %2:gprc, 100
108 ; CHECK: STW %3, %2, 100
109 BLR8 implicit $lr8, implicit $rm
112 name: testFoldRLWINMToZero
113 #CHECK: name: testFoldRLWINMToZero
114 tracksRegLiveness: true
119 %1:gprc = COPY %0.sub_32:g8rc
120 %2:gprc = RLWINM %1:gprc, 27, 5, 10
121 ; CHECK-NOT: RLWINM %1,
122 %3:gprc = RLWINM %2:gprc, 8, 5, 10
123 ; CHECK: %3:gprc = LI 0
124 BLR8 implicit $lr8, implicit $rm
127 name: testFoldRLWINM_recToZero
128 #CHECK: name: testFoldRLWINM_recToZero
129 tracksRegLiveness: true
134 %1:gprc = COPY %0.sub_32:g8rc
135 %2:gprc = RLWINM %1:gprc, 27, 5, 10
136 ; CHECK-NOT: RLWINM %1,
137 %3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
138 ; CHECK: %3:gprc = ANDI_rec %1, 0, implicit-def $cr0
139 BLR8 implicit $lr8, implicit $rm
142 name: testFoldRLWINMoToZeroSrcCanNotBeDeleted
143 #CHECK: name: testFoldRLWINMoToZeroSrcCanNotBeDeleted
144 tracksRegLiveness: true
149 %1:gprc = COPY %0.sub_32:g8rc
150 %2:gprc = RLWINM_rec %1:gprc, 27, 5, 10, implicit-def $cr0
151 ; CHECK: %2:gprc = RLWINM_rec %1, 27, 5, 10, implicit-def $cr0
152 %3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
153 ; CHECK: %3:gprc = ANDI_rec %1, 0, implicit-def $cr0
154 BLR8 implicit $lr8, implicit $rm
157 name: testFoldRLWINMInvalidMask
158 #CHECK: name: testFoldRLWINMInvalidMask
159 tracksRegLiveness: true
164 %1:gprc = COPY %0.sub_32:g8rc
165 %2:gprc = RLWINM %1:gprc, 20, 5, 31
166 ; CHECK: %2:gprc = RLWINM %1, 20, 5, 31
167 %3:gprc = RLWINM %2:gprc, 19, 10, 20
168 ; CHECK: %3:gprc = RLWINM %2, 19, 10, 20
169 BLR8 implicit $lr8, implicit $rm
172 name: testFoldRLWINMLIWrapMask
173 #CHECK: name: testFoldRLWINMLIWrapMask
174 tracksRegLiveness: true
180 ; CHECK: %2:gprc = LI 200
181 %2:gprc = RLWINM %1:gprc, 1, 3, 2
182 STW %2:gprc, %0:gprc, 100
183 BLR8 implicit $lr8, implicit $rm
186 name: testFoldRLWINMAndANDI
187 tracksRegLiveness: true
191 ; CHECK-LABEL: name: testFoldRLWINMAndANDI
192 ; CHECK: liveins: $x3
193 ; CHECK: [[COPY:%[0-9]+]]:g8rc = COPY $x3
194 ; CHECK: [[COPY1:%[0-9]+]]:gprc = COPY [[COPY]].sub_32
195 ; CHECK: [[RLWINM:%[0-9]+]]:gprc = RLWINM [[COPY1]], 4, 28, 31
196 ; CHECK: [[ANDI_rec:%[0-9]+]]:gprc = ANDI_rec [[RLWINM]], 4, implicit-def $cr0
197 ; CHECK: BLR8 implicit $lr8, implicit $rm
199 %1:gprc = COPY %0.sub_32:g8rc
200 %2:gprc = RLWINM %1:gprc, 4, 28, 31
201 %3:gprc = ANDI_rec %2:gprc, 4, implicit-def $cr0
202 BLR8 implicit $lr8, implicit $rm