1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -O0 -mtriple=aarch64-apple-ios -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK
3---
4name:            ptr_add
5legalized:       true
6regBankSelected: true
7body:             |
8  bb.0:
9      liveins: $x0
10    ; CHECK-LABEL: name: ptr_add
11    ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
12    ; CHECK: [[COPY1:%[0-9]+]]:gpr64common = COPY [[COPY]]
13    ; CHECK: [[ADDXri:%[0-9]+]]:gpr64sp = ADDXri [[COPY1]], 42, 0
14    ; CHECK: $x0 = COPY [[ADDXri]]
15    %0:gpr(p0) = COPY $x0
16    %1:gpr(s64) = G_CONSTANT i64 42
17    %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
18    $x0 = COPY %2(p0)
19...
20
21---
22name:            ptr_add_no_constant
23legalized:       true
24regBankSelected: true
25body:             |
26  bb.0:
27      liveins: $x0, $x1
28    ; CHECK-LABEL: name: ptr_add_no_constant
29    ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
30    ; CHECK: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1
31    ; CHECK: [[ADDXrr:%[0-9]+]]:gpr64 = ADDXrr [[COPY]], [[COPY1]]
32    ; CHECK: $x0 = COPY [[ADDXrr]]
33    %0:gpr(p0) = COPY $x0
34    %1:gpr(s64) = COPY $x1
35    %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
36    $x0 = COPY %2(p0)
37...
38
39---
40name:            ptr_add_bad_imm
41legalized:       true
42regBankSelected: true
43body:             |
44  bb.0:
45      liveins: $x0, $x1
46    ; CHECK-LABEL: name: ptr_add_bad_imm
47    ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
48    ; CHECK: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 10000
49    ; CHECK: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[MOVi32imm]], %subreg.sub_32
50    ; CHECK: [[ADDXrr:%[0-9]+]]:gpr64 = ADDXrr [[COPY]], [[SUBREG_TO_REG]]
51    ; CHECK: $x0 = COPY [[ADDXrr]]
52    %0:gpr(p0) = COPY $x0
53    %1:gpr(s64) = G_CONSTANT i64 10000
54    %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
55    $x0 = COPY %2(p0)
56...
57
58---
59name:            ptr_add_vec
60legalized:       true
61regBankSelected: true
62body:             |
63  bb.0:
64      liveins: $q0, $q1
65    ; CHECK-LABEL: name: ptr_add_vec
66    ; CHECK: [[COPY:%[0-9]+]]:fpr128 = COPY $q0
67    ; CHECK: [[COPY1:%[0-9]+]]:fpr128 = COPY $q1
68    ; CHECK: [[ADDv2i64_:%[0-9]+]]:fpr128 = ADDv2i64 [[COPY]], [[COPY1]]
69    ; CHECK: $q0 = COPY [[ADDv2i64_]]
70    %0:fpr(<2 x p0>) = COPY $q0
71    %1:fpr(<2 x s64>) = COPY $q1
72    %3:fpr(<2 x p0>) = G_PTR_ADD %0, %1(<2 x s64>)
73    $q0 = COPY %3(<2 x p0>)
74...
75---
76name:            ptr_add_neg_imm
77legalized:       true
78regBankSelected: true
79body:             |
80  bb.0:
81      liveins: $x0
82    ; CHECK-LABEL: name: ptr_add_neg_imm
83    ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
84    ; CHECK: [[COPY1:%[0-9]+]]:gpr64common = COPY [[COPY]]
85    ; CHECK: [[SUBSXri:%[0-9]+]]:gpr64 = SUBSXri [[COPY1]], 10, 0, implicit-def $nzcv
86    ; CHECK: $x0 = COPY [[SUBSXri]]
87    %0:gpr(p0) = COPY $x0
88    %1:gpr(s64) = G_CONSTANT i64 -10
89    %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
90    $x0 = COPY %2(p0)
91...
92---
93name:            ptr_add_arith_extended
94legalized:       true
95regBankSelected: true
96body:             |
97  bb.0:
98      liveins: $x0
99    ; CHECK-LABEL: name: ptr_add_arith_extended
100    ; CHECK: %reg0:gpr32 = COPY $w0
101    ; CHECK: %ptr:gpr64 = COPY $x1
102    ; CHECK: [[COPY:%[0-9]+]]:gpr64common = COPY %ptr
103    ; CHECK: %ptr_add:gpr64sp = ADDXrx [[COPY]], %reg0, 18
104    ; CHECK: $x0 = COPY %ptr_add
105    %reg0:gpr(s32) = COPY $w0
106    %ptr:gpr(p0) = COPY $x1
107    %ext:gpr(s64) = G_ZEXT %reg0(s32)
108    %cst:gpr(s64) = G_CONSTANT i64 2
109    %shift:gpr(s64) = G_SHL %ext, %cst(s64)
110    %ptr_add:gpr(p0) = G_PTR_ADD %ptr, %shift(s64)
111    $x0 = COPY %ptr_add(p0)
112...
113---
114name:            ptr_add_negated_reg
115legalized:       true
116regBankSelected: true
117body:             |
118  bb.0:
119      liveins: $x0, $x1
120    ; CHECK-LABEL: name: ptr_add_negated_reg
121    ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
122    ; CHECK: %src:gpr64 = COPY $x1
123    ; CHECK: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr [[COPY]], %src, implicit-def $nzcv
124    ; CHECK: $x0 = COPY [[SUBSXrr]]
125    %0:gpr(p0) = COPY $x0
126    %src:gpr(s64) = COPY $x1
127    %1:gpr(s64) = G_CONSTANT i64 0
128    %neg:gpr(s64) = G_SUB %1, %src
129    %2:gpr(p0) = G_PTR_ADD %0, %neg(s64)
130    $x0 = COPY %2(p0)
131...
132