From 33a90b18e084c15f4e2558f9aa8ade4227b39f51 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 6 May 2002 05:43:36 +0000 Subject: [PATCH] New testcases so I don't forget about these algebraic simplifications git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2479 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/and.ll | 31 +++++++++++++++++++++ test/Transforms/InstCombine/or.ll | 41 ++++++++++++++++++++++++++++ test/Transforms/InstCombine/rem.ll | 15 ++++++++++ test/Transforms/InstCombine/shift.ll | 35 ++++++++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 test/Transforms/InstCombine/and.ll create mode 100644 test/Transforms/InstCombine/or.ll create mode 100644 test/Transforms/InstCombine/rem.ll create mode 100644 test/Transforms/InstCombine/shift.ll diff --git a/test/Transforms/InstCombine/and.ll b/test/Transforms/InstCombine/and.ll new file mode 100644 index 00000000000..455be22a9f3 --- /dev/null +++ b/test/Transforms/InstCombine/and.ll @@ -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 index 00000000000..76d620eb334 --- /dev/null +++ b/test/Transforms/InstCombine/or.ll @@ -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 index 00000000000..7f62bd2c596 --- /dev/null +++ b/test/Transforms/InstCombine/rem.ll @@ -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 index 00000000000..c6b65174f6b --- /dev/null +++ b/test/Transforms/InstCombine/shift.ll @@ -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 +} + -- 2.34.1