Nate Begeman | 1b0674c | 2005-08-03 18:27:17 +0000 | [diff] [blame] | 1 | ; All of these ands and shifts should be folded into rlwimi's |
Reid Spencer | eb1d74e | 2007-04-16 17:36:08 +0000 | [diff] [blame^] | 2 | ; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 -o %t -f |
| 3 | ; RUN: not grep and %t |
| 4 | ; RUN: not grep srawi %t |
| 5 | ; RUN: not grep srwi %t |
| 6 | ; RUN: not grep slwi %t |
| 7 | ; RUN: grep rlwinm %t | wc -l | grep 8 |
Nate Begeman | 1b0674c | 2005-08-03 18:27:17 +0000 | [diff] [blame] | 8 | |
| 9 | implementation ; Functions: |
| 10 | |
| 11 | int %test1(int %a) { |
| 12 | entry: |
| 13 | %tmp.1 = and int %a, 268431360 ; <int> [#uses=1] |
| 14 | ret int %tmp.1 |
| 15 | } |
| 16 | |
| 17 | int %test2(int %a) { |
| 18 | entry: |
| 19 | %tmp.1 = and int %a, -268435441 ; <int> [#uses=1] |
| 20 | ret int %tmp.1 |
| 21 | } |
Chris Lattner | 645f381 | 2005-08-09 20:24:16 +0000 | [diff] [blame] | 22 | |
| 23 | int %test3(int %a) { |
| 24 | entry: |
| 25 | %tmp.2 = shr int %a, ubyte 8 ; <int> [#uses=1] |
| 26 | %tmp.3 = and int %tmp.2, 255 ; <int> [#uses=1] |
| 27 | ret int %tmp.3 |
| 28 | } |
| 29 | |
| 30 | uint %test4(uint %a) { |
| 31 | entry: |
| 32 | %tmp.3 = shr uint %a, ubyte 8 ; <uint> [#uses=1] |
| 33 | %tmp.4 = and uint %tmp.3, 255 ; <uint> [#uses=1] |
| 34 | ret uint %tmp.4 |
| 35 | } |
| 36 | |
| 37 | int %test5(int %a) { |
| 38 | entry: |
| 39 | %tmp.2 = shl int %a, ubyte 8 ; <int> [#uses=1] |
| 40 | %tmp.3 = and int %tmp.2, -8388608 ; <int> [#uses=1] |
| 41 | ret int %tmp.3 |
| 42 | } |
| 43 | |
| 44 | int %test6(int %a) { |
| 45 | entry: |
| 46 | %tmp.1 = and int %a, 65280 ; <int> [#uses=1] |
| 47 | %tmp.2 = shr int %tmp.1, ubyte 8 ; <uint> [#uses=1] |
| 48 | ret int %tmp.2 |
| 49 | } |
| 50 | |
| 51 | uint %test7(uint %a) { |
| 52 | entry: |
| 53 | %tmp.1 = and uint %a, 65280 ; <uint> [#uses=1] |
| 54 | %tmp.2 = shr uint %tmp.1, ubyte 8 ; <uint> [#uses=1] |
| 55 | ret uint %tmp.2 |
| 56 | } |
| 57 | |
| 58 | int %test8(int %a) { |
| 59 | entry: |
| 60 | %tmp.1 = and int %a, 16711680 ; <int> [#uses=1] |
| 61 | %tmp.2 = shl int %tmp.1, ubyte 8 ; <int> [#uses=1] |
| 62 | ret int %tmp.2 |
| 63 | } |
| 64 | |