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