1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s
3 ; SimplifyCFG should eliminate redundant indirectbr edges.
6 ; CHECK: indirectbr i8* %t, [label %BB0, label %BB1, label %BB2]
7 ; CHECK: %x = phi i32 [ 0, %BB0 ], [ 1, %entry ]
14 define void @indbrtest0(i8** %P, i8** %Q) {
16 store i8* blockaddress(@indbrtest0, %BB0), i8** %P
17 store i8* blockaddress(@indbrtest0, %BB1), i8** %P
18 store i8* blockaddress(@indbrtest0, %BB2), i8** %P
21 indirectbr i8* %t, [label %BB0, label %BB1, label %BB2, label %BB0, label %BB1, label %BB2]
26 %x = phi i32 [ 0, %BB0 ], [ 1, %entry ], [ 1, %entry ]
34 ; SimplifyCFG should convert the indirectbr into a directbr. It would be even
35 ; better if it removed the branch altogether, but simplifycfdg currently misses
36 ; that because the predecessor is the entry block.
39 ; CHECK: br label %BB0
41 define void @indbrtest1(i8** %P, i8** %Q) {
43 store i8* blockaddress(@indbrtest1, %BB0), i8** %P
46 indirectbr i8* %t, [label %BB0, label %BB0]
52 ; SimplifyCFG should notice that BB0 does not have its address taken and
53 ; remove it from entry's successor list.
57 ; CHECK-NEXT: unreachable
59 define void @indbrtest2(i8* %t) {
61 indirectbr i8* %t, [label %BB0, label %BB0]