1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=aarch64-apple-ios -run-pass=localizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK
7 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
9 define void @local_use() { ret void }
10 define void @non_local_1use() { ret void }
11 define void @non_local_2uses() { ret void }
12 define void @non_local_phi_use() { ret void }
13 define void @non_local_phi_use_followed_by_use() { ret void }
14 define void @non_local_phi_use_followed_by_use_fi() { ret void }
15 define void @float_non_local_phi_use_followed_by_use_fi() { ret void }
16 define void @non_local_phi() { ret void }
17 define void @non_local_label() { ret void }
26 ; CHECK-LABEL: name: local_use
27 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
28 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]]
29 %0:gpr(s32) = G_CONSTANT i32 1
30 %1:gpr(s32) = G_ADD %0, %0
38 ; CHECK-LABEL: name: non_local_1use
40 ; CHECK: successors: %bb.1(0x80000000)
41 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
42 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]]
44 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
45 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[C1]], [[ADD]]
47 ; Existing registers should be left untouched
48 ; The newly created reg should be on the same regbank/regclass as its origin.
53 %0:gpr(s32) = G_CONSTANT i32 1
54 %1:gpr(s32) = G_ADD %0, %0
57 %2:gpr(s32) = G_ADD %0, %1
65 ; CHECK-LABEL: name: non_local_2uses
67 ; CHECK: successors: %bb.1(0x80000000)
68 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
69 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]]
71 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
72 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[C1]], [[C1]]
74 ; Existing registers should be left untouched
75 ; The newly created reg should be on the same regbank/regclass as its origin.
80 %0:gpr(s32) = G_CONSTANT i32 1
81 %1:gpr(s32) = G_ADD %0, %0
84 %2:gpr(s32) = G_ADD %0, %0
88 name: non_local_phi_use
91 tracksRegLiveness: true
93 ; CHECK-LABEL: name: non_local_phi_use
95 ; CHECK: successors: %bb.1(0x80000000)
96 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
97 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]]
99 ; CHECK: successors: %bb.2(0x80000000)
100 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
102 ; CHECK: [[PHI:%[0-9]+]]:gpr(s32) = PHI [[C1]](s32), %bb.1
103 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[PHI]], [[PHI]]
105 ; Existing registers should be left untouched
106 ; The newly created reg should be on the same regbank/regclass as its origin.
111 %0:gpr(s32) = G_CONSTANT i32 1
112 %1:gpr(s32) = G_ADD %0, %0
118 %3:gpr(s32) = PHI %0(s32), %bb.1
119 %2:gpr(s32) = G_ADD %3, %3
123 name: non_local_phi_use_followed_by_use
125 regBankSelected: true
126 tracksRegLiveness: true
128 ; CHECK-LABEL: name: non_local_phi_use_followed_by_use
130 ; CHECK: successors: %bb.1(0x80000000)
131 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
132 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]]
134 ; CHECK: successors: %bb.2(0x80000000)
135 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
137 ; CHECK: [[PHI:%[0-9]+]]:gpr(s32) = PHI [[C1]](s32), %bb.1
138 ; CHECK: [[C2:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
139 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[PHI]], [[C2]]
141 ; Existing registers should be left untouched
142 ; The newly created reg should be on the same regbank/regclass as its origin.
147 %0:gpr(s32) = G_CONSTANT i32 1
148 %1:gpr(s32) = G_ADD %0, %0
154 %3:gpr(s32) = PHI %0(s32), %bb.1
155 %2:gpr(s32) = G_ADD %3, %0
159 name: non_local_phi_use_followed_by_use_fi
161 regBankSelected: true
162 tracksRegLiveness: true
164 ; CHECK-LABEL: name: non_local_phi_use_followed_by_use_fi
166 ; CHECK: successors: %bb.1(0x80000000)
167 ; CHECK: [[FRAME_INDEX:%[0-9]+]]:gpr(s32) = G_FRAME_INDEX 1
168 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[FRAME_INDEX]], [[FRAME_INDEX]]
170 ; CHECK: successors: %bb.2(0x80000000)
171 ; CHECK: [[FRAME_INDEX1:%[0-9]+]]:gpr(s32) = G_FRAME_INDEX 1
173 ; CHECK: [[PHI:%[0-9]+]]:gpr(s32) = PHI [[FRAME_INDEX1]](s32), %bb.1
174 ; CHECK: [[FRAME_INDEX2:%[0-9]+]]:gpr(s32) = G_FRAME_INDEX 1
175 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[PHI]], [[FRAME_INDEX2]]
177 ; Existing registers should be left untouched
178 ; The newly created reg should be on the same regbank/regclass as its origin.
183 %0:gpr(s32) = G_FRAME_INDEX 1
184 %1:gpr(s32) = G_ADD %0, %0
190 %3:gpr(s32) = PHI %0(s32), %bb.1
191 %2:gpr(s32) = G_ADD %3, %0
195 name: float_non_local_phi_use_followed_by_use_fi
197 regBankSelected: true
198 tracksRegLiveness: true
200 ; CHECK-LABEL: name: float_non_local_phi_use_followed_by_use_fi
202 ; CHECK: successors: %bb.1(0x80000000)
203 ; CHECK: [[C:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
204 ; CHECK: [[FADD:%[0-9]+]]:fpr(s32) = G_FADD [[C]], [[C]]
206 ; CHECK: successors: %bb.2(0x80000000)
207 ; CHECK: [[C1:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
209 ; CHECK: [[PHI:%[0-9]+]]:fpr(s32) = PHI [[C1]](s32), %bb.1
210 ; CHECK: [[C2:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
211 ; CHECK: [[FADD1:%[0-9]+]]:fpr(s32) = G_FADD [[PHI]], [[C2]]
213 ; Existing registers should be left untouched
214 ; The newly created reg should be on the same regbank/regclass as its origin.
219 %0:fpr(s32) = G_FCONSTANT float 1.0
220 %1:fpr(s32) = G_FADD %0, %0
226 %3:fpr(s32) = PHI %0(s32), %bb.1
227 %2:fpr(s32) = G_FADD %3, %0
231 # Make sure we don't insert a constant before PHIs.
232 # This used to happen for loops of one basic block.
235 regBankSelected: true
236 tracksRegLiveness: true
238 ; CHECK-LABEL: name: non_local_phi
240 ; CHECK: successors: %bb.1(0x80000000)
241 ; CHECK: [[C:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
242 ; CHECK: [[FADD:%[0-9]+]]:fpr(s32) = G_FADD [[C]], [[C]]
244 ; CHECK: successors: %bb.1(0x80000000)
245 ; CHECK: [[PHI:%[0-9]+]]:fpr(s32) = PHI [[FADD]](s32), %bb.0, %4(s32), %bb.1
246 ; CHECK: [[C1:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
247 ; CHECK: [[FADD1:%[0-9]+]]:fpr(s32) = G_FADD [[PHI]], [[FADD]]
250 ; Existing registers should be left untouched
251 ; The newly created reg should be on the same regbank/regclass as its origin.
256 %0:fpr(s32) = G_FCONSTANT float 1.0
257 %1:fpr(s32) = G_FADD %0, %0
262 %3:fpr(s32) = PHI %1(s32), %bb.0, %0(s32), %bb.1
263 %2:fpr(s32) = G_FADD %3, %1
268 # Make sure we don't insert a constant before EH_LABELs.
269 name: non_local_label
271 regBankSelected: true
272 tracksRegLiveness: true
274 ; CHECK-LABEL: name: non_local_label
276 ; CHECK: successors: %bb.1(0x80000000)
277 ; CHECK: liveins: $s0
278 ; CHECK: [[COPY:%[0-9]+]]:fpr(s32) = COPY $s0
279 ; CHECK: [[C:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
281 ; CHECK: successors: %bb.1(0x80000000)
283 ; CHECK: [[C1:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
284 ; CHECK: [[FADD:%[0-9]+]]:fpr(s32) = G_FADD [[COPY]], [[C1]]
287 ; Existing registers should be left untouched
288 ; The newly created reg should be on the same regbank/regclass as its origin.
294 %0:fpr(s32) = COPY $s0
295 %1:fpr(s32) = G_FCONSTANT float 1.0
301 %2:fpr(s32) = G_FADD %0, %1