2009-12-22 14:04:26 +08:00
|
|
|
; Test CFG simplify removal of branch instructions.
|
2002-05-06 10:37:38 +08:00
|
|
|
;
|
2009-12-22 14:04:26 +08:00
|
|
|
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
2002-05-06 10:37:38 +08:00
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test1() {
|
2010-12-13 13:10:30 +08:00
|
|
|
br label %1
|
2008-03-18 11:45:45 +08:00
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2009-12-22 14:04:26 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2002-05-06 10:37:38 +08:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test2() {
|
|
|
|
ret void
|
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2009-12-22 14:04:26 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
; CHECK-NEXT: }
|
2002-05-06 10:37:38 +08:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test3(i1 %T) {
|
2010-12-13 13:10:30 +08:00
|
|
|
br i1 %T, label %1, label %1
|
2008-03-18 11:45:45 +08:00
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
2009-12-22 14:04:26 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2002-05-06 10:37:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-22 14:07:30 +08:00
|
|
|
; PR5795
|
|
|
|
define void @test5(i32 %A) {
|
|
|
|
switch i32 %A, label %return [
|
2010-12-13 13:10:30 +08:00
|
|
|
i32 2, label %1
|
|
|
|
i32 10, label %2
|
2009-12-22 14:07:30 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
ret void
|
|
|
|
|
|
|
|
ret void
|
|
|
|
|
|
|
|
return: ; preds = %entry
|
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
2009-12-22 14:07:30 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
}
|
2014-01-29 00:56:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
; PR14893
|
|
|
|
define i8 @test6f() {
|
|
|
|
; CHECK-LABEL: @test6f
|
|
|
|
; CHECK: alloca i8, align 1
|
|
|
|
; CHECK-NEXT: call i8 @test6g
|
|
|
|
; CHECK-NEXT: icmp eq i8 %tmp, 0
|
|
|
|
; CHECK-NEXT: load i8* %r, align 1{{$}}
|
|
|
|
|
|
|
|
bb0:
|
|
|
|
%r = alloca i8, align 1
|
|
|
|
%tmp = call i8 @test6g(i8* %r)
|
|
|
|
%tmp1 = icmp eq i8 %tmp, 0
|
|
|
|
br i1 %tmp1, label %bb2, label %bb1
|
|
|
|
bb1:
|
|
|
|
%tmp3 = load i8* %r, align 1, !range !2, !tbaa !1
|
|
|
|
%tmp4 = icmp eq i8 %tmp3, 1
|
|
|
|
br i1 %tmp4, label %bb2, label %bb3
|
|
|
|
bb2:
|
|
|
|
br label %bb3
|
|
|
|
bb3:
|
|
|
|
%tmp6 = phi i8 [ 0, %bb2 ], [ 1, %bb1 ]
|
|
|
|
ret i8 %tmp6
|
|
|
|
}
|
|
|
|
declare i8 @test6g(i8*)
|
|
|
|
|
|
|
|
!0 = metadata !{metadata !1, metadata !1, i64 0}
|
|
|
|
!1 = metadata !{metadata !"foo"}
|
|
|
|
!2 = metadata !{i8 0, i8 2}
|