New testcases so I don't forget about these algebraic simplifications
authorChris Lattner <sabre@nondot.org>
Mon, 6 May 2002 05:43:36 +0000 (05:43 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 6 May 2002 05:43:36 +0000 (05:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2479 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/and.ll [new file with mode: 0644]
test/Transforms/InstCombine/or.ll [new file with mode: 0644]
test/Transforms/InstCombine/rem.ll [new file with mode: 0644]
test/Transforms/InstCombine/shift.ll [new file with mode: 0644]

diff --git a/test/Transforms/InstCombine/and.ll b/test/Transforms/InstCombine/and.ll
new file mode 100644 (file)
index 0000000..455be22
--- /dev/null
@@ -0,0 +1,31 @@
+; This test makes sure that these instructions are properly eliminated.
+;
+
+; RUN: if as < %s | opt -instcombine -dce | dis | grep and
+; RUN: then exit 1
+; RUN: else exit 0
+; RUN: fi
+
+implementation
+
+int "test1"(int %A) {
+       %B = and int %A, 0     ; zero result
+       ret int %B
+}
+
+int "test2"(int %A) {
+       %B = and int %A, -1    ; noop
+       ret int %B
+}
+
+bool "test3"(bool %A) {
+       %B = and bool %A, false  ; always = false
+       ret bool %B
+}
+
+bool "test4"(bool %A) {
+       %B = and bool %A, true  ; noop
+       ret bool %B
+}
+
+
diff --git a/test/Transforms/InstCombine/or.ll b/test/Transforms/InstCombine/or.ll
new file mode 100644 (file)
index 0000000..76d620e
--- /dev/null
@@ -0,0 +1,41 @@
+; This test makes sure that these instructions are properly eliminated.
+;
+
+; RUN: if as < %s | opt -instcombine -dce | dis | grep or
+; RUN: then exit 1
+; RUN: else exit 0
+; RUN: fi
+
+implementation
+
+int "test1"(int %A) {
+       %B = or int %A, 0
+       ret int %B
+}
+
+int "test2"(int %A) {
+       %B = or int %A, -1
+       ret int %B
+}
+
+bool "test3"(bool %A) {
+       %B = or bool %A, false
+       ret bool %B
+}
+
+bool "test4"(bool %A) {
+       %B = or bool %A, true
+       ret bool %B
+}
+
+bool "test5"(bool %A) {
+       %B = xor bool %A, false
+       ret bool %B
+}
+
+int "test5"(int %A) {
+       %B = xor int %A, 0
+       ret int %B
+}
+
+
diff --git a/test/Transforms/InstCombine/rem.ll b/test/Transforms/InstCombine/rem.ll
new file mode 100644 (file)
index 0000000..7f62bd2
--- /dev/null
@@ -0,0 +1,15 @@
+; This test makes sure that these instructions are properly eliminated.
+;
+
+; RUN: if as < %s | opt -instcombine -dce | dis | grep rem
+; RUN: then exit 1
+; RUN: else exit 0
+; RUN: fi
+
+implementation
+
+int "test1"(int %A) {
+       %B = rem int %A, 1    ; ISA constant 0
+       ret int %B
+}
+
diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll
new file mode 100644 (file)
index 0000000..c6b6517
--- /dev/null
@@ -0,0 +1,35 @@
+; This test makes sure that these instructions are properly eliminated.
+;
+
+; RUN: if as < %s | opt -instcombine -dce | dis | grep sh
+; RUN: then exit 1
+; RUN: else exit 0
+; RUN: fi
+
+implementation
+
+int "test1"(int %A) {
+       %B = shl int %A, ubyte 0
+       ret int %B
+}
+
+int "test2"(ubyte %A) {
+       %B = shl int 0, ubyte %A
+       ret int %B
+}
+
+int "test3"(int %A) {
+       %B = shr int %A, ubyte 0
+       ret int %B
+}
+
+int "test4"(ubyte %A) {
+       %B = shr int 0, ubyte %A
+       ret int %B
+}
+
+int "test5"(int %A) {
+       %B = shr int %A, ubyte 32  ;; shift all bits out
+       ret int %B
+}
+