llvm.org GIT mirror llvm / 19e9705
Add a regtest for cases we now recognize as rotates, thanks to Scott Michel's recent dagcombine patch git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35606 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
1 changed file(s) with 38 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwinm | wc -l | grep 4 &&
1 ; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwnm | wc -l | grep 2 &&
2 ; RUN: llvm-as < %s | llc -march=ppc32 | not grep or
3
4 define i32 @rotl32(i32 %A, i8 %Amt) {
5 %shift.upgrd.1 = zext i8 %Amt to i32 ; [#uses=1]
6 %B = shl i32 %A, %shift.upgrd.1 ; [#uses=1]
7 %Amt2 = sub i8 32, %Amt ; [#uses=1]
8 %shift.upgrd.2 = zext i8 %Amt2 to i32 ; [#uses=1]
9 %C = lshr i32 %A, %shift.upgrd.2 ; [#uses=1]
10 %D = or i32 %B, %C ; [#uses=1]
11 ret i32 %D
12 }
13
14 define i32 @rotr32(i32 %A, i8 %Amt) {
15 %shift.upgrd.3 = zext i8 %Amt to i32 ; [#uses=1]
16 %B = lshr i32 %A, %shift.upgrd.3 ; [#uses=1]
17 %Amt2 = sub i8 32, %Amt ; [#uses=1]
18 %shift.upgrd.4 = zext i8 %Amt2 to i32 ; [#uses=1]
19 %C = shl i32 %A, %shift.upgrd.4 ; [#uses=1]
20 %D = or i32 %B, %C ; [#uses=1]
21 ret i32 %D
22 }
23
24 define i32 @rotli32(i32 %A) {
25 %B = shl i32 %A, 5 ; [#uses=1]
26 %C = lshr i32 %A, 27 ; [#uses=1]
27 %D = or i32 %B, %C ; [#uses=1]
28 ret i32 %D
29 }
30
31 define i32 @rotri32(i32 %A) {
32 %B = lshr i32 %A, 5 ; [#uses=1]
33 %C = shl i32 %A, 27 ; [#uses=1]
34 %D = or i32 %B, %C ; [#uses=1]
35 ret i32 %D
36 }
37