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
10 ; CHECK-LABEL: name: ptr_add
13 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
14 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64common = COPY [[COPY]]
15 ; CHECK-NEXT: [[ADDXri:%[0-9]+]]:gpr64sp = ADDXri [[COPY1]], 42, 0
16 ; CHECK-NEXT: $x0 = COPY [[ADDXri]]
18 %1:gpr(s64) = G_CONSTANT i64 42
19 %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
24 name: ptr_add_no_constant
30 ; CHECK-LABEL: name: ptr_add_no_constant
31 ; CHECK: liveins: $x0, $x1
33 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
34 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1
35 ; CHECK-NEXT: [[ADDXrr:%[0-9]+]]:gpr64 = ADDXrr [[COPY]], [[COPY1]]
36 ; CHECK-NEXT: $x0 = COPY [[ADDXrr]]
38 %1:gpr(s64) = COPY $x1
39 %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
50 ; CHECK-LABEL: name: ptr_add_bad_imm
51 ; CHECK: liveins: $x0, $x1
53 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
54 ; CHECK-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 10000
55 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[MOVi32imm]], %subreg.sub_32
56 ; CHECK-NEXT: [[ADDXrr:%[0-9]+]]:gpr64 = ADDXrr [[COPY]], [[SUBREG_TO_REG]]
57 ; CHECK-NEXT: $x0 = COPY [[ADDXrr]]
59 %1:gpr(s64) = G_CONSTANT i64 10000
60 %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
71 ; CHECK-LABEL: name: ptr_add_vec
72 ; CHECK: liveins: $q0, $q1
74 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr128 = COPY $q0
75 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr128 = COPY $q1
76 ; CHECK-NEXT: [[ADDv2i64_:%[0-9]+]]:fpr128 = ADDv2i64 [[COPY]], [[COPY1]]
77 ; CHECK-NEXT: $q0 = COPY [[ADDv2i64_]]
78 %0:fpr(<2 x p0>) = COPY $q0
79 %1:fpr(<2 x s64>) = COPY $q1
80 %3:fpr(<2 x p0>) = G_PTR_ADD %0, %1(<2 x s64>)
81 $q0 = COPY %3(<2 x p0>)
90 ; CHECK-LABEL: name: ptr_add_neg_imm
93 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
94 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64common = COPY [[COPY]]
95 ; CHECK-NEXT: [[SUBSXri:%[0-9]+]]:gpr64 = SUBSXri [[COPY1]], 10, 0, implicit-def dead $nzcv
96 ; CHECK-NEXT: $x0 = COPY [[SUBSXri]]
98 %1:gpr(s64) = G_CONSTANT i64 -10
99 %2:gpr(p0) = G_PTR_ADD %0, %1(s64)
103 name: ptr_add_arith_extended
105 regBankSelected: true
109 ; CHECK-LABEL: name: ptr_add_arith_extended
110 ; CHECK: liveins: $x0
112 ; CHECK-NEXT: %reg0:gpr32 = COPY $w0
113 ; CHECK-NEXT: %ptr:gpr64 = COPY $x1
114 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64common = COPY %ptr
115 ; CHECK-NEXT: %ptr_add:gpr64sp = ADDXrx [[COPY]], %reg0, 18
116 ; CHECK-NEXT: $x0 = COPY %ptr_add
117 %reg0:gpr(s32) = COPY $w0
118 %ptr:gpr(p0) = COPY $x1
119 %ext:gpr(s64) = G_ZEXT %reg0(s32)
120 %cst:gpr(s64) = G_CONSTANT i64 2
121 %shift:gpr(s64) = G_SHL %ext, %cst(s64)
122 %ptr_add:gpr(p0) = G_PTR_ADD %ptr, %shift(s64)
123 $x0 = COPY %ptr_add(p0)
126 name: ptr_add_negated_reg
128 regBankSelected: true
132 ; CHECK-LABEL: name: ptr_add_negated_reg
133 ; CHECK: liveins: $x0, $x1
135 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
136 ; CHECK-NEXT: %src:gpr64 = COPY $x1
137 ; CHECK-NEXT: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr [[COPY]], %src, implicit-def dead $nzcv
138 ; CHECK-NEXT: $x0 = COPY [[SUBSXrr]]
139 %0:gpr(p0) = COPY $x0
140 %src:gpr(s64) = COPY $x1
141 %1:gpr(s64) = G_CONSTANT i64 0
142 %neg:gpr(s64) = G_SUB %1, %src
143 %2:gpr(p0) = G_PTR_ADD %0, %neg(s64)