summaryrefslogtreecommitdiff
path: root/test/CodeGen/PowerPC/rlwinm2.ll
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2006-09-22 05:49:57 +0000
committerNate Begeman <natebegeman@mac.com>2006-09-22 05:49:57 +0000
commit62929eb3d61ccf4a63045994f62c7a9dec5891a8 (patch)
treeaf4f0b53e73cfaab7fe5b814ec6631a8d17be5e6 /test/CodeGen/PowerPC/rlwinm2.ll
parentf30e0eed4c298084c55e6c8e260b48bf62318227 (diff)
downloadllvm-62929eb3d61ccf4a63045994f62c7a9dec5891a8.tar.gz
llvm-62929eb3d61ccf4a63045994f62c7a9dec5891a8.tar.bz2
llvm-62929eb3d61ccf4a63045994f62c7a9dec5891a8.tar.xz
Testcase for better rotate left and mask support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30579 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/PowerPC/rlwinm2.ll')
-rw-r--r--test/CodeGen/PowerPC/rlwinm2.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/rlwinm2.ll b/test/CodeGen/PowerPC/rlwinm2.ll
new file mode 100644
index 0000000000..8a789ee6e6
--- /dev/null
+++ b/test/CodeGen/PowerPC/rlwinm2.ll
@@ -0,0 +1,30 @@
+; All of these ands and shifts should be folded into rlw[i]nm instructions
+; RUN: llvm-as < %s | llc -march=ppc32 | not grep and &&
+; RUN: llvm-as < %s | llc -march=ppc32 | not grep srawi &&
+; RUN: llvm-as < %s | llc -march=ppc32 | not grep srwi &&
+; RUN: llvm-as < %s | llc -march=ppc32 | not grep slwi &&
+; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwnm | wc -l | grep 1 &&
+; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwinm | wc -l | grep 1
+
+
+implementation ; Functions:
+
+uint %test1(uint %X, int %Y) {
+entry:
+ %tmp = cast int %Y to ubyte ; <ubyte> [#uses=2]
+ %tmp1 = shl uint %X, ubyte %tmp ; <uint> [#uses=1]
+ %tmp2 = sub ubyte 32, %tmp ; <ubyte> [#uses=1]
+ %tmp3 = shr uint %X, ubyte %tmp2 ; <uint> [#uses=1]
+ %tmp4 = or uint %tmp1, %tmp3 ; <uint> [#uses=1]
+ %tmp6 = and uint %tmp4, 127 ; <uint> [#uses=1]
+ ret uint %tmp6
+}
+
+uint %test2(uint %X) {
+entry:
+ %tmp1 = shr uint %X, ubyte 27 ; <uint> [#uses=1]
+ %tmp2 = shl uint %X, ubyte 5 ; <uint> [#uses=1]
+ %tmp2.masked = and uint %tmp2, 96 ; <uint> [#uses=1]
+ %tmp5 = or uint %tmp1, %tmp2.masked ; <uint> [#uses=1]
+ ret uint %tmp5
+}