blob: 8a789ee6e6b18eda48f7f34f7529761a43dd9c92 [file] [log] [blame]
Nate Begeman62929eb2006-09-22 05:49:57 +00001; All of these ands and shifts should be folded into rlw[i]nm instructions
2; RUN: llvm-as < %s | llc -march=ppc32 | not grep and &&
3; RUN: llvm-as < %s | llc -march=ppc32 | not grep srawi &&
4; RUN: llvm-as < %s | llc -march=ppc32 | not grep srwi &&
5; RUN: llvm-as < %s | llc -march=ppc32 | not grep slwi &&
6; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwnm | wc -l | grep 1 &&
7; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwinm | wc -l | grep 1
8
9
10implementation ; Functions:
11
12uint %test1(uint %X, int %Y) {
13entry:
14 %tmp = cast int %Y to ubyte ; <ubyte> [#uses=2]
15 %tmp1 = shl uint %X, ubyte %tmp ; <uint> [#uses=1]
16 %tmp2 = sub ubyte 32, %tmp ; <ubyte> [#uses=1]
17 %tmp3 = shr uint %X, ubyte %tmp2 ; <uint> [#uses=1]
18 %tmp4 = or uint %tmp1, %tmp3 ; <uint> [#uses=1]
19 %tmp6 = and uint %tmp4, 127 ; <uint> [#uses=1]
20 ret uint %tmp6
21}
22
23uint %test2(uint %X) {
24entry:
25 %tmp1 = shr uint %X, ubyte 27 ; <uint> [#uses=1]
26 %tmp2 = shl uint %X, ubyte 5 ; <uint> [#uses=1]
27 %tmp2.masked = and uint %tmp2, 96 ; <uint> [#uses=1]
28 %tmp5 = or uint %tmp1, %tmp2.masked ; <uint> [#uses=1]
29 ret uint %tmp5
30}