1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
5 tracksRegLiveness: true
11 ; CHECK-LABEL: name: right_ident_sub
13 ; CHECK: %x:_(s32) = COPY $w0
14 ; CHECK: $w0 = COPY %x(s32)
15 ; CHECK: RET_ReallyLR implicit $w0
17 %cst:_(s32) = G_CONSTANT i32 0
18 %op:_(s32) = G_SUB %x(s32), %cst
20 RET_ReallyLR implicit $w0
25 tracksRegLiveness: true
31 ; CHECK-LABEL: name: right_ident_add
33 ; CHECK: %x:_(s32) = COPY $w0
34 ; CHECK: $w0 = COPY %x(s32)
35 ; CHECK: RET_ReallyLR implicit $w0
37 %cst:_(s32) = G_CONSTANT i32 0
38 %op:_(s32) = G_ADD %x(s32), %cst
40 RET_ReallyLR implicit $w0
45 tracksRegLiveness: true
51 ; CHECK-LABEL: name: mul_0
53 ; CHECK: %cst:_(s32) = G_CONSTANT i32 0
54 ; CHECK: $w0 = COPY %cst(s32)
55 ; CHECK: RET_ReallyLR implicit $w0
57 %cst:_(s32) = G_CONSTANT i32 0
58 %op:_(s32) = G_MUL %x(s32), %cst
60 RET_ReallyLR implicit $w0
64 # FIXME: Probably should be able to replace this.
66 name: mul_0_cant_replace
67 tracksRegLiveness: true
73 ; CHECK-LABEL: name: mul_0_cant_replace
75 ; CHECK: %x:_(s32) = COPY $w0
76 ; CHECK: %cst:_(s32) = G_CONSTANT i32 0
77 ; CHECK: %op:gpr(s32) = G_MUL %x, %cst
78 ; CHECK: $w0 = COPY %op(s32)
79 ; CHECK: RET_ReallyLR implicit $w0
81 %cst:_(s32) = G_CONSTANT i32 0
82 %op:gpr(s32) = G_MUL %x(s32), %cst
84 RET_ReallyLR implicit $w0
90 tracksRegLiveness: true
96 ; CHECK-LABEL: name: sdiv_0
98 ; CHECK: %cst:_(s32) = G_CONSTANT i32 0
99 ; CHECK: $w0 = COPY %cst(s32)
100 ; CHECK: RET_ReallyLR implicit $w0
102 %cst:_(s32) = G_CONSTANT i32 0
103 %op:_(s32) = G_SDIV %cst, %x
105 RET_ReallyLR implicit $w0
110 tracksRegLiveness: true
116 ; CHECK-LABEL: name: udiv_0
117 ; CHECK: liveins: $w0
118 ; CHECK: %cst:_(s32) = G_CONSTANT i32 0
119 ; CHECK: $w0 = COPY %cst(s32)
120 ; CHECK: RET_ReallyLR implicit $w0
122 %cst:_(s32) = G_CONSTANT i32 0
123 %op:_(s32) = G_UDIV %cst, %x
125 RET_ReallyLR implicit $w0
130 tracksRegLiveness: true
136 ; CHECK-LABEL: name: srem_0
137 ; CHECK: liveins: $w0
138 ; CHECK: %cst:_(s32) = G_CONSTANT i32 0
139 ; CHECK: $w0 = COPY %cst(s32)
140 ; CHECK: RET_ReallyLR implicit $w0
142 %cst:_(s32) = G_CONSTANT i32 0
143 %op:_(s32) = G_SREM %cst, %x
145 RET_ReallyLR implicit $w0
150 tracksRegLiveness: true
156 ; CHECK-LABEL: name: urem_0
157 ; CHECK: liveins: $w0
158 ; CHECK: %cst:_(s32) = G_CONSTANT i32 0
159 ; CHECK: $w0 = COPY %cst(s32)
160 ; CHECK: RET_ReallyLR implicit $w0
162 %cst:_(s32) = G_CONSTANT i32 0
163 %op:_(s32) = G_UREM %cst, %x
165 RET_ReallyLR implicit $w0
171 tracksRegLiveness: true
177 ; CHECK-LABEL: name: right_ident_or
178 ; CHECK: liveins: $w0
179 ; CHECK: %x:_(s32) = COPY $w0
180 ; CHECK: $w0 = COPY %x(s32)
181 ; CHECK: RET_ReallyLR implicit $w0
183 %cst:_(s32) = G_CONSTANT i32 0
184 %op:_(s32) = G_OR %x(s32), %cst
186 RET_ReallyLR implicit $w0
190 name: right_ident_xor
191 tracksRegLiveness: true
197 ; CHECK-LABEL: name: right_ident_xor
198 ; CHECK: liveins: $w0
199 ; CHECK: %x:_(s32) = COPY $w0
200 ; CHECK: $w0 = COPY %x(s32)
201 ; CHECK: RET_ReallyLR implicit $w0
203 %cst:_(s32) = G_CONSTANT i32 0
204 %op:_(s32) = G_XOR %x(s32), %cst
206 RET_ReallyLR implicit $w0
210 name: right_ident_shl
211 tracksRegLiveness: true
217 ; CHECK-LABEL: name: right_ident_shl
218 ; CHECK: liveins: $w0
219 ; CHECK: %x:_(s32) = COPY $w0
220 ; CHECK: $w0 = COPY %x(s32)
221 ; CHECK: RET_ReallyLR implicit $w0
223 %cst:_(s32) = G_CONSTANT i32 0
224 %op:_(s32) = G_SHL %x(s32), %cst
226 RET_ReallyLR implicit $w0
230 name: right_ident_ashr
231 tracksRegLiveness: true
235 ; Fold (x ashr 0) -> x
237 ; CHECK-LABEL: name: right_ident_ashr
238 ; CHECK: liveins: $w0
239 ; CHECK: %x:_(s32) = COPY $w0
240 ; CHECK: $w0 = COPY %x(s32)
241 ; CHECK: RET_ReallyLR implicit $w0
243 %cst:_(s32) = G_CONSTANT i32 0
244 %op:_(s32) = G_ASHR %x(s32), %cst
246 RET_ReallyLR implicit $w0
250 name: right_ident_lshr
251 tracksRegLiveness: true
255 ; Fold (x lshr 0) -> x
257 ; CHECK-LABEL: name: right_ident_lshr
258 ; CHECK: liveins: $w0
259 ; CHECK: %x:_(s32) = COPY $w0
260 ; CHECK: $w0 = COPY %x(s32)
261 ; CHECK: RET_ReallyLR implicit $w0
263 %cst:_(s32) = G_CONSTANT i32 0
264 %op:_(s32) = G_LSHR %x(s32), %cst
266 RET_ReallyLR implicit $w0
271 tracksRegLiveness: true
275 ; Not an identity, no folding.
277 ; CHECK-LABEL: name: dont_fold_sub
278 ; CHECK: liveins: $w0
279 ; CHECK: %x:_(s32) = COPY $w0
280 ; CHECK: %cst:_(s32) = G_CONSTANT i32 1
281 ; CHECK: %op:_(s32) = G_SUB %x, %cst
282 ; CHECK: $w0 = COPY %op(s32)
283 ; CHECK: RET_ReallyLR implicit $w0
285 %cst:_(s32) = G_CONSTANT i32 1
286 %op:_(s32) = G_SUB %x(s32), %cst
288 RET_ReallyLR implicit $w0
292 name: look_through_zext
293 tracksRegLiveness: true
297 ; CHECK-LABEL: name: look_through_zext
298 ; CHECK: liveins: $x0
299 ; CHECK: %zero:_(s8) = G_CONSTANT i8 0
300 ; CHECK: %zext_zero:_(s64) = G_ZEXT %zero(s8)
301 ; CHECK: $x0 = COPY %zext_zero(s64)
302 ; CHECK: RET_ReallyLR implicit $x0
303 %zero:_(s8) = G_CONSTANT i8 0
304 %zext_zero:_(s64) = G_ZEXT %zero(s8)
305 %c:_(s64) = G_CONSTANT i64 72340172838076673
306 %mul:_(s64) = G_MUL %c, %zext_zero
308 RET_ReallyLR implicit $x0
311 name: right_ident_ptr_add
312 tracksRegLiveness: true
318 ; CHECK-LABEL: name: right_ident_ptr_add
319 ; CHECK: liveins: $x0
320 ; CHECK: %x:_(p0) = COPY $x0
321 ; CHECK: $x0 = COPY %x(p0)
322 ; CHECK: RET_ReallyLR implicit $x0
324 %cst:_(s64) = G_CONSTANT i64 0
325 %op:_(p0) = G_PTR_ADD %x(p0), %cst
327 RET_ReallyLR implicit $x0