1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
4 ; Test that a switch going to a switch on the same value can be merged.
5 ; All three switches in this example can be merged into one big one.
15 define void @test1(i32 %V) {
16 ; CHECK-LABEL: @test1(
17 ; CHECK-NEXT: switch i32 [[V:%.*]], label [[INFLOOP:%.*]] [
18 ; CHECK-NEXT: i32 4, label [[A:%.*]]
19 ; CHECK-NEXT: i32 17, label [[B:%.*]]
20 ; CHECK-NEXT: i32 18, label [[B]]
21 ; CHECK-NEXT: i32 42, label [[D:%.*]]
24 ; CHECK-NEXT: ret void
26 ; CHECK-NEXT: call void @foo1()
27 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
29 ; CHECK-NEXT: call void @foo2()
30 ; CHECK-NEXT: br label [[COMMON_RET]]
32 ; CHECK-NEXT: call void @foo4()
33 ; CHECK-NEXT: br label [[COMMON_RET]]
35 ; CHECK-NEXT: br label [[INFLOOP]]
37 switch i32 %V, label %F [
43 T: ; preds = %0, %0, %0
44 switch i32 %V, label %F [
52 B: ; preds = %F, %F, %T
58 F: ; preds = %F, %T, %0, %0
59 switch i32 %V, label %F [