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 3 4# Test the localizer. 5 6--- | 7 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" 8 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 } 18... 19 20--- 21name: local_use 22legalized: true 23regBankSelected: true 24body: | 25 bb.0: 26 ; CHECK-LABEL: name: local_use 27 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 28 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]] 29 %0:gpr(s32) = G_CONSTANT 1 30 %1:gpr(s32) = G_ADD %0, %0 31... 32 33--- 34name: non_local_1use 35legalized: true 36regBankSelected: true 37body: | 38 ; CHECK-LABEL: name: non_local_1use 39 ; CHECK: bb.0: 40 ; CHECK: successors: %bb.1(0x80000000) 41 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 42 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]] 43 ; CHECK: bb.1: 44 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 45 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[C1]], [[ADD]] 46 47 ; Existing registers should be left untouched 48 ; The newly created reg should be on the same regbank/regclass as its origin. 49 50 bb.0: 51 successors: %bb.1 52 53 %0:gpr(s32) = G_CONSTANT 1 54 %1:gpr(s32) = G_ADD %0, %0 55 56 bb.1: 57 %2:gpr(s32) = G_ADD %0, %1 58... 59 60--- 61name: non_local_2uses 62legalized: true 63regBankSelected: true 64body: | 65 ; CHECK-LABEL: name: non_local_2uses 66 ; CHECK: bb.0: 67 ; CHECK: successors: %bb.1(0x80000000) 68 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 69 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]] 70 ; CHECK: bb.1: 71 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 72 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[C1]], [[C1]] 73 74 ; Existing registers should be left untouched 75 ; The newly created reg should be on the same regbank/regclass as its origin. 76 77 bb.0: 78 successors: %bb.1 79 80 %0:gpr(s32) = G_CONSTANT 1 81 %1:gpr(s32) = G_ADD %0, %0 82 83 bb.1: 84 %2:gpr(s32) = G_ADD %0, %0 85... 86 87--- 88name: non_local_phi_use 89legalized: true 90regBankSelected: true 91tracksRegLiveness: true 92body: | 93 ; CHECK-LABEL: name: non_local_phi_use 94 ; CHECK: bb.0: 95 ; CHECK: successors: %bb.1(0x80000000) 96 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 97 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]] 98 ; CHECK: bb.1: 99 ; CHECK: successors: %bb.2(0x80000000) 100 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 101 ; CHECK: bb.2: 102 ; CHECK: [[PHI:%[0-9]+]]:gpr(s32) = PHI [[C1]](s32), %bb.1 103 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[PHI]], [[PHI]] 104 105 ; Existing registers should be left untouched 106 ; The newly created reg should be on the same regbank/regclass as its origin. 107 108 bb.0: 109 successors: %bb.1 110 111 %0:gpr(s32) = G_CONSTANT 1 112 %1:gpr(s32) = G_ADD %0, %0 113 114 bb.1: 115 successors: %bb.2 116 117 bb.2: 118 %3:gpr(s32) = PHI %0(s32), %bb.1 119 %2:gpr(s32) = G_ADD %3, %3 120... 121 122--- 123name: non_local_phi_use_followed_by_use 124legalized: true 125regBankSelected: true 126tracksRegLiveness: true 127body: | 128 ; CHECK-LABEL: name: non_local_phi_use_followed_by_use 129 ; CHECK: bb.0: 130 ; CHECK: successors: %bb.1(0x80000000) 131 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 132 ; CHECK: [[ADD:%[0-9]+]]:gpr(s32) = G_ADD [[C]], [[C]] 133 ; CHECK: bb.1: 134 ; CHECK: successors: %bb.2(0x80000000) 135 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 136 ; CHECK: bb.2: 137 ; CHECK: [[PHI:%[0-9]+]]:gpr(s32) = PHI [[C1]](s32), %bb.1 138 ; CHECK: [[C2:%[0-9]+]]:gpr(s32) = G_CONSTANT 1 139 ; CHECK: [[ADD1:%[0-9]+]]:gpr(s32) = G_ADD [[PHI]], [[C2]] 140 141 ; Existing registers should be left untouched 142 ; The newly created reg should be on the same regbank/regclass as its origin. 143 144 bb.0: 145 successors: %bb.1 146 147 %0:gpr(s32) = G_CONSTANT 1 148 %1:gpr(s32) = G_ADD %0, %0 149 150 bb.1: 151 successors: %bb.2 152 153 bb.2: 154 %3:gpr(s32) = PHI %0(s32), %bb.1 155 %2:gpr(s32) = G_ADD %3, %0 156... 157 158--- 159name: non_local_phi_use_followed_by_use_fi 160legalized: true 161regBankSelected: true 162tracksRegLiveness: true 163body: | 164 ; CHECK-LABEL: name: non_local_phi_use_followed_by_use_fi 165 ; CHECK: bb.0: 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]] 169 ; CHECK: bb.1: 170 ; CHECK: successors: %bb.2(0x80000000) 171 ; CHECK: [[FRAME_INDEX1:%[0-9]+]]:gpr(s32) = G_FRAME_INDEX 1 172 ; CHECK: bb.2: 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]] 176 177 ; Existing registers should be left untouched 178 ; The newly created reg should be on the same regbank/regclass as its origin. 179 180 bb.0: 181 successors: %bb.1 182 183 %0:gpr(s32) = G_FRAME_INDEX 1 184 %1:gpr(s32) = G_ADD %0, %0 185 186 bb.1: 187 successors: %bb.2 188 189 bb.2: 190 %3:gpr(s32) = PHI %0(s32), %bb.1 191 %2:gpr(s32) = G_ADD %3, %0 192... 193 194--- 195name: float_non_local_phi_use_followed_by_use_fi 196legalized: true 197regBankSelected: true 198tracksRegLiveness: true 199body: | 200 ; CHECK-LABEL: name: float_non_local_phi_use_followed_by_use_fi 201 ; CHECK: bb.0: 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]] 205 ; CHECK: bb.1: 206 ; CHECK: successors: %bb.2(0x80000000) 207 ; CHECK: [[C1:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00 208 ; CHECK: bb.2: 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]] 212 213 ; Existing registers should be left untouched 214 ; The newly created reg should be on the same regbank/regclass as its origin. 215 216 bb.0: 217 successors: %bb.1 218 219 %0:fpr(s32) = G_FCONSTANT float 1.0 220 %1:fpr(s32) = G_FADD %0, %0 221 222 bb.1: 223 successors: %bb.2 224 225 bb.2: 226 %3:fpr(s32) = PHI %0(s32), %bb.1 227 %2:fpr(s32) = G_FADD %3, %0 228... 229 230--- 231# Make sure we don't insert a constant before PHIs. 232# This used to happen for loops of one basic block. 233name: non_local_phi 234legalized: true 235regBankSelected: true 236tracksRegLiveness: true 237body: | 238 ; CHECK-LABEL: name: non_local_phi 239 ; CHECK: bb.0: 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]] 243 ; CHECK: bb.1: 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]] 248 ; CHECK: G_BR %bb.1 249 250 ; Existing registers should be left untouched 251 ; The newly created reg should be on the same regbank/regclass as its origin. 252 253 bb.0: 254 successors: %bb.1 255 256 %0:fpr(s32) = G_FCONSTANT float 1.0 257 %1:fpr(s32) = G_FADD %0, %0 258 259 bb.1: 260 successors: %bb.1 261 262 %3:fpr(s32) = PHI %1(s32), %bb.0, %0(s32), %bb.1 263 %2:fpr(s32) = G_FADD %3, %1 264 G_BR %bb.1 265... 266 267--- 268# Make sure we don't insert a constant before EH_LABELs. 269name: non_local_label 270legalized: true 271regBankSelected: true 272tracksRegLiveness: true 273body: | 274 ; CHECK-LABEL: name: non_local_label 275 ; CHECK: bb.0: 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 280 ; CHECK: bb.1: 281 ; CHECK: successors: %bb.1(0x80000000) 282 ; CHECK: EH_LABEL 1 283 ; CHECK: [[C1:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00 284 ; CHECK: [[FADD:%[0-9]+]]:fpr(s32) = G_FADD [[COPY]], [[C1]] 285 ; CHECK: G_BR %bb.1 286 287 ; Existing registers should be left untouched 288 ; The newly created reg should be on the same regbank/regclass as its origin. 289 290 bb.0: 291 liveins: $s0 292 successors: %bb.1 293 294 %0:fpr(s32) = COPY $s0 295 %1:fpr(s32) = G_FCONSTANT float 1.0 296 297 bb.1: 298 successors: %bb.1 299 300 EH_LABEL 1 301 %2:fpr(s32) = G_FADD %0, %1 302 G_BR %bb.1 303... 304