Chris Lattner | 5f0a8c7 | 2004-11-06 21:11:04 +0000 | [diff] [blame] | 1 | ; All of these ands and shifts should be folded into rlwimi's |
John Criswell | d41abfa | 2005-10-17 21:54:18 +0000 | [diff] [blame] | 2 | ; RUN: llvm-as < %s | llc -march=ppc32 | not grep and && |
| 3 | ; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwimi | wc -l | grep 8 |
Nate Begeman | 2a40841 | 2004-10-24 10:30:22 +0000 | [diff] [blame] | 4 | |
| 5 | implementation ; Functions: |
| 6 | |
| 7 | int %test1(int %x, int %y) { |
| 8 | entry: |
| 9 | %tmp.3 = shl int %x, ubyte 16 ; <int> [#uses=1] |
| 10 | %tmp.7 = and int %y, 65535 ; <int> [#uses=1] |
| 11 | %tmp.9 = or int %tmp.7, %tmp.3 ; <int> [#uses=1] |
| 12 | ret int %tmp.9 |
| 13 | } |
| 14 | |
| 15 | int %test2(int %x, int %y) { |
| 16 | entry: |
| 17 | %tmp.7 = and int %x, 65535 ; <int> [#uses=1] |
| 18 | %tmp.3 = shl int %y, ubyte 16 ; <int> [#uses=1] |
| 19 | %tmp.9 = or int %tmp.7, %tmp.3 ; <int> [#uses=1] |
| 20 | ret int %tmp.9 |
| 21 | } |
| 22 | |
| 23 | uint %test3(uint %x, uint %y) { |
| 24 | entry: |
| 25 | %tmp.3 = shr uint %x, ubyte 16 ; <uint> [#uses=1] |
| 26 | %tmp.6 = and uint %y, 4294901760 ; <uint> [#uses=1] |
| 27 | %tmp.7 = or uint %tmp.6, %tmp.3 ; <uint> [#uses=1] |
| 28 | ret uint %tmp.7 |
| 29 | } |
| 30 | |
| 31 | uint %test4(uint %x, uint %y) { |
| 32 | entry: |
| 33 | %tmp.6 = and uint %x, 4294901760 ; <uint> [#uses=1] |
| 34 | %tmp.3 = shr uint %y, ubyte 16 ; <uint> [#uses=1] |
| 35 | %tmp.7 = or uint %tmp.6, %tmp.3 ; <uint> [#uses=1] |
| 36 | ret uint %tmp.7 |
| 37 | } |
| 38 | |
| 39 | int %test5(int %x, int %y) { |
| 40 | entry: |
| 41 | %tmp.3 = shl int %x, ubyte 1 ; <int> [#uses=1] |
| 42 | %tmp.4 = and int %tmp.3, -65536 ; <int> [#uses=1] |
| 43 | %tmp.7 = and int %y, 65535 ; <int> [#uses=1] |
| 44 | %tmp.9 = or int %tmp.4, %tmp.7 ; <int> [#uses=1] |
| 45 | ret int %tmp.9 |
| 46 | } |
| 47 | |
| 48 | int %test6(int %x, int %y) { |
| 49 | entry: |
| 50 | %tmp.7 = and int %x, 65535 ; <int> [#uses=1] |
| 51 | %tmp.3 = shl int %y, ubyte 1 ; <int> [#uses=1] |
| 52 | %tmp.4 = and int %tmp.3, -65536 ; <int> [#uses=1] |
| 53 | %tmp.9 = or int %tmp.4, %tmp.7 ; <int> [#uses=1] |
| 54 | ret int %tmp.9 |
| 55 | } |
| 56 | |
Nate Begeman | 2bbcca3 | 2005-08-03 18:11:23 +0000 | [diff] [blame] | 57 | int %test7(int %x, int %y) { |
Nate Begeman | 2a40841 | 2004-10-24 10:30:22 +0000 | [diff] [blame] | 58 | entry: |
| 59 | %tmp.2 = and int %x, -65536 ; <int> [#uses=1] |
| 60 | %tmp.5 = and int %y, 65535 ; <int> [#uses=1] |
| 61 | %tmp.7 = or int %tmp.5, %tmp.2 ; <int> [#uses=1] |
| 62 | ret int %tmp.7 |
| 63 | } |
Nate Begeman | 2bbcca3 | 2005-08-03 18:11:23 +0000 | [diff] [blame] | 64 | |
| 65 | uint %test8(uint %bar) { |
| 66 | entry: |
| 67 | %tmp.3 = shl uint %bar, ubyte 1 ; <uint> [#uses=1] |
| 68 | %tmp.4 = and uint %tmp.3, 2 ; <uint> [#uses=1] |
| 69 | %tmp.6 = and uint %bar, 4294967293 ; <uint> [#uses=1] |
| 70 | %tmp.7 = or uint %tmp.4, %tmp.6 ; <uint> [#uses=1] |
| 71 | ret uint %tmp.7 |
| 72 | } |