• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %s -simplifycfg -S | FileCheck %s
2
3declare i32 @f(i32)
4
5define i32 @basic(i32 %x) {
6; CHECK-LABEL: @basic
7; CHECK-LABEL: entry:
8; CHECK-NEXT:  call i32 @f(i32 0)
9; CHECK-NEXT:  ret i32 %0
10
11entry:
12  switch i32 %x, label %default [
13    i32 5, label %default
14    i32 6, label %default
15    i32 7, label %default
16  ]
17default:
18  %0 = call i32 @f(i32 0)
19  ret i32 %0
20}
21
22
23define i32 @constant() {
24; CHECK-LABEL: @constant
25; CHECK-LABEL: entry:
26; CHECK-NEXT:  call i32 @f(i32 1)
27; CHECK-NEXT:  ret i32 %0
28
29entry:
30  switch i32 42, label %default [
31    i32 41, label %default
32    i32 42, label %a
33    i32 43, label %b
34  ]
35default:
36  %0 = call i32 @f(i32 0)
37  ret i32 %0
38a:
39  %1 = call i32 @f(i32 1)
40  ret i32 %1
41b:
42  %2 = call i32 @f(i32 2)
43  ret i32 %2
44}
45
46
47define i32 @unreachable(i32 %x) {
48; CHECK-LABEL: @unreachable
49; CHECK-LABEL: entry:
50; CHECK-NEXT:  call i32 @f(i32 0)
51; CHECK-NEXT:  ret i32 %0
52
53entry:
54  switch i32 %x, label %unreachable [
55    i32 5, label %a
56    i32 6, label %a
57    i32 7, label %a
58  ]
59unreachable:
60  unreachable
61a:
62  %0 = call i32 @f(i32 0)
63  ret i32 %0
64}
65