• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -simplifycfg -S | FileCheck %s
2
3; int foo1_with_default(int a) {
4;   switch(a) {
5;     case 10:
6;       return 10;
7;     case 20:
8;       return 2;
9;   }
10;   return 4;
11; }
12
13define i32 @foo1_with_default(i32 %a) {
14; CHECK-LABEL: @foo1_with_default(
15; CHECK-NEXT:  entry:
16; CHECK-NEXT:    [[SWITCH_SELECTCMP:%.*]] = icmp eq i32 %a, 20
17; CHECK-NEXT:    [[SWITCH_SELECT:%.*]] = select i1 [[SWITCH_SELECTCMP:%.*]], i32 2, i32 4
18; CHECK-NEXT:    [[SWITCH_SELECTCMP1:%.*]] = icmp eq i32 %a, 10
19; CHECK-NEXT:    [[SWITCH_SELECT2:%.*]] = select i1 [[SWITCH_SELECTCMP1]], i32 10, i32 [[SWITCH_SELECT]]
20; CHECK-NEXT:    ret i32 [[SWITCH_SELECT2]]
21;
22entry:
23  switch i32 %a, label %sw.epilog [
24  i32 10, label %sw.bb
25  i32 20, label %sw.bb1
26  ]
27
28sw.bb:
29  br label %return
30
31sw.bb1:
32  br label %return
33
34sw.epilog:
35  br label %return
36
37return:
38  %retval.0 = phi i32 [ 4, %sw.epilog ], [ 2, %sw.bb1 ], [ 10, %sw.bb ]
39  ret i32 %retval.0
40}
41
42