1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -dfa-jump-threading -dfa-max-path-length=6 %s | FileCheck %s
5 ; <%for.body %case1 %case1.1 %case1.2 %case1.3 %case1.4 %for.inc %for.end>
6 ; too long so that it is not jump-threaded.
7 define i32 @max_path_length(i32 %num) {
8 ; CHECK-LABEL: @max_path_length(
10 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
12 ; CHECK-NEXT: [[COUNT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
13 ; CHECK-NEXT: [[STATE:%.*]] = phi i32 [ 1, [[ENTRY]] ], [ [[STATE_NEXT:%.*]], [[FOR_INC]] ]
14 ; CHECK-NEXT: switch i32 [[STATE]], label [[FOR_INC_JT1:%.*]] [
15 ; CHECK-NEXT: i32 1, label [[CASE1:%.*]]
16 ; CHECK-NEXT: i32 2, label [[CASE2:%.*]]
18 ; CHECK: for.body.jt2:
19 ; CHECK-NEXT: [[COUNT_JT2:%.*]] = phi i32 [ [[INC_JT2:%.*]], [[FOR_INC_JT2:%.*]] ]
20 ; CHECK-NEXT: [[STATE_JT2:%.*]] = phi i32 [ [[STATE_NEXT_JT2:%.*]], [[FOR_INC_JT2]] ]
21 ; CHECK-NEXT: br label [[CASE2]]
22 ; CHECK: for.body.jt1:
23 ; CHECK-NEXT: [[COUNT_JT1:%.*]] = phi i32 [ [[INC_JT1:%.*]], [[FOR_INC_JT1]] ]
24 ; CHECK-NEXT: [[STATE_JT1:%.*]] = phi i32 [ [[STATE_NEXT_JT1:%.*]], [[FOR_INC_JT1]] ]
25 ; CHECK-NEXT: br label [[CASE1]]
27 ; CHECK-NEXT: [[COUNT2:%.*]] = phi i32 [ [[COUNT_JT1]], [[FOR_BODY_JT1:%.*]] ], [ [[COUNT]], [[FOR_BODY]] ]
28 ; CHECK-NEXT: br label [[CASE1_1:%.*]]
30 ; CHECK-NEXT: br label [[CASE1_2:%.*]]
32 ; CHECK-NEXT: br label [[CASE1_3:%.*]]
34 ; CHECK-NEXT: br label [[CASE1_4:%.*]]
36 ; CHECK-NEXT: br label [[FOR_INC]]
38 ; CHECK-NEXT: [[COUNT1:%.*]] = phi i32 [ [[COUNT_JT2]], [[FOR_BODY_JT2:%.*]] ], [ [[COUNT]], [[FOR_BODY]] ]
39 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[COUNT1]], 50
40 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_INC_JT1]], label [[SI_UNFOLD_FALSE:%.*]]
41 ; CHECK: si.unfold.false:
42 ; CHECK-NEXT: br label [[FOR_INC_JT2]]
44 ; CHECK-NEXT: [[STATE_NEXT]] = phi i32 [ 2, [[CASE1_4]] ]
45 ; CHECK-NEXT: [[INC]] = add nsw i32 [[COUNT2]], 1
46 ; CHECK-NEXT: [[CMP_EXIT:%.*]] = icmp slt i32 [[INC]], [[NUM:%.*]]
47 ; CHECK-NEXT: br i1 [[CMP_EXIT]], label [[FOR_BODY]], label [[FOR_END:%.*]]
49 ; CHECK-NEXT: [[STATE_NEXT_JT2]] = phi i32 [ 2, [[SI_UNFOLD_FALSE]] ]
50 ; CHECK-NEXT: [[INC_JT2]] = add nsw i32 [[COUNT1]], 1
51 ; CHECK-NEXT: [[CMP_EXIT_JT2:%.*]] = icmp slt i32 [[INC_JT2]], [[NUM]]
52 ; CHECK-NEXT: br i1 [[CMP_EXIT_JT2]], label [[FOR_BODY_JT2]], label [[FOR_END]]
54 ; CHECK-NEXT: [[COUNT3:%.*]] = phi i32 [ [[COUNT1]], [[CASE2]] ], [ [[COUNT]], [[FOR_BODY]] ]
55 ; CHECK-NEXT: [[STATE_NEXT_JT1]] = phi i32 [ 1, [[CASE2]] ], [ 1, [[FOR_BODY]] ]
56 ; CHECK-NEXT: [[INC_JT1]] = add nsw i32 [[COUNT3]], 1
57 ; CHECK-NEXT: [[CMP_EXIT_JT1:%.*]] = icmp slt i32 [[INC_JT1]], [[NUM]]
58 ; CHECK-NEXT: br i1 [[CMP_EXIT_JT1]], label [[FOR_BODY_JT1]], label [[FOR_END]]
60 ; CHECK-NEXT: ret i32 0
66 %count = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
67 %state = phi i32 [ 1, %entry ], [ %state.next, %for.inc ]
68 switch i32 %state, label %for.inc [
89 %cmp = icmp eq i32 %count, 50
90 %sel = select i1 %cmp, i32 1, i32 2
94 %state.next = phi i32 [ %sel, %case2 ], [ 1, %for.body ], [ 2, %case1.4 ]
95 %inc = add nsw i32 %count, 1
96 %cmp.exit = icmp slt i32 %inc, %num
97 br i1 %cmp.exit, label %for.body, label %for.end