1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
4 ; int foo1_with_default(int a) {
14 define i32 @foo1_with_default(i32 %a) {
15 ; CHECK-LABEL: @foo1_with_default(
17 ; CHECK-NEXT: [[SWITCH_SELECTCMP:%.*]] = icmp eq i32 [[A:%.*]], 20
18 ; CHECK-NEXT: [[SWITCH_SELECT:%.*]] = select i1 [[SWITCH_SELECTCMP]], i32 2, i32 4
19 ; CHECK-NEXT: [[SWITCH_SELECTCMP1:%.*]] = icmp eq i32 [[A]], 10
20 ; CHECK-NEXT: [[SWITCH_SELECT2:%.*]] = select i1 [[SWITCH_SELECTCMP1]], i32 10, i32 [[SWITCH_SELECT]]
21 ; CHECK-NEXT: ret i32 [[SWITCH_SELECT2]]
24 switch i32 %a, label %sw.epilog [
39 %retval.0 = phi i32 [ 4, %sw.epilog ], [ 2, %sw.bb1 ], [ 10, %sw.bb ]
43 ; Same as above, but both cases have the same value.
44 define i32 @same_value(i32 %a) {
45 ; CHECK-LABEL: @same_value(
47 ; CHECK-NEXT: [[SWITCH_SELECTCMP_CASE1:%.*]] = icmp eq i32 [[A:%.*]], 10
48 ; CHECK-NEXT: [[SWITCH_SELECTCMP_CASE2:%.*]] = icmp eq i32 [[A]], 20
49 ; CHECK-NEXT: [[SWITCH_SELECTCMP:%.*]] = or i1 [[SWITCH_SELECTCMP_CASE1]], [[SWITCH_SELECTCMP_CASE2]]
50 ; CHECK-NEXT: [[TMP0:%.*]] = select i1 [[SWITCH_SELECTCMP]], i32 10, i32 4
51 ; CHECK-NEXT: ret i32 [[TMP0]]
54 switch i32 %a, label %sw.epilog [
66 %retval.0 = phi i32 [ 4, %sw.epilog ], [ 10, %sw.bb ]