1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -loop-reduce -S %s | FileCheck %s
4 ; Make sure SCEVExpander does not crash and introduce unnecessary LCSSA PHI nodes.
6 define void @schedule_block() {
7 ; CHECK-LABEL: @schedule_block(
9 ; CHECK-NEXT: switch i16 undef, label [[IF_END156_I:%.*]] [
10 ; CHECK-NEXT: i16 27, label [[IF_THEN_I:%.*]]
11 ; CHECK-NEXT: i16 28, label [[IF_THEN_I]]
12 ; CHECK-NEXT: i16 29, label [[IF_THEN13_I:%.*]]
13 ; CHECK-NEXT: i16 32, label [[LAND_LHS_TRUE136_I:%.*]]
16 ; CHECK-NEXT: unreachable
18 ; CHECK-NEXT: unreachable
19 ; CHECK: land.lhs.true136.i:
20 ; CHECK-NEXT: unreachable
22 ; CHECK-NEXT: switch i16 undef, label [[WHILE_END256:%.*]] [
23 ; CHECK-NEXT: i16 29, label [[IF_THEN210:%.*]]
24 ; CHECK-NEXT: i16 28, label [[IF_THEN210]]
25 ; CHECK-NEXT: i16 27, label [[LAND_LHS_TRUE191:%.*]]
26 ; CHECK-NEXT: i16 32, label [[IF_END248:%.*]]
28 ; CHECK: land.lhs.true191:
29 ; CHECK-NEXT: unreachable
31 ; CHECK-NEXT: unreachable
33 ; CHECK-NEXT: br label [[FOR_END:%.*]]
34 ; CHECK: while.end256:
35 ; CHECK-NEXT: unreachable
37 ; CHECK-NEXT: br label [[WHILE_BODY1013:%.*]]
38 ; CHECK: while.body1013:
39 ; CHECK-NEXT: br label [[FOR_COND_I2472:%.*]]
40 ; CHECK: for.cond.i2472:
41 ; CHECK-NEXT: [[I_0_I:%.*]] = phi i32 [ 0, [[WHILE_BODY1013]] ], [ [[TMP2:%.*]], [[FOR_END34_I:%.*]] ]
42 ; CHECK-NEXT: br i1 false, label [[FOR_COND3_PREHEADER_I:%.*]], label [[IF_END107_I_LOOPEXIT:%.*]]
43 ; CHECK: for.cond3.preheader.i:
44 ; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[I_0_I]] to i64
45 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw i64 [[TMP0]], 1
46 ; CHECK-NEXT: br label [[FOR_COND3_I:%.*]]
48 ; CHECK-NEXT: [[INDVARS_IV301_I2691:%.*]] = phi i64 [ [[INDVARS_IV_NEXT302_I:%.*]], [[FOR_BODY5_I:%.*]] ], [ [[TMP1]], [[FOR_COND3_PREHEADER_I]] ]
49 ; CHECK-NEXT: [[INDVARS_IV_NEXT302_I]] = add nsw i64 [[INDVARS_IV301_I2691]], 1
50 ; CHECK-NEXT: br label [[FOR_BODY5_I]]
52 ; CHECK-NEXT: br i1 false, label [[FOR_COND3_I]], label [[FOR_BODY5_I_FOR_END_I2475_LOOPEXIT_CRIT_EDGE:%.*]]
53 ; CHECK: for.body5.i.for.end.i2475.loopexit_crit_edge:
54 ; CHECK-NEXT: [[TMP2]] = trunc i64 [[INDVARS_IV_NEXT302_I]] to i32
55 ; CHECK-NEXT: br label [[FOR_END34_I]]
57 ; CHECK-NEXT: br i1 false, label [[FOR_COND_I2472]], label [[IF_ELSE_I2488:%.*]]
58 ; CHECK: if.else.i2488:
59 ; CHECK-NEXT: br i1 undef, label [[IF_END107_I:%.*]], label [[FOR_BODY45_PREHEADER_I:%.*]]
60 ; CHECK: for.body45.preheader.i:
61 ; CHECK-NEXT: [[TMP3:%.*]] = sext i32 [[I_0_I]] to i64
62 ; CHECK-NEXT: unreachable
63 ; CHECK: if.end107.i.loopexit:
64 ; CHECK-NEXT: br label [[IF_END107_I]]
66 ; CHECK-NEXT: unreachable
69 switch i16 undef, label %if.end156.i [
70 i16 27, label %if.then.i
71 i16 28, label %if.then.i
72 i16 29, label %if.then13.i
73 i16 32, label %land.lhs.true136.i
76 if.then.i: ; preds = %entry, %entry
79 if.then13.i: ; preds = %entry
82 land.lhs.true136.i: ; preds = %entry
85 if.end156.i: ; preds = %entry
86 switch i16 undef, label %while.end256 [
87 i16 29, label %if.then210
88 i16 28, label %if.then210
89 i16 27, label %land.lhs.true191
90 i16 32, label %if.end248
93 land.lhs.true191: ; preds = %if.end156.i
96 if.then210: ; preds = %if.end156.i, %if.end156.i
99 if.end248: ; preds = %if.end156.i
102 while.end256: ; preds = %if.end156.i
105 for.end: ; preds = %if.end248
106 br label %while.body1013
108 while.body1013: ; preds = %for.end
109 br label %for.cond.i2472
111 for.cond.i2472: ; preds = %for.end34.i, %while.body1013
112 %i.0.i = phi i32 [ 0, %while.body1013 ], [ %2, %for.end34.i ]
113 br i1 undef, label %for.cond3.preheader.i, label %if.end107.i
115 for.cond3.preheader.i: ; preds = %for.cond.i2472
116 %0 = sext i32 %i.0.i to i64
117 %1 = add nsw i64 %0, 1
118 br label %for.cond3.i
120 for.cond3.i: ; preds = %for.body5.i, %for.cond3.preheader.i
121 %indvars.iv301.i2691 = phi i64 [ %indvars.iv.next302.i, %for.body5.i ], [ %1, %for.cond3.preheader.i ]
122 %indvars.iv.next302.i = add nsw i64 %indvars.iv301.i2691, 1
123 br label %for.body5.i
125 for.body5.i: ; preds = %for.cond3.i
126 br i1 undef, label %for.cond3.i, label %for.body5.i.for.end.i2475.loopexit_crit_edge
128 for.body5.i.for.end.i2475.loopexit_crit_edge: ; preds = %for.body5.i
129 %2 = trunc i64 %indvars.iv.next302.i to i32
130 br label %for.end34.i
132 for.end34.i: ; preds = %for.body5.i.for.end.i2475.loopexit_crit_edge
133 br i1 undef, label %for.cond.i2472, label %if.else.i2488
135 if.else.i2488: ; preds = %for.end34.i
136 br i1 undef, label %if.end107.i, label %for.body45.preheader.i
138 for.body45.preheader.i: ; preds = %if.else.i2488
139 %3 = sext i32 %i.0.i to i64
142 if.end107.i: ; preds = %if.else.i2488, %for.cond.i2472