summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyCFG
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/SimplifyCFG')
-rw-r--r--test/Transforms/SimplifyCFG/basictest.ll9
-rw-r--r--test/Transforms/SimplifyCFG/duplicate-phis.ll21
2 files changed, 28 insertions, 2 deletions
diff --git a/test/Transforms/SimplifyCFG/basictest.ll b/test/Transforms/SimplifyCFG/basictest.ll
index 468b6ed11bc4..a829e030e21d 100644
--- a/test/Transforms/SimplifyCFG/basictest.ll
+++ b/test/Transforms/SimplifyCFG/basictest.ll
@@ -21,5 +21,10 @@ BB1: ; preds = %0, %0
}
-
-
+define void @test4() {
+entry:
+ br label %return
+return:
+ ret void
+}
+@test4g = global i8* blockaddress(@test4, %return)
diff --git a/test/Transforms/SimplifyCFG/duplicate-phis.ll b/test/Transforms/SimplifyCFG/duplicate-phis.ll
new file mode 100644
index 000000000000..a1e511398004
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/duplicate-phis.ll
@@ -0,0 +1,21 @@
+; RUN: opt < %s -instcombine -simplifycfg -S | grep { = phi } | count 1
+
+; instcombine should sort the PHI operands so that simplifycfg can see the
+; duplicate and remove it.
+
+define i32 @foo(i1 %t) {
+entry:
+ call void @bar()
+ br i1 %t, label %true, label %false,
+true:
+ call void @bar()
+ br label %false
+false:
+ %a = phi i32 [ 2, %true ], [ 5, %entry ]
+ %b = phi i32 [ 5, %entry ], [ 2, %true ]
+ call void @bar()
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+declare void @bar()