1 ; Test CFG simplify removal of branch instructions. 2 ; 3 ; RUN: opt < %s -simplifycfg -S | FileCheck %s 4 5 define void @test1() { 6 br label %1 7 ret void 8 ; CHECK-LABEL: @test1( 9 ; CHECK-NEXT: ret void 10 } 11 12 define void @test2() { 13 ret void 14 ret void 15 ; CHECK-LABEL: @test2( 16 ; CHECK-NEXT: ret void 17 ; CHECK-NEXT: } 18 } 19 20 define void @test3(i1 %T) { 21 br i1 %T, label %1, label %1 22 ret void 23 ; CHECK-LABEL: @test3( 24 ; CHECK-NEXT: ret void 25 } 26 27 28 ; PR5795 29 define void @test5(i32 %A) { 30 switch i32 %A, label %return [ 31 i32 2, label %1 32 i32 10, label %2 33 ] 34 35 ret void 36 37 ret void 38 39 return: ; preds = %entry 40 ret void 41 ; CHECK-LABEL: @test5( 42 ; CHECK-NEXT: ret void 43 } 44 45 46 ; PR14893 47 define i8 @test6f() { 48 ; CHECK-LABEL: @test6f 49 ; CHECK: alloca i8, align 1 50 ; CHECK-NEXT: call i8 @test6g 51 ; CHECK-NEXT: icmp eq i8 %tmp, 0 52 ; CHECK-NEXT: load i8* %r, align 1{{$}} 53 54 bb0: 55 %r = alloca i8, align 1 56 %tmp = call i8 @test6g(i8* %r) 57 %tmp1 = icmp eq i8 %tmp, 0 58 br i1 %tmp1, label %bb2, label %bb1 59 bb1: 60 %tmp3 = load i8* %r, align 1, !range !2, !tbaa !1 61 %tmp4 = icmp eq i8 %tmp3, 1 62 br i1 %tmp4, label %bb2, label %bb3 63 bb2: 64 br label %bb3 65 bb3: 66 %tmp6 = phi i8 [ 0, %bb2 ], [ 1, %bb1 ] 67 ret i8 %tmp6 68 } 69 declare i8 @test6g(i8*) 70 71 !0 = metadata !{metadata !1, metadata !1, i64 0} 72 !1 = metadata !{metadata !"foo"} 73 !2 = metadata !{i8 0, i8 2} 74