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 +} +