@@ -9,11 +9,12 @@ define i32 @switch_with_matching_dests_0_and_pow2_3_cases(i8 %v) {
99; CHECK: [[LOOP_HEADER]]:
1010; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
1111; CHECK-NEXT: [[TMP3:%.*]] = zext i8 [[V]] to i32
12- ; CHECK-NEXT: switch i32 [[TMP3]], label %[[LOOP_LATCH]] [
13- ; CHECK-NEXT: i32 32, label %[[E1:.*]]
14- ; CHECK-NEXT: i32 0, label %[[E1]]
15- ; CHECK-NEXT: i32 124, label %[[E2:.*]]
16- ; CHECK-NEXT: ]
12+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[TMP3]], -33
13+ ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
14+ ; CHECK-NEXT: br i1 [[TMP2]], label %[[E1:.*]], label %[[BB3:.*]]
15+ ; CHECK: [[BB3]]:
16+ ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[TMP3]], 124
17+ ; CHECK-NEXT: br i1 [[COND]], label %[[E2:.*]], label %[[LOOP_LATCH]]
1718; CHECK: [[LOOP_LATCH]]:
1819; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
1920; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[IV_NEXT]], 100
@@ -54,11 +55,12 @@ define i32 @switch_with_matching_dests_0_and_pow2_3_cases_swapped(i8 %v) {
5455; CHECK: [[LOOP_HEADER]]:
5556; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
5657; CHECK-NEXT: [[TMP3:%.*]] = zext i8 [[V]] to i32
57- ; CHECK-NEXT: switch i32 [[TMP3]], label %[[LOOP_LATCH]] [
58- ; CHECK-NEXT: i32 0, label %[[E1:.*]]
59- ; CHECK-NEXT: i32 32, label %[[E1]]
60- ; CHECK-NEXT: i32 124, label %[[E2:.*]]
61- ; CHECK-NEXT: ]
58+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[TMP3]], -33
59+ ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
60+ ; CHECK-NEXT: br i1 [[TMP2]], label %[[E1:.*]], label %[[BB3:.*]]
61+ ; CHECK: [[BB3]]:
62+ ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[TMP3]], 124
63+ ; CHECK-NEXT: br i1 [[COND]], label %[[E2:.*]], label %[[LOOP_LATCH]]
6264; CHECK: [[LOOP_LATCH]]:
6365; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
6466; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[IV_NEXT]], 100
@@ -106,19 +108,20 @@ define i32 @switch_with_matching_dests_0_and_pow2_3_cases_with_phi(i8 %v, i1 %c)
106108; CHECK: [[LOOP_HEADER]]:
107109; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, %[[THEN]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
108110; CHECK-NEXT: [[TMP0:%.*]] = zext i8 [[V]] to i32
109- ; CHECK-NEXT: switch i32 [[TMP0]], label %[[LOOP_LATCH]] [
110- ; CHECK-NEXT: i32 32, label %[[E1]]
111- ; CHECK-NEXT: i32 0, label %[[E1]]
112- ; CHECK-NEXT: i32 124, label %[[E2:.*]]
113- ; CHECK-NEXT: ]
111+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[TMP0]], -33
112+ ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
113+ ; CHECK-NEXT: br i1 [[TMP2]], label %[[E1]], label %[[BB3:.*]]
114+ ; CHECK: [[BB3]]:
115+ ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[TMP0]], 124
116+ ; CHECK-NEXT: br i1 [[COND]], label %[[E2:.*]], label %[[LOOP_LATCH]]
114117; CHECK: [[LOOP_LATCH]]:
115118; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
116119; CHECK-NEXT: [[EC:%.*]] = icmp eq i32 [[IV_NEXT]], 100
117120; CHECK-NEXT: br i1 [[EC]], label %[[E0:.*]], label %[[LOOP_HEADER]]
118121; CHECK: [[E0]]:
119122; CHECK-NEXT: ret i32 10
120123; CHECK: [[E1]]:
121- ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ 20, %[[LOOP_HEADER]] ], [ 20, %[[LOOP_HEADER]] ]
124+ ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ 20, %[[LOOP_HEADER]] ]
122125; CHECK-NEXT: ret i32 [[P]]
123126; CHECK: [[E2]]:
124127; CHECK-NEXT: ret i32 30
@@ -214,19 +217,20 @@ define i32 @switch_in_loop_with_matching_dests_0_and_pow2_3_cases(ptr %start) {
214217; CHECK-NEXT: [[ENTRY:.*]]:
215218; CHECK-NEXT: br label %[[LOOP:.*]]
216219; CHECK: [[LOOP]]:
217- ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[TMP0:%.*]], %[[LOOP ]] ]
220+ ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[TMP0:%.*]], %[[TMP4:.* ]] ]
218221; CHECK-NEXT: [[TMP0]] = getelementptr inbounds nuw i8, ptr [[P]], i64 1
219222; CHECK-NEXT: [[L:%.*]] = load i8, ptr [[TMP0]], align 1
220223; CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[L]] to i32
221- ; CHECK-NEXT: switch i32 [[TMP1]], label %[[LOOP]] [
222- ; CHECK-NEXT: i32 32, label %[[E1:.*]]
223- ; CHECK-NEXT: i32 0, label %[[E1]]
224- ; CHECK-NEXT: i32 124, label %[[E2:.*]]
225- ; CHECK-NEXT: ]
224+ ; CHECK-NEXT: [[TMP5:%.*]] = and i32 [[TMP1]], -33
225+ ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP5]], 0
226+ ; CHECK-NEXT: br i1 [[TMP3]], label %[[E1:.*]], label %[[TMP4]]
227+ ; CHECK: [[TMP4]]:
228+ ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[TMP1]], 124
229+ ; CHECK-NEXT: br i1 [[COND]], label %[[E2:.*]], label %[[LOOP]]
226230; CHECK: [[E1]]:
227231; CHECK-NEXT: br label %[[E2]]
228232; CHECK: [[E2]]:
229- ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ -1, %[[E1]] ], [ 0, %[[LOOP ]] ]
233+ ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ -1, %[[E1]] ], [ 0, %[[TMP4 ]] ]
230234; CHECK-NEXT: ret i32 [[TMP2]]
231235;
232236entry:
@@ -256,20 +260,22 @@ define i32 @switch_in_loop_with_matching_dests_0_and_pow2_4_cases(ptr %start) {
256260; CHECK-NEXT: [[ENTRY:.*]]:
257261; CHECK-NEXT: br label %[[LOOP:.*]]
258262; CHECK: [[LOOP]]:
259- ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[TMP0:%.*]], %[[LOOP ]] ]
263+ ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[TMP0:%.*]], %[[TMP4:.* ]] ]
260264; CHECK-NEXT: [[TMP0]] = getelementptr inbounds nuw i8, ptr [[P]], i64 1
261265; CHECK-NEXT: [[L:%.*]] = load i8, ptr [[TMP0]], align 1
262266; CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[L]] to i32
267+ ; CHECK-NEXT: [[TMP5:%.*]] = and i32 [[TMP1]], -33
268+ ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP5]], 0
269+ ; CHECK-NEXT: br i1 [[TMP3]], label %[[E1:.*]], label %[[TMP4]]
270+ ; CHECK: [[TMP4]]:
263271; CHECK-NEXT: switch i32 [[TMP1]], label %[[LOOP]] [
264- ; CHECK-NEXT: i32 0, label %[[E1:.*]]
265- ; CHECK-NEXT: i32 15, label %[[E1]]
266- ; CHECK-NEXT: i32 32, label %[[E1]]
267272; CHECK-NEXT: i32 124, label %[[E2:.*]]
273+ ; CHECK-NEXT: i32 15, label %[[E1]]
268274; CHECK-NEXT: ]
269275; CHECK: [[E1]]:
270276; CHECK-NEXT: br label %[[E2]]
271277; CHECK: [[E2]]:
272- ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ -1, %[[E1]] ], [ 0, %[[LOOP ]] ]
278+ ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ -1, %[[E1]] ], [ 0, %[[TMP4 ]] ]
273279; CHECK-NEXT: ret i32 [[TMP2]]
274280;
275281entry:
0 commit comments