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