summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/bswap.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-11-29 07:21:08 +0000
committerChris Lattner <sabre@nondot.org>2006-11-29 07:21:08 +0000
commit71d8f4d84a0c41fed67447cd146af09ffd9cc865 (patch)
tree5d8a0a29b4d5cb41addfabd5d80819b1686fc43c /test/Transforms/InstCombine/bswap.ll
parent46b96055cf34dca14ca4d3f853fa8cd8785e5517 (diff)
downloadllvm-71d8f4d84a0c41fed67447cd146af09ffd9cc865.tar.gz
llvm-71d8f4d84a0c41fed67447cd146af09ffd9cc865.tar.bz2
llvm-71d8f4d84a0c41fed67447cd146af09ffd9cc865.tar.xz
new bswap idiom
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32012 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/bswap.ll')
-rw-r--r--test/Transforms/InstCombine/bswap.ll21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/Transforms/InstCombine/bswap.ll b/test/Transforms/InstCombine/bswap.ll
index 6f434e3f27..87caf29252 100644
--- a/test/Transforms/InstCombine/bswap.ll
+++ b/test/Transforms/InstCombine/bswap.ll
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep 'call.*llvm.bswap' | wc -l | grep 4
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep 'call.*llvm.bswap' | wc -l | grep 5
uint %test1(uint %i) {
%tmp1 = shr uint %i, ubyte 24 ; <uint> [#uses=1]
@@ -40,3 +40,22 @@ ushort %test4(ushort %s) {
ret ushort %tmp5
}
+; unsigned short test5(unsigned short a) {
+; return ((a & 0xff00) >> 8 | (a & 0x00ff) << 8);
+;}
+ushort %test5(ushort %a) {
+ %tmp = zext ushort %a to int
+ %tmp1 = and int %tmp, 65280
+ %tmp2 = ashr int %tmp1, ubyte 8
+ %tmp2 = trunc int %tmp2 to short
+ %tmp3 = zext ushort %a to int
+ %tmp4 = and int %tmp3, 255
+ %tmp5 = shl int %tmp4, ubyte 8
+ %tmp5 = trunc int %tmp5 to short
+ %tmp = or short %tmp2, %tmp5
+ %tmp6 = bitcast short %tmp to ushort
+ %tmp6 = zext ushort %tmp6 to int
+ %retval = trunc int %tmp6 to ushort
+ ret ushort %retval
+}
+