Skip to content

Commit e32c428

Browse files
[SimplifyCFG] Precommit tests for PR118955 (NFC)
1 parent d7a8e09 commit e32c428

File tree

2 files changed

+106
-14
lines changed

2 files changed

+106
-14
lines changed

llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,20 +314,20 @@ lor.end:
314314
define i32 @overflow(i32 %type) {
315315
; CHECK-LABEL: @overflow(
316316
; CHECK-NEXT: entry:
317-
; CHECK-NEXT: switch i32 [[TYPE:%.*]], label [[IF_END:%.*]] [
317+
; CHECK-NEXT: switch i32 [[TYPE:%.*]], label [[SW_DEFAULT:%.*]] [
318318
; CHECK-NEXT: i32 3, label [[SW_BB3:%.*]]
319319
; CHECK-NEXT: i32 -2147483645, label [[SW_BB3]]
320-
; CHECK-NEXT: i32 1, label [[SW_BB1:%.*]]
320+
; CHECK-NEXT: i32 1, label [[IF_END:%.*]]
321321
; CHECK-NEXT: i32 2, label [[SW_BB2:%.*]]
322322
; CHECK-NEXT: ]
323323
; CHECK: sw.bb1:
324-
; CHECK-NEXT: br label [[IF_END]]
324+
; CHECK-NEXT: br label [[SW_DEFAULT]]
325325
; CHECK: sw.bb2:
326-
; CHECK-NEXT: br label [[IF_END]]
326+
; CHECK-NEXT: br label [[SW_DEFAULT]]
327327
; CHECK: sw.bb3:
328-
; CHECK-NEXT: br label [[IF_END]]
328+
; CHECK-NEXT: br label [[SW_DEFAULT]]
329329
; CHECK: if.end:
330-
; CHECK-NEXT: [[DIRENT_TYPE_0:%.*]] = phi i32 [ 6, [[SW_BB3]] ], [ 5, [[SW_BB2]] ], [ 0, [[SW_BB1]] ], [ 3, [[ENTRY:%.*]] ]
330+
; CHECK-NEXT: [[DIRENT_TYPE_0:%.*]] = phi i32 [ 6, [[SW_BB3]] ], [ 5, [[SW_BB2]] ], [ 0, [[IF_END]] ], [ 3, [[ENTRY:%.*]] ]
331331
; CHECK-NEXT: ret i32 [[DIRENT_TYPE_0]]
332332
;
333333
entry:
@@ -340,15 +340,23 @@ entry:
340340
i32 3, label %sw.bb3
341341
]
342342

343-
sw.bb: br label %if.end
344-
sw.bb1: br label %if.end
345-
sw.bb2: br label %if.end
346-
sw.bb3: br label %if.end
347-
sw.default: br label %if.end
348-
if.else: br label %if.end
343+
sw.bb: ; preds = %entry, %entry
344+
br label %if.end
349345

350-
if.end:
351-
%dirent_type.0 = phi i32 [ 3, %sw.default ], [ 6, %sw.bb3 ], [ 5, %sw.bb2 ], [ 0, %sw.bb1 ], [ 3, %sw.bb ], [ 0, %if.else ]
346+
sw.bb1: ; preds = %entry
347+
br label %if.end
348+
349+
sw.bb2: ; preds = %entry
350+
br label %if.end
351+
352+
sw.bb3: ; preds = %entry, %entry
353+
br label %if.end
354+
355+
sw.default: ; preds = %entry
356+
br label %if.end
357+
358+
if.end: ; preds = %sw.default, %sw.bb3, %sw.bb2, %sw.bb1, %sw.bb
359+
%dirent_type.0 = phi i32 [ 3, %sw.default ], [ 6, %sw.bb3 ], [ 5, %sw.bb2 ], [ 0, %sw.bb1 ], [ 3, %sw.bb ]
352360
ret i32 %dirent_type.0
353361
}
354362

llvm/test/Transforms/SimplifyCFG/switch-dup-bbs.ll

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,87 @@ define i32 @switch_dup_default(i32 %0, i32 %1, i32 %2, i32 %3) {
127127
%9 = phi i32 [ %3, %5 ], [ %2, %6 ], [ %2, %7 ]
128128
ret i32 %9
129129
}
130+
131+
define i32 @switch_dup_exit(i32 %val) {
132+
; SIMPLIFY-CFG-LABEL: define i32 @switch_dup_exit(
133+
; SIMPLIFY-CFG-SAME: i32 [[VAL:%.*]]) {
134+
; SIMPLIFY-CFG-NEXT: [[ENTRY:.*]]:
135+
; SIMPLIFY-CFG-NEXT: switch i32 [[VAL]], label %[[DEFAULT:.*]] [
136+
; SIMPLIFY-CFG-NEXT: i32 1, label %[[EXIT:.*]]
137+
; SIMPLIFY-CFG-NEXT: i32 11, label %[[EXIT]]
138+
; SIMPLIFY-CFG-NEXT: i32 22, label %[[BB1:.*]]
139+
; SIMPLIFY-CFG-NEXT: i32 15, label %[[BB2:.*]]
140+
; SIMPLIFY-CFG-NEXT: i32 0, label %[[BB2]]
141+
; SIMPLIFY-CFG-NEXT: ]
142+
; SIMPLIFY-CFG: [[BB1]]:
143+
; SIMPLIFY-CFG-NEXT: br label %[[EXIT]]
144+
; SIMPLIFY-CFG: [[BB2]]:
145+
; SIMPLIFY-CFG-NEXT: br label %[[EXIT]]
146+
; SIMPLIFY-CFG: [[DEFAULT]]:
147+
; SIMPLIFY-CFG-NEXT: br label %[[EXIT]]
148+
; SIMPLIFY-CFG: [[EXIT]]:
149+
; SIMPLIFY-CFG-NEXT: [[RET:%.*]] = phi i32 [ 0, %[[DEFAULT]] ], [ 0, %[[BB2]] ], [ 3, %[[BB1]] ], [ 1, %[[ENTRY]] ], [ 1, %[[ENTRY]] ]
150+
; SIMPLIFY-CFG-NEXT: ret i32 [[RET]]
151+
;
152+
entry:
153+
switch i32 %val, label %default [
154+
i32 1, label %exit
155+
i32 11, label %exit
156+
i32 22, label %bb1
157+
i32 15, label %bb2
158+
i32 0, label %bb2
159+
]
160+
161+
bb1:
162+
br label %exit
163+
164+
bb2:
165+
br label %exit
166+
167+
default:
168+
br label %exit
169+
170+
exit:
171+
%ret = phi i32 [ 0, %default ], [ 0, %bb2 ], [ 3, %bb1 ], [ 1, %entry ], [ 1, %entry ]
172+
ret i32 %ret
173+
}
174+
175+
define i64 @switch_dup_exit_2(i32 %val) {
176+
; SIMPLIFY-CFG-LABEL: define i64 @switch_dup_exit_2(
177+
; SIMPLIFY-CFG-SAME: i32 [[VAL:%.*]]) {
178+
; SIMPLIFY-CFG-NEXT: [[ENTRY:.*]]:
179+
; SIMPLIFY-CFG-NEXT: switch i32 [[VAL]], label %[[DEFAULT:.*]] [
180+
; SIMPLIFY-CFG-NEXT: i32 1, label %[[EXIT:.*]]
181+
; SIMPLIFY-CFG-NEXT: i32 11, label %[[EXIT]]
182+
; SIMPLIFY-CFG-NEXT: i32 13, label %[[BB1:.*]]
183+
; SIMPLIFY-CFG-NEXT: i32 0, label %[[BB1]]
184+
; SIMPLIFY-CFG-NEXT: ]
185+
; SIMPLIFY-CFG: [[BB1]]:
186+
; SIMPLIFY-CFG-NEXT: br label %[[EXIT]]
187+
; SIMPLIFY-CFG: [[DEFAULT]]:
188+
; SIMPLIFY-CFG-NEXT: br label %[[EXIT]]
189+
; SIMPLIFY-CFG: [[EXIT]]:
190+
; SIMPLIFY-CFG-NEXT: [[RET:%.*]] = phi i64 [ 0, %[[DEFAULT]] ], [ 0, %[[BB1]] ], [ 1, %[[ENTRY]] ], [ 1, %[[ENTRY]] ]
191+
; SIMPLIFY-CFG-NEXT: ret i64 [[RET]]
192+
;
193+
entry:
194+
switch i32 %val, label %default [
195+
i32 1, label %bb2
196+
i32 11, label %exit
197+
i32 13, label %bb1
198+
i32 0, label %bb1
199+
]
200+
201+
bb1:
202+
br label %exit
203+
204+
bb2:
205+
br label %exit
206+
207+
default:
208+
br label %exit
209+
210+
exit:
211+
%ret = phi i64 [ 0, %default ], [ 0, %bb1 ], [ 1, %entry ], [ 1, %bb2 ]
212+
ret i64 %ret
213+
}

0 commit comments

Comments
 (0)