aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-16 19:08:36 +0000
committerChris Lattner <sabre@nondot.org>2002-09-16 19:08:36 +0000
commit876a75c79e90a9b057c4da0e44554f21974f1d7c (patch)
treeb095acf1a5aac5fa08b12ca810298af4135660cc /test
parent8e2e5f74daf4dfa741634c4b1e2c65d5dcd18c2e (diff)
downloadexternal_llvm-876a75c79e90a9b057c4da0e44554f21974f1d7c.zip
external_llvm-876a75c79e90a9b057c4da0e44554f21974f1d7c.tar.gz
external_llvm-876a75c79e90a9b057c4da0e44554f21974f1d7c.tar.bz2
Checking testcases for cee pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3764 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/CorrelatedExprs/Makefile10
-rw-r--r--test/Transforms/CorrelatedExprs/basictest.ll138
-rw-r--r--test/Transforms/CorrelatedExprs/branchtest.ll38
3 files changed, 186 insertions, 0 deletions
diff --git a/test/Transforms/CorrelatedExprs/Makefile b/test/Transforms/CorrelatedExprs/Makefile
new file mode 100644
index 0000000..91acd4d
--- /dev/null
+++ b/test/Transforms/CorrelatedExprs/Makefile
@@ -0,0 +1,10 @@
+
+LEVEL = ../../../..
+include $(LEVEL)/test/Makefile.tests
+
+TESTS := $(wildcard *.ll)
+
+all:: $(addprefix Output/, $(TESTS:%.ll=%.ll.out))
+
+Output/%.ll.out: %.ll Output/.dir $(LOPT)
+ -$(TESTRUNR) $<
diff --git a/test/Transforms/CorrelatedExprs/basictest.ll b/test/Transforms/CorrelatedExprs/basictest.ll
new file mode 100644
index 0000000..c8eb546
--- /dev/null
+++ b/test/Transforms/CorrelatedExprs/basictest.ll
@@ -0,0 +1,138 @@
+; RUN: if as < %s | opt -cee -constprop -instcombine -dce | dis | grep 'REMOVE'
+; RUN: then exit 1
+; RUN: else exit 0
+; RUN: fi
+
+int %test1(int %A) {
+ %cond = seteq int %A, 40
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE = add int %A, 2 ; Should become = 42
+ ret int %REMOVE
+F:
+ ret int 8
+}
+
+bool %test2(int %A) {
+ %cond = seteq int %A, 40
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE = seteq int %A, 2 ; Should become = false
+ ret bool %REMOVE
+F:
+ ret bool false
+}
+
+bool %test3(int %A) {
+ %cond = setlt int %A, 40
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE = setgt int %A, 47 ; Should become = false
+ ret bool %REMOVE
+F:
+ %REMOVE2 = setge int %A, 40 ; Should become = true
+ ret bool %REMOVE2
+}
+
+bool %test4(int %A) {
+ %cond = setlt int %A, 40
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE = setgt int %A, 47 ; Should become = false
+ ret bool %REMOVE
+F:
+ ret bool false
+}
+
+int %test5(int %A, int %B) {
+ %cond = setne int %A, %B
+ br bool %cond, label %F, label %T
+T:
+ %C = sub int %A, %B ; = 0
+ ret int %C
+F:
+ ret int 0
+}
+
+bool %test6(int %A) {
+ %REMOVE = setlt int %A, 47 ; Should become dead
+ %cond = setlt int %A, 40
+ br bool %cond, label %T, label %F
+T:
+ ret bool %REMOVE ;; == true
+F:
+ ret bool false
+}
+
+bool %test7(int %A) {
+ %cond = setlt int %A, 40
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE = xor bool %cond, true
+ ret bool %REMOVE
+F:
+ ret bool false
+}
+
+; Test that and expressions are handled...
+bool %test8(int %A, int %B) {
+ %cond1 = setle int %A, 7
+ %cond2 = setle int %B, 7
+ %cond = and bool %cond1, %cond2
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE1 = seteq int %A, 9 ; false
+ %REMOVE2 = setge int %B, 9 ; false
+ %REMOVE = or bool %REMOVE1, %REMOVE2 ; false
+ ret bool %REMOVE
+F:
+ ret bool false
+}
+
+; Test that or expressions are handled...
+bool %test9(int %A, int %B) {
+ %cond1 = setle int %A, 7
+ %cond2 = setle int %B, 7
+ %cond = or bool %cond1, %cond2
+ br bool %cond, label %T, label %F
+T:
+ ret bool false
+F:
+ %REMOVE1 = setge int %A, 8 ; true
+ %REMOVE2 = setge int %B, 8 ; true
+ %REMOVE = or bool %REMOVE1, %REMOVE2 ; true
+ ret bool %REMOVE
+}
+
+bool %test10(int %A) {
+ %cond = setle int %A, 7
+ br bool %cond, label %T, label %F
+T:
+ ret bool false
+F:
+ %REMOVE = setge int %A, 8
+ ret bool %REMOVE
+}
+
+; Implement correlated comparisons against non-constants
+bool %test11(int %A, int %B) {
+ %cond = setlt int %A, %B
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE1 = seteq int %A, %B ; false
+ %REMOVE2 = setle int %A, %B ; true
+ %cond2 = and bool %REMOVE1, %REMOVE2
+ ret bool %cond2
+F:
+ ret bool true
+}
+
+bool %test12(int %A) {
+ %cond = setlt int %A, 0
+ br bool %cond, label %T, label %F
+T:
+ %REMOVE = setne int %A, 0 ; true
+ ret bool %REMOVE
+F:
+ ret bool false
+}
diff --git a/test/Transforms/CorrelatedExprs/branchtest.ll b/test/Transforms/CorrelatedExprs/branchtest.ll
new file mode 100644
index 0000000..eeed1fd
--- /dev/null
+++ b/test/Transforms/CorrelatedExprs/branchtest.ll
@@ -0,0 +1,38 @@
+; RUN: if as < %s | opt -cee -simplifycfg | dis | grep 'REMOVE'
+; RUN: then exit 1
+; RUN: else exit 0
+; RUN: fi
+
+implementation
+
+declare void %foo(int)
+
+void %test(int %A) {
+bb1: ;[#uses=0]
+ %cond212 = setgt int %A, 9 ; <bool> [#uses=1]
+ br bool %cond212, label %REMOVEbb3, label %bb2
+
+bb2: ;[#uses=1]
+ call void %foo( int 123 )
+ br label %REMOVEbb3
+
+REMOVEbb3: ;[#uses=2]
+ %cond217 = setle int %A, 9 ; <bool> [#uses=1]
+ br bool %cond217, label %REMOVEbb5, label %bb4
+
+bb4: ;[#uses=1]
+ call void %foo( int 234 )
+ br label %REMOVEbb5
+
+REMOVEbb5: ;[#uses=2]
+ %cond222 = setgt int %A, 9 ; <bool> [#uses=1]
+ br bool %cond222, label %bb7, label %REMOVEbb6
+
+REMOVEbb6: ;[#uses=1]
+ call void %foo( int 456 )
+ br label %bb7
+
+bb7: ;[#uses=2]
+ ret void
+}
+