Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 1 | ; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s |
Scott Michel | 477dc85 | 2008-12-31 00:08:25 +0000 | [diff] [blame^] | 2 | ; RUN: grep -w shlh %t1.s | count 9 |
Scott Michel | 02d711b | 2008-12-30 23:28:25 +0000 | [diff] [blame] | 3 | ; RUN: grep -w shlhi %t1.s | count 3 |
| 4 | ; RUN: grep -w shl %t1.s | count 9 |
| 5 | ; RUN: grep -w shli %t1.s | count 3 |
| 6 | ; RUN: grep -w xshw %t1.s | count 5 |
| 7 | ; RUN: grep -w and %t1.s | count 5 |
| 8 | ; RUN: grep -w andi %t1.s | count 2 |
| 9 | ; RUN: grep -w rotmi %t1.s | count 2 |
| 10 | ; RUN: grep -w rotqmbyi %t1.s | count 1 |
| 11 | ; RUN: grep -w rotqmbii %t1.s | count 2 |
| 12 | ; RUN: grep -w rotqmby %t1.s | count 1 |
| 13 | ; RUN: grep -w rotqmbi %t1.s | count 1 |
| 14 | ; RUN: grep -w rotqbyi %t1.s | count 1 |
| 15 | ; RUN: grep -w rotqbii %t1.s | count 2 |
| 16 | ; RUN: grep -w rotqbybi %t1.s | count 1 |
| 17 | ; RUN: grep -w sfi %t1.s | count 3 |
| 18 | |
Scott Michel | 477dc85 | 2008-12-31 00:08:25 +0000 | [diff] [blame^] | 19 | ; XFAIL: * |
| 20 | |
Scott Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 21 | target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128" |
| 22 | target triple = "spu" |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 23 | |
| 24 | ; Vector shifts are not currently supported in gcc or llvm assembly. These are |
| 25 | ; not tested. |
| 26 | |
| 27 | ; Shift left i16 via register, note that the second operand to shl is promoted |
| 28 | ; to a 32-bit type: |
| 29 | |
| 30 | define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 31 | %A = shl i16 %arg1, %arg2 |
| 32 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | define i16 @shlh_i16_2(i16 %arg1, i16 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 36 | %A = shl i16 %arg2, %arg1 |
| 37 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | define i16 @shlh_i16_3(i16 signext %arg1, i16 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 41 | %A = shl i16 %arg1, %arg2 |
| 42 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | define i16 @shlh_i16_4(i16 signext %arg1, i16 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 46 | %A = shl i16 %arg2, %arg1 |
| 47 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | define i16 @shlh_i16_5(i16 zeroext %arg1, i16 zeroext %arg2) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 51 | %A = shl i16 %arg1, %arg2 |
| 52 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | define i16 @shlh_i16_6(i16 zeroext %arg1, i16 zeroext %arg2) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 56 | %A = shl i16 %arg2, %arg1 |
| 57 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | ; Shift left i16 with immediate: |
| 61 | define i16 @shlhi_i16_1(i16 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 62 | %A = shl i16 %arg1, 12 |
| 63 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | ; Should not generate anything other than the return, arg1 << 0 = arg1 |
| 67 | define i16 @shlhi_i16_2(i16 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 68 | %A = shl i16 %arg1, 0 |
| 69 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | define i16 @shlhi_i16_3(i16 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 73 | %A = shl i16 16383, %arg1 |
| 74 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | ; Should generate 0, 0 << arg1 = 0 |
| 78 | define i16 @shlhi_i16_4(i16 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 79 | %A = shl i16 0, %arg1 |
| 80 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | define i16 @shlhi_i16_5(i16 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 84 | %A = shl i16 %arg1, 12 |
| 85 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | ; Should not generate anything other than the return, arg1 << 0 = arg1 |
| 89 | define i16 @shlhi_i16_6(i16 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 90 | %A = shl i16 %arg1, 0 |
| 91 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | define i16 @shlhi_i16_7(i16 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 95 | %A = shl i16 16383, %arg1 |
| 96 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | ; Should generate 0, 0 << arg1 = 0 |
| 100 | define i16 @shlhi_i16_8(i16 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 101 | %A = shl i16 0, %arg1 |
| 102 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | define i16 @shlhi_i16_9(i16 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 106 | %A = shl i16 %arg1, 12 |
| 107 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | ; Should not generate anything other than the return, arg1 << 0 = arg1 |
| 111 | define i16 @shlhi_i16_10(i16 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 112 | %A = shl i16 %arg1, 0 |
| 113 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | define i16 @shlhi_i16_11(i16 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 117 | %A = shl i16 16383, %arg1 |
| 118 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | ; Should generate 0, 0 << arg1 = 0 |
| 122 | define i16 @shlhi_i16_12(i16 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 123 | %A = shl i16 0, %arg1 |
| 124 | ret i16 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | ; Shift left i32 via register, note that the second operand to shl is promoted |
| 128 | ; to a 32-bit type: |
| 129 | |
| 130 | define i32 @shl_i32_1(i32 %arg1, i32 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 131 | %A = shl i32 %arg1, %arg2 |
| 132 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | define i32 @shl_i32_2(i32 %arg1, i32 %arg2) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 136 | %A = shl i32 %arg2, %arg1 |
| 137 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | define i32 @shl_i32_3(i32 signext %arg1, i32 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 141 | %A = shl i32 %arg1, %arg2 |
| 142 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | define i32 @shl_i32_4(i32 signext %arg1, i32 signext %arg2) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 146 | %A = shl i32 %arg2, %arg1 |
| 147 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | define i32 @shl_i32_5(i32 zeroext %arg1, i32 zeroext %arg2) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 151 | %A = shl i32 %arg1, %arg2 |
| 152 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | define i32 @shl_i32_6(i32 zeroext %arg1, i32 zeroext %arg2) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 156 | %A = shl i32 %arg2, %arg1 |
| 157 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | ; Shift left i32 with immediate: |
| 161 | define i32 @shli_i32_1(i32 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 162 | %A = shl i32 %arg1, 12 |
| 163 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | ; Should not generate anything other than the return, arg1 << 0 = arg1 |
| 167 | define i32 @shli_i32_2(i32 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 168 | %A = shl i32 %arg1, 0 |
| 169 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | define i32 @shli_i32_3(i32 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 173 | %A = shl i32 16383, %arg1 |
| 174 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | ; Should generate 0, 0 << arg1 = 0 |
| 178 | define i32 @shli_i32_4(i32 %arg1) { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 179 | %A = shl i32 0, %arg1 |
| 180 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | define i32 @shli_i32_5(i32 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 184 | %A = shl i32 %arg1, 12 |
| 185 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | ; Should not generate anything other than the return, arg1 << 0 = arg1 |
| 189 | define i32 @shli_i32_6(i32 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 190 | %A = shl i32 %arg1, 0 |
| 191 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | define i32 @shli_i32_7(i32 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 195 | %A = shl i32 16383, %arg1 |
| 196 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | ; Should generate 0, 0 << arg1 = 0 |
| 200 | define i32 @shli_i32_8(i32 signext %arg1) signext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 201 | %A = shl i32 0, %arg1 |
| 202 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | define i32 @shli_i32_9(i32 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 206 | %A = shl i32 %arg1, 12 |
| 207 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | ; Should not generate anything other than the return, arg1 << 0 = arg1 |
| 211 | define i32 @shli_i32_10(i32 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 212 | %A = shl i32 %arg1, 0 |
| 213 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | define i32 @shli_i32_11(i32 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 217 | %A = shl i32 16383, %arg1 |
| 218 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | ; Should generate 0, 0 << arg1 = 0 |
| 222 | define i32 @shli_i32_12(i32 zeroext %arg1) zeroext { |
Scott Michel | 53dec47 | 2008-03-05 23:00:19 +0000 | [diff] [blame] | 223 | %A = shl i32 0, %arg1 |
| 224 | ret i32 %A |
Scott Michel | 0a92af4 | 2007-12-19 20:50:49 +0000 | [diff] [blame] | 225 | } |
Scott Michel | 02d711b | 2008-12-30 23:28:25 +0000 | [diff] [blame] | 226 | |
| 227 | ;; i64 shift left |
| 228 | |
| 229 | define i64 @shl_i64_1(i64 %arg1) { |
| 230 | %A = shl i64 %arg1, 9 |
| 231 | ret i64 %A |
| 232 | } |
| 233 | |
| 234 | define i64 @shl_i64_2(i64 %arg1) { |
| 235 | %A = shl i64 %arg1, 3 |
| 236 | ret i64 %A |
| 237 | } |
| 238 | |
| 239 | define i64 @shl_i64_3(i64 %arg1, i32 %shift) { |
| 240 | %1 = zext i32 %shift to i64 |
| 241 | %2 = shl i64 %arg1, %1 |
| 242 | ret i64 %2 |
| 243 | } |
| 244 | |
| 245 | ;; i64 shift right logical (shift 0s from the right) |
| 246 | |
| 247 | define i64 @lshr_i64_1(i64 %arg1) { |
| 248 | %1 = lshr i64 %arg1, 9 |
| 249 | ret i64 %1 |
| 250 | } |
| 251 | |
| 252 | define i64 @lshr_i64_2(i64 %arg1) { |
| 253 | %1 = lshr i64 %arg1, 3 |
| 254 | ret i64 %1 |
| 255 | } |
| 256 | |
| 257 | define i64 @lshr_i64_3(i64 %arg1, i32 %shift) { |
| 258 | %1 = zext i32 %shift to i64 |
| 259 | %2 = lshr i64 %arg1, %1 |
| 260 | ret i64 %2 |
| 261 | } |
| 262 | |
| 263 | ;; i64 shift right arithmetic (shift 1s from the right) |
| 264 | |
| 265 | define i64 @ashr_i64_1(i64 %arg) { |
| 266 | %1 = ashr i64 %arg, 9 |
| 267 | ret i64 %1 |
| 268 | } |
| 269 | |
| 270 | define i64 @ashr_i64_2(i64 %arg) { |
| 271 | %1 = ashr i64 %arg, 3 |
| 272 | ret i64 %1 |
| 273 | } |
| 274 | |
| 275 | define i64 @ashr_i64_3(i64 %arg1, i32 %shift) { |
| 276 | %1 = zext i32 %shift to i64 |
| 277 | %2 = ashr i64 %arg1, %1 |
| 278 | ret i64 %2 |
| 279 | } |