1; RUN: llc -mtriple=thumbv8.1m.main -O0 -mattr=+lob -disable-arm-loloops=false -stop-before=arm-low-overhead-loops %s -o - | FileCheck %s --check-prefix=CHECK-MID 2; RUN: llc -mtriple=thumbv8.1m.main -O0 -mattr=+lob -disable-arm-loloops=false -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK-END 3 4; Test that the branch targets are correct after isel, even though the loop 5; will sometimes be reverted anyway. 6 7; CHECK-MID: name: check_loop_dec_brcond_combine 8; CHECK-MID: bb.2.for.body: 9; CHECK-MID: renamable $lr = t2LoopDec killed renamable $lr, 1 10; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 11; CHECK-MID: bb.3.for.header: 12; CHECK-MID: tB %bb.2 13 14; CHECK-END: .LBB0_1: 15; CHECK-END: b .LBB0_3 16; CHECK-END: .LBB0_2: 17; CHECK-END: subs.w lr, lr, #1 18; CHECK-END: bne .LBB0_3 19; CHECK-END: b .LBB0_4 20; CHECK-END: .LBB0_3: 21; CHECK-END: b .LBB0_2 22define void @check_loop_dec_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 23entry: 24 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 25 br label %for.body.preheader 26 27for.body.preheader: 28 %scevgep = getelementptr i32, i32* %a, i32 -1 29 %scevgep4 = getelementptr i32, i32* %c, i32 -1 30 %scevgep8 = getelementptr i32, i32* %b, i32 -1 31 br label %for.header 32 33for.body: 34 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 35 %ld1 = load i32, i32* %scevgep11, align 4 36 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 37 %ld2 = load i32, i32* %scevgep7, align 4 38 %mul = mul nsw i32 %ld2, %ld1 39 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 40 store i32 %mul, i32* %scevgep3, align 4 41 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 42 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 43 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 44 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 45 %cmp = icmp ne i32 %count.next, 0 46 br i1 %cmp, label %for.header, label %for.cond.cleanup 47 48for.header: 49 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 50 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 51 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 52 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 53 br label %for.body 54 55for.cond.cleanup: 56 ret void 57} 58 59; CHECK-MID: name: check_loop_dec_ugt_brcond_combine 60; CHECK-MID: bb.2.for.body: 61; CHECK-MID: renamable $lr = t2LoopDec killed renamable $lr, 1 62; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 63; CHECK-MID: bb.3.for.header: 64; CHECK-MID: tB %bb.2 65define void @check_loop_dec_ugt_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 66entry: 67 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 68 br label %for.body.preheader 69 70for.body.preheader: 71 %scevgep = getelementptr i32, i32* %a, i32 -1 72 %scevgep4 = getelementptr i32, i32* %c, i32 -1 73 %scevgep8 = getelementptr i32, i32* %b, i32 -1 74 br label %for.header 75 76for.body: 77 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 78 %ld1 = load i32, i32* %scevgep11, align 4 79 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 80 %ld2 = load i32, i32* %scevgep7, align 4 81 %mul = mul nsw i32 %ld2, %ld1 82 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 83 store i32 %mul, i32* %scevgep3, align 4 84 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 85 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 86 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 87 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 88 %cmp = icmp ugt i32 %count.next, 0 89 br i1 %cmp, label %for.header, label %for.cond.cleanup 90 91for.header: 92 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 93 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 94 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 95 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 96 br label %for.body 97 98for.cond.cleanup: 99 ret void 100} 101 102; CHECK-MID: name: check_loop_dec_ult_brcond_combine 103; CHECK-MID: bb.2.for.body: 104; CHECK-MID: renamable $lr = t2LoopDec killed renamable $lr, 1 105; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 106; CHECK-MID: bb.3.for.header: 107; CHECK-MID: tB %bb.2 108define void @check_loop_dec_ult_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 109entry: 110 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 111 br label %for.body.preheader 112 113for.body.preheader: 114 %scevgep = getelementptr i32, i32* %a, i32 -1 115 %scevgep4 = getelementptr i32, i32* %c, i32 -1 116 %scevgep8 = getelementptr i32, i32* %b, i32 -1 117 br label %for.header 118 119for.body: 120 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 121 %ld1 = load i32, i32* %scevgep11, align 4 122 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 123 %ld2 = load i32, i32* %scevgep7, align 4 124 %mul = mul nsw i32 %ld2, %ld1 125 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 126 store i32 %mul, i32* %scevgep3, align 4 127 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 128 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 129 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 130 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 131 %cmp = icmp ult i32 %count.next, 1 132 br i1 %cmp, label %for.cond.cleanup, label %for.header 133 134for.header: 135 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 136 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 137 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 138 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 139 br label %for.body 140 141for.cond.cleanup: 142 ret void 143} 144 145; CHECK-MID: name: check_loop_dec_ult_xor_brcond_combine 146; CHECK-MIO: bb.2.for.body: 147; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 148; CHECK-MID: tB %bb.4, 14 149; CHECk-MID: bb.3.for.header: 150; CHECK-MID: tB %bb.2 151define void @check_loop_dec_ult_xor_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 152entry: 153 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 154 br label %for.body.preheader 155 156for.body.preheader: 157 %scevgep = getelementptr i32, i32* %a, i32 -1 158 %scevgep4 = getelementptr i32, i32* %c, i32 -1 159 %scevgep8 = getelementptr i32, i32* %b, i32 -1 160 br label %for.header 161 162for.body: 163 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 164 %ld1 = load i32, i32* %scevgep11, align 4 165 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 166 %ld2 = load i32, i32* %scevgep7, align 4 167 %mul = mul nsw i32 %ld2, %ld1 168 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 169 store i32 %mul, i32* %scevgep3, align 4 170 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 171 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 172 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 173 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 174 %cmp = icmp ult i32 %count.next, 1 175 %negate = xor i1 %cmp, 1 176 br i1 %negate, label %for.header, label %for.cond.cleanup 177 178for.header: 179 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 180 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 181 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 182 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 183 br label %for.body 184 185for.cond.cleanup: 186 ret void 187} 188 189; CHECK-MID: name: check_loop_dec_sgt_brcond_combine 190; CHECK-MIO: bb.2.for.body: 191; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 192; CHECK-MID: tB %bb.4, 14 193; CHECk-MID: bb.3.for.header: 194; CHECK-MID: tB %bb.2 195define void @check_loop_dec_sgt_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 196entry: 197 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 198 br label %for.body.preheader 199 200for.body.preheader: 201 %scevgep = getelementptr i32, i32* %a, i32 -1 202 %scevgep4 = getelementptr i32, i32* %c, i32 -1 203 %scevgep8 = getelementptr i32, i32* %b, i32 -1 204 br label %for.header 205 206for.body: 207 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 208 %ld1 = load i32, i32* %scevgep11, align 4 209 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 210 %ld2 = load i32, i32* %scevgep7, align 4 211 %mul = mul nsw i32 %ld2, %ld1 212 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 213 store i32 %mul, i32* %scevgep3, align 4 214 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 215 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 216 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 217 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 218 %cmp = icmp sgt i32 %count.next, 0 219 br i1 %cmp, label %for.header, label %for.cond.cleanup 220 221for.header: 222 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 223 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 224 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 225 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 226 br label %for.body 227 228for.cond.cleanup: 229 ret void 230} 231 232; CHECK-MID: name: check_loop_dec_sge_brcond_combine 233; CHECK-MIO: bb.2.for.body: 234; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 235; CHECK-MID: tB %bb.4, 14 236; CHECk-MID: bb.3.for.header: 237; CHECK-MID: tB %bb.2 238define void @check_loop_dec_sge_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 239entry: 240 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 241 br label %for.body.preheader 242 243for.body.preheader: 244 %scevgep = getelementptr i32, i32* %a, i32 -1 245 %scevgep4 = getelementptr i32, i32* %c, i32 -1 246 %scevgep8 = getelementptr i32, i32* %b, i32 -1 247 br label %for.header 248 249for.body: 250 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 251 %ld1 = load i32, i32* %scevgep11, align 4 252 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 253 %ld2 = load i32, i32* %scevgep7, align 4 254 %mul = mul nsw i32 %ld2, %ld1 255 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 256 store i32 %mul, i32* %scevgep3, align 4 257 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 258 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 259 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 260 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 261 %cmp = icmp sge i32 %count.next, 1 262 br i1 %cmp, label %for.header, label %for.cond.cleanup 263 264for.header: 265 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 266 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 267 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 268 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 269 br label %for.body 270 271for.cond.cleanup: 272 ret void 273} 274 275; CHECK-MID: name: check_loop_dec_sge_xor_brcond_combine 276; CHECK-MIO: bb.2.for.body: 277; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 278; CHECK-MID: tB %bb.4, 14 279; CHECk-MID: bb.3.for.header: 280; CHECK-MID: tB %bb.2 281define void @check_loop_dec_sge_xor_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 282entry: 283 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 284 br label %for.body.preheader 285 286for.body.preheader: 287 %scevgep = getelementptr i32, i32* %a, i32 -1 288 %scevgep4 = getelementptr i32, i32* %c, i32 -1 289 %scevgep8 = getelementptr i32, i32* %b, i32 -1 290 br label %for.header 291 292for.body: 293 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 294 %ld1 = load i32, i32* %scevgep11, align 4 295 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 296 %ld2 = load i32, i32* %scevgep7, align 4 297 %mul = mul nsw i32 %ld2, %ld1 298 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 299 store i32 %mul, i32* %scevgep3, align 4 300 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 301 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 302 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 303 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 304 %cmp = icmp sge i32 %count.next, 1 305 %negated = xor i1 %cmp, 1 306 br i1 %negated, label %for.cond.cleanup, label %for.header 307 308for.header: 309 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 310 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 311 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 312 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 313 br label %for.body 314 315for.cond.cleanup: 316 ret void 317} 318 319; CHECK-MID: name: check_loop_dec_uge_brcond_combine 320; CHECK-MIO: bb.2.for.body: 321; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 322; CHECK-MID: tB %bb.4, 14 323; CHECk-MID: bb.3.for.header: 324; CHECK-MID: tB %bb.2 325define void @check_loop_dec_uge_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 326entry: 327 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 328 br label %for.body.preheader 329 330for.body.preheader: 331 %scevgep = getelementptr i32, i32* %a, i32 -1 332 %scevgep4 = getelementptr i32, i32* %c, i32 -1 333 %scevgep8 = getelementptr i32, i32* %b, i32 -1 334 br label %for.header 335 336for.body: 337 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 338 %ld1 = load i32, i32* %scevgep11, align 4 339 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 340 %ld2 = load i32, i32* %scevgep7, align 4 341 %mul = mul nsw i32 %ld2, %ld1 342 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 343 store i32 %mul, i32* %scevgep3, align 4 344 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 345 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 346 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 347 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 348 %cmp = icmp uge i32 %count.next, 1 349 br i1 %cmp, label %for.header, label %for.cond.cleanup 350 351for.header: 352 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 353 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 354 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 355 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 356 br label %for.body 357 358for.cond.cleanup: 359 ret void 360} 361 362; CHECK-MID: name: check_loop_dec_uge_xor_brcond_combine 363; CHECK-MIO: bb.2.for.body: 364; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.3 365; CHECK-MID: tB %bb.4, 14 366; CHECk-MID: bb.3.for.header: 367; CHECK-MID: tB %bb.2 368define void @check_loop_dec_uge_xor_brcond_combine(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32 %N) { 369entry: 370 %start = call i32 @llvm.start.loop.iterations.i32(i32 %N) 371 br label %for.body.preheader 372 373for.body.preheader: 374 %scevgep = getelementptr i32, i32* %a, i32 -1 375 %scevgep4 = getelementptr i32, i32* %c, i32 -1 376 %scevgep8 = getelementptr i32, i32* %b, i32 -1 377 br label %for.header 378 379for.body: 380 %scevgep11 = getelementptr i32, i32* %lsr.iv9, i32 1 381 %ld1 = load i32, i32* %scevgep11, align 4 382 %scevgep7 = getelementptr i32, i32* %lsr.iv5, i32 1 383 %ld2 = load i32, i32* %scevgep7, align 4 384 %mul = mul nsw i32 %ld2, %ld1 385 %scevgep3 = getelementptr i32, i32* %lsr.iv1, i32 1 386 store i32 %mul, i32* %scevgep3, align 4 387 %scevgep2 = getelementptr i32, i32* %lsr.iv1, i32 1 388 %scevgep6 = getelementptr i32, i32* %lsr.iv5, i32 1 389 %scevgep10 = getelementptr i32, i32* %lsr.iv9, i32 1 390 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 391 %cmp = icmp uge i32 %count.next, 1 392 %negated = xor i1 %cmp, 1 393 br i1 %negated, label %for.cond.cleanup, label %for.header 394 395for.header: 396 %lsr.iv9 = phi i32* [ %scevgep8, %for.body.preheader ], [ %scevgep10, %for.body ] 397 %lsr.iv5 = phi i32* [ %scevgep4, %for.body.preheader ], [ %scevgep6, %for.body ] 398 %lsr.iv1 = phi i32* [ %scevgep, %for.body.preheader ], [ %scevgep2, %for.body ] 399 %count = phi i32 [ %start, %for.body.preheader ], [ %count.next, %for.body ] 400 br label %for.body 401 402for.cond.cleanup: 403 ret void 404} 405 406; CHECK-MID: check_negated_xor_wls 407; CHECK-MID: t2WhileLoopStart renamable $r2, %bb.3 408; CHECK-MID: tB %bb.1 409; CHECK-MID: bb.1.while.body.preheader: 410; CHECK-MID: $lr = t2LoopDec killed renamable $lr, 1 411; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.2 412; CHECk-MID: tB %bb.3 413; CHECK-MID: bb.3.while.end: 414define void @check_negated_xor_wls(i16* nocapture %a, i16* nocapture readonly %b, i32 %N) { 415entry: 416 %wls = call i1 @llvm.test.set.loop.iterations.i32(i32 %N) 417 %xor = xor i1 %wls, 1 418 br i1 %xor, label %while.end, label %while.body.preheader 419 420while.body.preheader: 421 br label %while.body 422 423while.body: 424 %a.addr.06 = phi i16* [ %incdec.ptr1, %while.body ], [ %a, %while.body.preheader ] 425 %b.addr.05 = phi i16* [ %incdec.ptr, %while.body ], [ %b, %while.body.preheader ] 426 %count = phi i32 [ %N, %while.body.preheader ], [ %count.next, %while.body ] 427 %incdec.ptr = getelementptr inbounds i16, i16* %b.addr.05, i32 1 428 %ld.b = load i16, i16* %b.addr.05, align 2 429 %incdec.ptr1 = getelementptr inbounds i16, i16* %a.addr.06, i32 1 430 store i16 %ld.b, i16* %a.addr.06, align 2 431 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 432 %cmp = icmp ne i32 %count.next, 0 433 br i1 %cmp, label %while.body, label %while.end 434 435while.end: 436 ret void 437} 438 439; CHECK-MID: check_negated_cmp_wls 440; CHECK-MID: t2WhileLoopStart renamable $r2, %bb.3 441; CHECK-MID: tB %bb.1 442; CHECK-MID: bb.1.while.body.preheader: 443; CHECK-MID: $lr = t2LoopDec killed renamable $lr, 1 444; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.2 445; CHECk-MID: tB %bb.3 446; CHECK-MID: bb.3.while.end: 447define void @check_negated_cmp_wls(i16* nocapture %a, i16* nocapture readonly %b, i32 %N) { 448entry: 449 %wls = call i1 @llvm.test.set.loop.iterations.i32(i32 %N) 450 %cmp = icmp ne i1 %wls, 1 451 br i1 %cmp, label %while.end, label %while.body.preheader 452 453while.body.preheader: 454 br label %while.body 455 456while.body: 457 %a.addr.06 = phi i16* [ %incdec.ptr1, %while.body ], [ %a, %while.body.preheader ] 458 %b.addr.05 = phi i16* [ %incdec.ptr, %while.body ], [ %b, %while.body.preheader ] 459 %count = phi i32 [ %N, %while.body.preheader ], [ %count.next, %while.body ] 460 %incdec.ptr = getelementptr inbounds i16, i16* %b.addr.05, i32 1 461 %ld.b = load i16, i16* %b.addr.05, align 2 462 %incdec.ptr1 = getelementptr inbounds i16, i16* %a.addr.06, i32 1 463 store i16 %ld.b, i16* %a.addr.06, align 2 464 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 465 %cmp.1 = icmp ne i32 %count.next, 0 466 br i1 %cmp.1, label %while.body, label %while.end 467 468while.end: 469 ret void 470} 471 472; CHECK-MID: check_negated_reordered_wls 473; CHECK-MID: bb.1.while.body.preheader: 474; CHECK-MID: tB %bb.2 475; CHECK-MID: bb.2.while.body: 476; CHECK-MID: t2LoopDec killed renamable $lr, 1 477; CHECK-MID: t2LoopEnd killed renamable $lr, %bb.2 478; CHECK-MID: tB %bb.4 479; CHECK-MID: bb.3.while: 480; CHECK-MID: t2WhileLoopStart {{.*}}, %bb.4 481; CHECK-MID: bb.4.while.end 482define void @check_negated_reordered_wls(i16* nocapture %a, i16* nocapture readonly %b, i32 %N) { 483entry: 484 br label %while 485 486while.body.preheader: 487 br label %while.body 488 489while.body: 490 %a.addr.06 = phi i16* [ %incdec.ptr1, %while.body ], [ %a, %while.body.preheader ] 491 %b.addr.05 = phi i16* [ %incdec.ptr, %while.body ], [ %b, %while.body.preheader ] 492 %count = phi i32 [ %N, %while.body.preheader ], [ %count.next, %while.body ] 493 %incdec.ptr = getelementptr inbounds i16, i16* %b.addr.05, i32 1 494 %ld.b = load i16, i16* %b.addr.05, align 2 495 %incdec.ptr1 = getelementptr inbounds i16, i16* %a.addr.06, i32 1 496 store i16 %ld.b, i16* %a.addr.06, align 2 497 %count.next = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %count, i32 1) 498 %cmp = icmp ne i32 %count.next, 0 499 br i1 %cmp, label %while.body, label %while.end 500 501while: 502 %wls = call i1 @llvm.test.set.loop.iterations.i32(i32 %N) 503 %xor = xor i1 %wls, 1 504 br i1 %xor, label %while.end, label %while.body.preheader 505 506while.end: 507 ret void 508} 509 510declare i32 @llvm.start.loop.iterations.i32(i32) 511declare i1 @llvm.test.set.loop.iterations.i32(i32) 512declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) 513