1 ; RUN: opt -jump-threading -S < %s | FileCheck %s
2 ; RUN: opt -passes=jump-threading -S < %s | FileCheck %s
3 ; Check the unreachable loop won't cause infinite loop
4 ; in jump-threading when it tries to update the predecessors'
5 ; profile metadata from a phi node.
7 define void @unreachable_single_bb_loop() {
8 ; CHECK-LABEL: @unreachable_single_bb_loop()
11 %tmp1 = icmp eq i32 %tmp, 1
12 br i1 %tmp1, label %bb5, label %bb8
14 ; unreachable single bb loop.
16 %tmp4 = icmp ne i32 %tmp, 1
17 switch i1 %tmp4, label %bb2 [
22 bb5: ; preds = %bb2, %bb
23 %tmp6 = phi i1 [ %tmp1, %bb ], [ false, %bb2 ]
24 br i1 %tmp6, label %bb8, label %bb7, !prof !0
29 bb8: ; preds = %bb8, %bb7, %bb5, %bb2
33 define void @unreachable_multi_bbs_loop() {
34 ; CHECK-LABEL: @unreachable_multi_bbs_loop()
37 %tmp1 = icmp eq i32 %tmp, 1
38 br i1 %tmp1, label %bb5, label %bb8
40 ; unreachable two bbs loop.
45 %tmp4 = icmp ne i32 %tmp, 1
46 switch i1 %tmp4, label %bb3 [
51 bb5: ; preds = %bb2, %bb
52 %tmp6 = phi i1 [ %tmp1, %bb ], [ false, %bb2 ]
53 br i1 %tmp6, label %bb8, label %bb7, !prof !0
58 bb8: ; preds = %bb8, %bb7, %bb5, %bb2
63 !0 = !{!"branch_weights", i32 2146410443, i32 1073205}