Add a testcase for the recent duplicate PHI elimination changes.
authorDan Gohman <gohman@apple.com>
Fri, 30 Oct 2009 23:16:10 +0000 (23:16 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 30 Oct 2009 23:16:10 +0000 (23:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85636 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/SimplifyCFG/duplicate-phis.ll [new file with mode: 0644]

diff --git a/test/Transforms/SimplifyCFG/duplicate-phis.ll b/test/Transforms/SimplifyCFG/duplicate-phis.ll
new file mode 100644 (file)
index 0000000..a1e5113
--- /dev/null
@@ -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()