1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=newgvn -S %s | FileCheck %s
7 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
9 ; CHECK-NEXT: br label [[FOR_COND1:%.*]]
11 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[INC18:%.*]], [[FOR_INC17:%.*]] ], [ 0, [[FOR_COND]] ]
12 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[TMP0]], 1
13 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END19:%.*]]
15 ; CHECK-NEXT: br i1 undef, label [[FOR_BODY3:%.*]], label [[FOR_BODY_FOR_COND4_CRIT_EDGE:%.*]]
16 ; CHECK: for.body.for.cond4_crit_edge:
17 ; CHECK-NEXT: br label [[FOR_COND4:%.*]]
19 ; CHECK-NEXT: br label [[CLEANUP14:%.*]]
21 ; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[IF_END:%.*]]
23 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
25 ; CHECK-NEXT: br label [[FOR_COND6:%.*]]
27 ; CHECK-NEXT: [[TMP1:%.*]] = phi i64 [ [[INC:%.*]], [[FOR_INC:%.*]] ], [ 0, [[IF_END]] ]
28 ; CHECK-NEXT: [[CMP7:%.*]] = icmp sle i64 [[TMP1]], 1
29 ; CHECK-NEXT: br i1 [[CMP7]], label [[FOR_INC]], label [[FOR_END9:%.*]]
31 ; CHECK-NEXT: [[INC]] = add nsw i64 [[TMP1]], 1
32 ; CHECK-NEXT: br label [[FOR_COND6]]
34 ; CHECK-NEXT: br i1 true, label [[IF_THEN11:%.*]], label [[IF_END12:%.*]]
36 ; CHECK-NEXT: br label [[CLEANUP]]
38 ; CHECK-NEXT: store i8 poison, ptr null, align 1
39 ; CHECK-NEXT: br label [[CLEANUP]]
41 ; CHECK-NEXT: [[CLEANUP_DEST:%.*]] = phi i32 [ poison, [[IF_END12]] ], [ 1, [[IF_THEN11]] ], [ 9, [[IF_THEN]] ]
42 ; CHECK-NEXT: switch i32 [[CLEANUP_DEST]], label [[CLEANUP14]] [
43 ; CHECK-NEXT: i32 0, label [[FOR_COND4]]
44 ; CHECK-NEXT: i32 9, label [[FOR_END13:%.*]]
47 ; CHECK-NEXT: br label [[CLEANUP14]]
49 ; CHECK-NEXT: [[CLEANUP_DEST15:%.*]] = phi i32 [ 0, [[FOR_END13]] ], [ [[CLEANUP_DEST]], [[CLEANUP]] ], [ 1, [[FOR_BODY3]] ]
50 ; CHECK-NEXT: [[COND1:%.*]] = icmp eq i32 [[CLEANUP_DEST15]], 0
51 ; CHECK-NEXT: br i1 [[COND1]], label [[FOR_INC17]], label [[CLEANUP20:%.*]]
53 ; CHECK-NEXT: [[INC18]] = add nsw i32 [[TMP0]], 1
54 ; CHECK-NEXT: br label [[FOR_COND1]]
56 ; CHECK-NEXT: br label [[CLEANUP20]]
58 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i1 [ true, [[FOR_END19]] ], [ [[COND1]], [[CLEANUP14]] ]
59 ; CHECK-NEXT: [[CLEANUP_DEST21:%.*]] = phi i32 [ [[CLEANUP_DEST15]], [[CLEANUP14]] ], [ 0, [[FOR_END19]] ]
60 ; CHECK-NEXT: br i1 [[PHIOFOPS]], label [[FOR_COND]], label [[CLEANUP23:%.*]]
62 ; CHECK-NEXT: ret void
67 for.cond: ; preds = %cleanup20, %entry
70 for.cond1: ; preds = %for.inc17, %for.cond
71 %0 = phi i32 [ %inc18, %for.inc17 ], [ 0, %for.cond ]
72 %cmp = icmp sle i32 %0, 1
73 br i1 %cmp, label %for.body, label %for.end19
75 for.body: ; preds = %for.cond1
76 br i1 undef, label %for.body3, label %for.body.for.cond4_crit_edge
78 for.body.for.cond4_crit_edge: ; preds = %for.body
81 for.body3: ; preds = %for.body
84 for.cond4: ; preds = %cleanup, %for.body.for.cond4_crit_edge
85 br i1 undef, label %if.then, label %if.end
87 if.then: ; preds = %for.cond4
90 if.end: ; preds = %for.cond4
93 for.cond6: ; preds = %for.inc, %if.end
94 %1 = phi i64 [ %inc, %for.inc ], [ 0, %if.end ]
95 %cmp7 = icmp sle i64 %1, 1
96 br i1 %cmp7, label %for.inc, label %for.end9
98 for.inc: ; preds = %for.cond6
99 %inc = add nsw i64 %1, 1
102 for.end9: ; preds = %for.cond6
103 br i1 true, label %if.then11, label %if.end12
105 if.then11: ; preds = %for.end9
108 if.end12: ; preds = %for.end9
111 cleanup: ; preds = %if.end12, %if.then11, %if.then
112 %cleanup.dest = phi i32 [ undef, %if.end12 ], [ 1, %if.then11 ], [ 9, %if.then ]
113 switch i32 %cleanup.dest, label %cleanup14 [
114 i32 0, label %for.cond4
115 i32 9, label %for.end13
118 for.end13: ; preds = %cleanup
121 cleanup14: ; preds = %for.end13, %cleanup, %for.body3
122 %cleanup.dest15 = phi i32 [ 0, %for.end13 ], [ %cleanup.dest, %cleanup ], [ 1, %for.body3 ]
123 %cond1 = icmp eq i32 %cleanup.dest15, 0
124 br i1 %cond1, label %for.inc17, label %cleanup20
126 for.inc17: ; preds = %cleanup14
127 %inc18 = add nsw i32 %0, 1
130 for.end19: ; preds = %for.cond1
133 cleanup20: ; preds = %for.end19, %cleanup14
134 %cleanup.dest21 = phi i32 [ %cleanup.dest15, %cleanup14 ], [ 0, %for.end19 ]
135 %cond = icmp eq i32 %cleanup.dest21, 0
136 br i1 %cond, label %for.cond, label %cleanup23
138 cleanup23: ; preds = %cleanup20