blob: 843481d67922d7264770137e5f484f1ba9486532 [file] [log] [blame]
Chad Rosierea25eca2017-03-02 20:48:11 +00001# RUN: llc -mtriple=aarch64--linux-gnu -run-pass=aarch64-copyelim %s -verify-machineinstrs -o - | FileCheck %s
Geoff Berry6bb79152017-02-22 19:10:45 +00002---
3# Check that bb.0 COPY is seen through to allow the bb.1 COPY of XZR to be removed.
4# CHECK-LABEL: name: test1
Puyan Lotfi43e94b12018-01-31 22:04:26 +00005# CHECK-NOT: COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +00006name: test1
7tracksRegLiveness: true
8body: |
9 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000010 liveins: $x0, $x1
Geoff Berry6bb79152017-02-22 19:10:45 +000011
Puyan Lotfi43e94b12018-01-31 22:04:26 +000012 $x0 = COPY $x1
13 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +000014
15 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000016 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +000017 B %bb.3
18
19 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000020 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +000021
Puyan Lotfi43e94b12018-01-31 22:04:26 +000022 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +000023
24 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000025 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +000026
Puyan Lotfi43e94b12018-01-31 22:04:26 +000027 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +000028
29...
30# Similar to test1, but with reversed COPY.
31# CHECK-LABEL: name: test2
Puyan Lotfi43e94b12018-01-31 22:04:26 +000032# CHECK-NOT: COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +000033name: test2
34tracksRegLiveness: true
35body: |
36 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000037 liveins: $x0, $x1
Geoff Berry6bb79152017-02-22 19:10:45 +000038
Puyan Lotfi43e94b12018-01-31 22:04:26 +000039 $x1 = COPY $x0
40 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +000041
42 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000043 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +000044 B %bb.3
45
46 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000047 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +000048
Puyan Lotfi43e94b12018-01-31 22:04:26 +000049 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +000050
51 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000052 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +000053
Puyan Lotfi43e94b12018-01-31 22:04:26 +000054 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +000055
56...
57# Similar to test1, but with a clobber that prevents removal of the XZR COPY.
58# CHECK-LABEL: name: test3
Puyan Lotfi43e94b12018-01-31 22:04:26 +000059# CHECK: COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +000060name: test3
61tracksRegLiveness: true
62body: |
63 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000064 liveins: $x0, $x1, $x2
Geoff Berry6bb79152017-02-22 19:10:45 +000065
Puyan Lotfi43e94b12018-01-31 22:04:26 +000066 $x0 = COPY $x1
67 $x1 = LDRXui $x1, 0
68 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +000069
70 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000071 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +000072 B %bb.3
73
74 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000075 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +000076
Puyan Lotfi43e94b12018-01-31 22:04:26 +000077 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +000078
79 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000080 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +000081
Puyan Lotfi43e94b12018-01-31 22:04:26 +000082 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +000083
84...
85# Similar to test2, but with a clobber that prevents removal of the XZR COPY.
86# CHECK-LABEL: name: test4
Puyan Lotfi43e94b12018-01-31 22:04:26 +000087# CHECK: COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +000088name: test4
89tracksRegLiveness: true
90body: |
91 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000092 liveins: $x0, $x1, $x2
Geoff Berry6bb79152017-02-22 19:10:45 +000093
Puyan Lotfi43e94b12018-01-31 22:04:26 +000094 $x1 = COPY $x0
95 $x1 = LDRXui $x1, 0
96 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +000097
98 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000099 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000100 B %bb.3
101
102 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000103 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000104
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000105 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +0000106
107 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000108 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000109
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000110 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000111
112...
113# Similar to test2, but with a clobber that prevents removal of the XZR COPY.
114# CHECK-LABEL: name: test5
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000115# CHECK: COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000116name: test5
117tracksRegLiveness: true
118body: |
119 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000120 liveins: $x0, $x1, $x2
Geoff Berry6bb79152017-02-22 19:10:45 +0000121
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000122 $x1 = COPY $x0
123 $x0 = LDRXui $x1, 0
124 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +0000125
126 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000127 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000128 B %bb.3
129
130 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000131 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000132
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000133 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +0000134
135 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000136 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000137
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000138 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000139
140...
141# Similar to test1, but with two levels of COPYs.
142# CHECK-LABEL: name: test6
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000143# CHECK-NOT: COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000144name: test6
145tracksRegLiveness: true
146body: |
147 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000148 liveins: $x0, $x1, $x2
Geoff Berry6bb79152017-02-22 19:10:45 +0000149
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000150 $x2 = COPY $x0
151 $x1 = COPY $x2
152 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +0000153
154 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000155 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000156 B %bb.3
157
158 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000159 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000160
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000161 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +0000162
163 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000164 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000165
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000166 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000167
168...
169# Similar to test1, but with two levels of COPYs and a clobber preventing COPY of XZR removal.
170# CHECK-LABEL: name: test7
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000171# CHECK: COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000172name: test7
173tracksRegLiveness: true
174body: |
175 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000176 liveins: $x0, $x1, $x2
Geoff Berry6bb79152017-02-22 19:10:45 +0000177
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000178 $x2 = COPY $x0
179 $x0 = LDRXui $x1, 0
180 $x1 = COPY $x2
181 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +0000182
183 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000184 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000185 B %bb.3
186
187 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000188 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000189
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000190 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +0000191
192 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000193 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000194
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000195 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000196
197...
198# Check that the TargetRegs vector clobber update loop in
199# AArch64RedundantCopyElimination::optimizeCopy works correctly.
200# CHECK-LABEL: name: test8
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000201# CHECK: x0 = COPY $xzr
202# CHECK: x1 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000203name: test8
204tracksRegLiveness: true
205body: |
206 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000207 liveins: $x0, $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000208
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000209 $x1 = COPY $x0
210 CBNZX $x1, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +0000211
212 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000213 liveins: $x0, $x2
Geoff Berry6bb79152017-02-22 19:10:45 +0000214
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000215 $x0, $x1 = LDPXi $x2, 0
216 $x0 = COPY $xzr
217 $x1 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000218 B %bb.3
219
220 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000221 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000222
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000223 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +0000224
225 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000226 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000227
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000228 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000229
230...
231# Check that copy isn't removed from a block with multiple predecessors.
232# CHECK-LABEL: name: test9
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000233# CHECK: x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000234# CHECK-NEXT: B %bb.3
235name: test9
236tracksRegLiveness: true
237body: |
238 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000239 liveins: $x0, $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000240
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000241 CBNZX $x0, %bb.2
Geoff Berry6bb79152017-02-22 19:10:45 +0000242
243 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000244 liveins: $x0, $x2
Geoff Berry6bb79152017-02-22 19:10:45 +0000245
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000246 $x0 = COPY $xzr
Geoff Berry6bb79152017-02-22 19:10:45 +0000247 B %bb.3
248
249 bb.2:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000250 liveins: $x1
Geoff Berry6bb79152017-02-22 19:10:45 +0000251
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000252 $x0 = LDRXui $x1, 0
Geoff Berry6bb79152017-02-22 19:10:45 +0000253
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000254 CBNZX $x1, %bb.1
Geoff Berry6bb79152017-02-22 19:10:45 +0000255
256 bb.3:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000257 liveins: $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000258
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000259 RET_ReallyLR implicit $x0
Geoff Berry6bb79152017-02-22 19:10:45 +0000260
261...
Chad Rosierea25eca2017-03-02 20:48:11 +0000262# Eliminate redundant MOVi32imm 7 in bb.1
263# Note: 32-bit compare/32-bit move imm
264# Kill marker should be removed from compare.
265# CHECK-LABEL: name: test10
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000266# CHECK: SUBSWri $w0, 7, 0, implicit-def $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000267# CHECK: bb.1:
268# CHECK-NOT: MOVi32imm
269name: test10
270tracksRegLiveness: true
271body: |
272 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000273 liveins: $w0, $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000274
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000275 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
276 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000277 B %bb.1
278
279 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000280 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000281
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000282 $w0 = MOVi32imm 7
283 STRWui killed $w0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000284
285 bb.2:
286 RET_ReallyLR
287...
288# Eliminate redundant MOVi32imm 7 in bb.1
289# Note: 64-bit compare/32-bit move imm w/implicit def
290# Kill marker should be removed from compare.
291# CHECK-LABEL: name: test11
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000292# CHECK: SUBSXri $x0, 7, 0, implicit-def $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000293# CHECK: bb.1:
294# CHECK-NOT: MOVi32imm
295name: test11
296tracksRegLiveness: true
297body: |
298 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000299 liveins: $x0, $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000300
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000301 dead $xzr = SUBSXri killed $x0, 7, 0, implicit-def $nzcv
302 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000303 B %bb.1
304
305 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000306 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000307
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000308 $w0 = MOVi32imm 7, implicit-def $x0
309 STRXui killed $x0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000310
311 bb.2:
312 RET_ReallyLR
313...
314# Eliminate redundant MOVi32imm 7 in bb.1
315# Note: 64-bit compare/32-bit move imm
316# Kill marker should be removed from compare.
317# CHECK-LABEL: name: test12
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000318# CHECK: SUBSXri $x0, 7, 0, implicit-def $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000319# CHECK: bb.1:
320# CHECK-NOT: MOVi32imm
321name: test12
322tracksRegLiveness: true
323body: |
324 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000325 liveins: $x0, $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000326
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000327 dead $xzr = SUBSXri killed $x0, 7, 0, implicit-def $nzcv
328 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000329 B %bb.1
330
331 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000332 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000333
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000334 $w0 = MOVi32imm 7
335 STRWui killed $w0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000336
337 bb.2:
338 RET_ReallyLR
339...
340# Don't eliminate MOVi32imm 7 in bb.1 as we don't necessarily know the upper 32-bits.
341# Note: 32-bit compare/32-bit move imm w/implicit def
342# Kill marker should remain on compare.
343# CHECK-LABEL: name: test13
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000344# CHECK: SUBSWri killed $w0, 7, 0, implicit-def $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000345# CHECK: bb.1:
346# CHECK: MOVi32imm
347name: test13
348tracksRegLiveness: true
349body: |
350 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000351 liveins: $w0, $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000352
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000353 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
354 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000355 B %bb.1
356
357 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000358 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000359
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000360 $w0 = MOVi32imm 7, implicit-def $x0
361 STRXui killed $x0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000362
363 bb.2:
364 RET_ReallyLR
365...
366# We can't eliminate the MOVi32imm because of the clobbering LDRWui.
367# CHECK-LABEL: name: test14
368# CHECK: bb.1:
369# CHECK: MOVi32imm
370name: test14
371tracksRegLiveness: true
372body: |
373 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000374 liveins: $w0, $x1, $x2
Chad Rosierea25eca2017-03-02 20:48:11 +0000375
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000376 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
377 $w0 = LDRWui $x1, 0
378 STRWui killed $w0, killed $x2, 0
379 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000380 B %bb.1
381
382 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000383 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000384
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000385 $w0 = MOVi32imm 7
386 STRWui killed $w0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000387
388 bb.2:
389 RET_ReallyLR
390...
391# We can't eliminate the MOVi32imm because of the clobbering LDRWui.
392# CHECK-LABEL: name: test15
393# CHECK: bb.1:
394# CHECK: MOVi32imm
395name: test15
396tracksRegLiveness: true
397body: |
398 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000399 liveins: $w0, $x1, $x2
Chad Rosierea25eca2017-03-02 20:48:11 +0000400
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000401 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
402 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000403 B %bb.1
404
405 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000406 liveins: $x1, $x2
Chad Rosierea25eca2017-03-02 20:48:11 +0000407
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000408 $w0 = LDRWui $x1, 0
409 STRWui killed $w0, killed $x2, 0
410 $w0 = MOVi32imm 7
411 STRWui killed $w0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000412
413 bb.2:
414 RET_ReallyLR
415...
416# Check that bb.0 COPY is seen through to allow the bb.1 MOVi32imm to be removed.
417# CHECK-LABEL: name: test16
418# CHECK: bb.1:
419# CHECK-NOT: MOVi32imm
420name: test16
421tracksRegLiveness: true
422body: |
423 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000424 liveins: $w0, $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000425
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000426 dead $wzr = SUBSWri $w0, 7, 0, implicit-def $nzcv
427 $w2 = COPY $w0
428 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000429 B %bb.1
430
431 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000432 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000433
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000434 $w2 = MOVi32imm 7
435 STRWui killed $w2, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000436
437 bb.2:
438 RET_ReallyLR
439...
440# Check that bb.1 MOVi32imm is not removed due to self clobbering compare.
441# CHECK-LABEL: name: test17
442# CHECK: bb.1:
443# CHECK: MOVi32imm
444name: test17
445tracksRegLiveness: true
446body: |
447 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000448 liveins: $w0, $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000449
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000450 dead $w0 = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
451 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosierea25eca2017-03-02 20:48:11 +0000452 B %bb.1
453
454 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000455 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000456
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000457 $w0 = MOVi32imm 7
458 STRWui killed $w0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000459
460 bb.2:
461 RET_ReallyLR
462...
463# Make sure the MOVi64imm is not removed. In one version of this patch the
464# MOVi64imm immediate was truncated to 32 bits and incorrectly matched because
465# the low 32 bits of 4252017623040 are all zero.
466# CHECK-LABEL: name: test18
467# CHECK: bb.1:
468# CHECK: MOVi64imm
469name: test18
470tracksRegLiveness: true
471body: |
472 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000473 liveins: $x0, $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000474
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000475 CBNZX killed $x0, %bb.2
Chad Rosierea25eca2017-03-02 20:48:11 +0000476 B %bb.1
477
478 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000479 liveins: $x1
Chad Rosierea25eca2017-03-02 20:48:11 +0000480
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000481 $x0 = MOVi64imm 4252017623040
482 STRXui killed $x0, killed $x1, 0
Chad Rosierea25eca2017-03-02 20:48:11 +0000483
484 bb.2:
485 RET_ReallyLR
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000486...
487# Eliminate redundant MOVi32imm -1 in bb.1
488# Note: 32-bit compare/32-bit move imm
489# Kill marker should be removed from compare.
490# CHECK-LABEL: name: test19
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000491# CHECK: ADDSWri $w0, 1, 0, implicit-def $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000492# CHECK: bb.1:
493# CHECK-NOT: MOVi32imm
494name: test19
495tracksRegLiveness: true
496body: |
497 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000498 liveins: $w0, $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000499
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000500 dead $wzr = ADDSWri killed $w0, 1, 0, implicit-def $nzcv
501 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000502 B %bb.1
503
504 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000505 liveins: $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000506
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000507 $w0 = MOVi32imm -1
508 STRWui killed $w0, killed $x1, 0
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000509
510 bb.2:
511 RET_ReallyLR
512...
513# Eliminate redundant MOVi64imm -1 in bb.1
514# Note: 64-bit compare/64-bit move imm
515# Kill marker should be removed from compare.
516# CHECK-LABEL: name: test20
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000517# CHECK: ADDSXri $x0, 1, 0, implicit-def $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000518# CHECK: bb.1:
519# CHECK-NOT: MOVi64imm
520name: test20
521tracksRegLiveness: true
522body: |
523 bb.0:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000524 liveins: $x0, $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000525
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000526 dead $xzr = ADDSXri killed $x0, 1, 0, implicit-def $nzcv
527 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000528 B %bb.1
529
530 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000531 liveins: $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000532
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000533 $x0 = MOVi64imm -1
534 STRXui killed $x0, killed $x1, 0
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000535
536 bb.2:
537 RET_ReallyLR
538...
539# Eliminate redundant MOVi32imm -1 in bb.1
540# Note: 64-bit compare/32-bit move imm
541# Kill marker should be removed from compare.
542# CHECK-LABEL: name: test21
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000543# CHECK: ADDSXri $x0, 1, 0, implicit-def $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000544# CHECK: bb.1:
545# CHECK-NOT: MOVi32imm
546name: test21
547tracksRegLiveness: true
548body: |
549 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000550 liveins: $x0, $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000551
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000552 dead $xzr = ADDSXri killed $x0, 1, 0, implicit-def $nzcv
553 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000554 B %bb.1
555
556 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000557 liveins: $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000558
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000559 $w0 = MOVi32imm -1
560 STRWui killed $w0, killed $x1, 0
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000561
562 bb.2:
563 RET_ReallyLR
564...
565# Don't eliminate MOVi64imm -1 in bb.1 as we don't necessarily know the upper 32-bits.
566# Note: 32-bit compare/64-bit move imm
567# CHECK-LABEL: name: test22
568# CHECK: bb.1:
569# CHECK: MOVi64imm
570name: test22
571tracksRegLiveness: true
572body: |
573 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000574 liveins: $w0, $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000575
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000576 dead $wzr = ADDSWri killed $w0, 1, 0, implicit-def $nzcv
577 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000578 B %bb.1
579
580 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000581 liveins: $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000582
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000583 $x0 = MOVi64imm -1
584 STRXui killed $x0, killed $x1, 0
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000585
586 bb.2:
587 RET_ReallyLR
588...
589# Eliminate redundant MOVi32imm 4096 in bb.1 when the compare has a shifted immediate.
590# CHECK-LABEL: name: test23
591# CHECK: bb.1:
592# CHECK-NOT: MOVi32imm
593name: test23
594tracksRegLiveness: true
595body: |
596 bb.0.entry:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000597 liveins: $w0, $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000598
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000599 dead $wzr = SUBSWri killed $w0, 1, 12, implicit-def $nzcv
600 Bcc 1, %bb.2, implicit killed $nzcv
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000601 B %bb.1
602
603 bb.1:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000604 liveins: $x1
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000605
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000606 $w0 = MOVi32imm 4096
607 STRWui killed $w0, killed $x1, 0
Chad Rosier9a70c7c2017-03-06 21:20:00 +0000608
609 bb.2:
610 RET_ReallyLR