1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes="loop-mssa(loop-deletion,simple-loop-unswitch<nontrivial;trivial>),loop(indvars)" -verify-scev -S %s | FileCheck %s
4 define void @pr58868(i1 %c.1, ptr %src, ptr %dst) {
5 ; CHECK-LABEL: @pr58868(
7 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[ENTRY_SPLIT_US:%.*]], label [[ENTRY_SPLIT:%.*]]
8 ; CHECK: entry.split.us:
9 ; CHECK-NEXT: br label [[OUTER_HEADER_US:%.*]]
10 ; CHECK: outer.header.us:
11 ; CHECK-NEXT: br label [[OUTER_BB1_US:%.*]]
12 ; CHECK: outer.bb1.us:
13 ; CHECK-NEXT: br label [[OUTER_BB2_US:%.*]]
14 ; CHECK: outer.bb2.us:
15 ; CHECK-NEXT: [[LV_US:%.*]] = load i16, ptr [[SRC:%.*]], align 1
16 ; CHECK-NEXT: br i1 true, label [[OUTER_HEADER_LOOPEXIT_US:%.*]], label [[OUTER_BB2_SPLIT_SPLIT_US:%.*]]
17 ; CHECK: outer.header.loopexit.us:
18 ; CHECK-NEXT: br label [[OUTER_HEADER_US]]
19 ; CHECK: outer.bb2.split.split.us:
20 ; CHECK-NEXT: [[LV_LCSSA_US:%.*]] = phi i16 [ [[LV_US]], [[OUTER_BB2_US]] ]
21 ; CHECK-NEXT: br label [[OUTER_BB2_SPLIT:%.*]]
23 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
24 ; CHECK: outer.header.loopexit:
25 ; CHECK-NEXT: unreachable
26 ; CHECK: outer.header:
27 ; CHECK-NEXT: br label [[OUTER_BB2:%.*]]
29 ; CHECK-NEXT: [[LV:%.*]] = load i16, ptr [[SRC]], align 1
30 ; CHECK-NEXT: br i1 false, label [[OUTER_HEADER_LOOPEXIT:%.*]], label [[OUTER_BB2_SPLIT_SPLIT:%.*]]
31 ; CHECK: outer.bb2.split.split:
32 ; CHECK-NEXT: [[LV_LCSSA:%.*]] = phi i16 [ [[LV]], [[OUTER_BB2]] ]
33 ; CHECK-NEXT: br label [[OUTER_BB2_SPLIT]]
34 ; CHECK: outer.bb2.split:
35 ; CHECK-NEXT: [[DOTUS_PHI:%.*]] = phi i16 [ [[LV_LCSSA]], [[OUTER_BB2_SPLIT_SPLIT]] ], [ [[LV_LCSSA_US]], [[OUTER_BB2_SPLIT_SPLIT_US]] ]
36 ; CHECK-NEXT: br label [[INNER_HEADER:%.*]]
37 ; CHECK: inner.header:
38 ; CHECK-NEXT: [[IV:%.*]] = phi i16 [ [[DOTUS_PHI]], [[OUTER_BB2_SPLIT]] ], [ [[IV_NEXT:%.*]], [[INNER_LATCH:%.*]] ]
39 ; CHECK-NEXT: br label [[INNER_LATCH]]
41 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i16 [[IV]], 1
42 ; CHECK-NEXT: store i16 0, ptr [[DST:%.*]], align 1
43 ; CHECK-NEXT: [[C_2:%.*]] = icmp ne i16 [[IV]], 0
44 ; CHECK-NEXT: br i1 [[C_2]], label [[INNER_HEADER]], label [[EXIT:%.*]]
46 ; CHECK-NEXT: ret void
49 br label %outer.header
52 br i1 %c.1, label %outer.bb1, label %outer.bb2
58 %lv = load i16, ptr %src, align 1
59 br label %inner.header
62 %iv = phi i16 [ %lv, %outer.bb2 ], [ %iv.next, %inner.latch ]
63 br i1 %c.1, label %outer.header, label %inner.latch
66 %iv.next = add nsw i16 %iv, 1
67 store i16 0, ptr %dst, align 1
68 %c.2 = icmp ne i16 %iv, 0
69 br i1 %c.2, label %inner.header, label %exit