1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -jump-threading -S < %s | FileCheck %s
3 ; RUN: opt -passes=jump-threading -S < %s | FileCheck %s
5 ; Check the unreachable loop won't cause infinite loop
6 ; in jump-threading when it tries to update the predecessors'
7 ; profile metadata from a phi node.
9 define void @unreachable_single_bb_loop() {
11 ; CHECK-LABEL: @unreachable_single_bb_loop(
13 ; CHECK-NEXT: [[TMP:%.*]] = call i32 @a()
14 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP]], 1
15 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB8:%.*]], label [[BB8]]
17 ; CHECK-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP]], 1
18 ; CHECK-NEXT: switch i1 [[TMP4]], label [[BB2:%.*]] [
19 ; CHECK-NEXT: i1 false, label [[BB8]]
20 ; CHECK-NEXT: i1 true, label [[BB8]]
23 ; CHECK-NEXT: ret void
27 %tmp1 = icmp eq i32 %tmp, 1
28 br i1 %tmp1, label %bb5, label %bb8
30 ; unreachable single bb loop.
32 %tmp4 = icmp ne i32 %tmp, 1
33 switch i1 %tmp4, label %bb2 [
38 bb5: ; preds = %bb2, %bb
39 %tmp6 = phi i1 [ %tmp1, %bb ], [ false, %bb2 ]
40 br i1 %tmp6, label %bb8, label %bb7, !prof !0
45 bb8: ; preds = %bb8, %bb7, %bb5, %bb2
49 define void @unreachable_multi_bbs_loop() {
51 ; CHECK-LABEL: @unreachable_multi_bbs_loop(
53 ; CHECK-NEXT: [[TMP:%.*]] = call i32 @a()
54 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP]], 1
55 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB8:%.*]], label [[BB8]]
57 ; CHECK-NEXT: br label [[BB2:%.*]]
59 ; CHECK-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP]], 1
60 ; CHECK-NEXT: switch i1 [[TMP4]], label [[BB3:%.*]] [
61 ; CHECK-NEXT: i1 false, label [[BB8]]
62 ; CHECK-NEXT: i1 true, label [[BB8]]
65 ; CHECK-NEXT: ret void
69 %tmp1 = icmp eq i32 %tmp, 1
70 br i1 %tmp1, label %bb5, label %bb8
72 ; unreachable two bbs loop.
77 %tmp4 = icmp ne i32 %tmp, 1
78 switch i1 %tmp4, label %bb3 [
83 bb5: ; preds = %bb2, %bb
84 %tmp6 = phi i1 [ %tmp1, %bb ], [ false, %bb2 ]
85 br i1 %tmp6, label %bb8, label %bb7, !prof !0
90 bb8: ; preds = %bb8, %bb7, %bb5, %bb2
95 ; This gets into a state that could cause instruction simplify
96 ; to hang - an insertelement instruction has itself as an operand.
98 define void @PR48362() {
100 ; CHECK-LABEL: @PR48362(
101 ; CHECK-NEXT: cleanup.cont1500:
102 ; CHECK-NEXT: unreachable
104 ; CHECK-NEXT: [[I82:%.*]] = load i32, i32* undef, align 1
105 ; CHECK-NEXT: [[TOBOOL1731_NOT:%.*]] = icmp eq i32 [[I82]], 0
106 ; CHECK-NEXT: br label [[IF_END1733:%.*]]
108 cleanup1491: ; preds = %for.body1140
109 switch i32 0, label %cleanup2343.loopexit4 [
110 i32 0, label %cleanup.cont1500
111 i32 128, label %lbl_555.loopexit
114 cleanup.cont1500: ; preds = %cleanup1491
117 lbl_555.loopexit: ; preds = %cleanup1491
118 br label %for.body1509
120 for.body1509: ; preds = %for.inc2340, %lbl_555.loopexit
121 %l_580.sroa.0.0 = phi <4 x i32> [ <i32 1684658741, i32 1684658741, i32 1684658741, i32 1684658741>, %lbl_555.loopexit ], [ %l_580.sroa.0.2, %for.inc2340 ]
122 %p_55.addr.10 = phi i16 [ 0, %lbl_555.loopexit ], [ %p_55.addr.11, %for.inc2340 ]
123 %i82 = load i32, i32* undef, align 1
124 %tobool1731.not = icmp eq i32 %i82, 0
125 br i1 %tobool1731.not, label %if.end1733, label %if.then1732
127 if.then1732: ; preds = %for.body1509
128 br label %cleanup2329
130 if.end1733: ; preds = %for.body1509
131 %tobool1735.not = icmp eq i16 %p_55.addr.10, 0
132 br i1 %tobool1735.not, label %if.then1736, label %if.else1904
134 if.then1736: ; preds = %if.end1733
135 br label %cleanup2329
137 if.else1904: ; preds = %if.end1733
138 br label %for.body1911
140 for.body1911: ; preds = %if.else1904
141 %l_580.sroa.0.4.vec.extract683 = extractelement <4 x i32> %l_580.sroa.0.0, i32 2
142 %xor2107 = xor i32 undef, %l_580.sroa.0.4.vec.extract683
143 br label %land.end2173
145 land.end2173: ; preds = %for.body1911
146 br i1 undef, label %if.end2178, label %cleanup2297
148 if.end2178: ; preds = %land.end2173
149 %l_580.sroa.0.2.vec.insert = insertelement <4 x i32> %l_580.sroa.0.0, i32 undef, i32 1
150 br label %cleanup2297
152 cleanup2297: ; preds = %if.end2178, %land.end2173
153 %l_580.sroa.0.1 = phi <4 x i32> [ %l_580.sroa.0.2.vec.insert, %if.end2178 ], [ %l_580.sroa.0.0, %land.end2173 ]
154 br label %cleanup2329
156 cleanup2329: ; preds = %cleanup2297, %if.then1736, %if.then1732
157 %l_580.sroa.0.2 = phi <4 x i32> [ %l_580.sroa.0.0, %if.then1736 ], [ %l_580.sroa.0.1, %cleanup2297 ], [ %l_580.sroa.0.0, %if.then1732 ]
158 %cleanup.dest.slot.11 = phi i32 [ 0, %if.then1736 ], [ undef, %cleanup2297 ], [ 129, %if.then1732 ]
159 %p_55.addr.11 = phi i16 [ %p_55.addr.10, %if.then1736 ], [ undef, %cleanup2297 ], [ %p_55.addr.10, %if.then1732 ]
160 switch i32 %cleanup.dest.slot.11, label %cleanup2343.loopexit [
161 i32 0, label %cleanup.cont2339
162 i32 129, label %crit_edge114
165 cleanup.cont2339: ; preds = %cleanup2329
166 br label %for.inc2340
168 for.inc2340: ; preds = %cleanup.cont2339
169 br i1 undef, label %for.body1509, label %crit_edge115
171 crit_edge114: ; preds = %cleanup2329
174 crit_edge115: ; preds = %for.inc2340
177 cleanup2343.loopexit: ; preds = %cleanup2329
180 cleanup2343.loopexit4: ; preds = %cleanup1491
184 !0 = !{!"branch_weights", i32 2146410443, i32 1073205}