[llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/bswap.ll

Chris Lattner sabre at nondot.org
Tue Nov 28 23:21:22 PST 2006



Changes in directory llvm/test/Regression/Transforms/InstCombine:

bswap.ll updated: 1.2 -> 1.3
---
Log message:

new bswap idiom


---
Diffs of the changes:  (+20 -1)

 bswap.ll |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletion(-)


Index: llvm/test/Regression/Transforms/InstCombine/bswap.ll
diff -u llvm/test/Regression/Transforms/InstCombine/bswap.ll:1.2 llvm/test/Regression/Transforms/InstCombine/bswap.ll:1.3
--- llvm/test/Regression/Transforms/InstCombine/bswap.ll:1.2	Mon Jul 10 15:25:01 2006
+++ llvm/test/Regression/Transforms/InstCombine/bswap.ll	Wed Nov 29 01:21:08 2006
@@ -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 @@
 	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
+}
+






More information about the llvm-commits mailing list