1 ; RUN: llc < %s -march=cellspu | FileCheck %s 2 3 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" 4 target triple = "spu" 5 6 ; $3 = %arg1, $4 = %arg2, $5 = %val1, $6 = %val2 7 ; $3 = %arg1, $4 = %val1, $5 = %val2 8 ; 9 ; For "positive" comparisons: 10 ; selb $3, $6, $5, <i1> 11 ; selb $3, $5, $4, <i1> 12 ; 13 ; For "negative" comparisons, i.e., those where the result of the comparison 14 ; must be inverted (setne, for example): 15 ; selb $3, $5, $6, <i1> 16 ; selb $3, $4, $5, <i1> 17 18 ; i16 integer comparisons: 19 define i16 @icmp_eq_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 20 ; CHECK: icmp_eq_select_i16: 21 ; CHECK: ceqh 22 ; CHECK: selb $3, $6, $5, $3 23 24 entry: 25 %A = icmp eq i16 %arg1, %arg2 26 %B = select i1 %A, i16 %val1, i16 %val2 27 ret i16 %B 28 } 29 30 define i1 @icmp_eq_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 31 ; CHECK: icmp_eq_setcc_i16: 32 ; CHECK: ilhu 33 ; CHECK: ceqh 34 ; CHECK: iohl 35 ; CHECK: shufb 36 37 entry: 38 %A = icmp eq i16 %arg1, %arg2 39 ret i1 %A 40 } 41 42 define i16 @icmp_eq_immed01_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 43 ; CHECK: icmp_eq_immed01_i16: 44 ; CHECK: ceqhi 45 ; CHECK: selb $3, $5, $4, $3 46 47 entry: 48 %A = icmp eq i16 %arg1, 511 49 %B = select i1 %A, i16 %val1, i16 %val2 50 ret i16 %B 51 } 52 53 define i16 @icmp_eq_immed02_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 54 ; CHECK: icmp_eq_immed02_i16: 55 ; CHECK: ceqhi 56 ; CHECK: selb $3, $5, $4, $3 57 58 entry: 59 %A = icmp eq i16 %arg1, -512 60 %B = select i1 %A, i16 %val1, i16 %val2 61 ret i16 %B 62 } 63 64 define i16 @icmp_eq_immed03_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 65 ; CHECK: icmp_eq_immed03_i16: 66 ; CHECK: ceqhi 67 ; CHECK: selb $3, $5, $4, $3 68 69 entry: 70 %A = icmp eq i16 %arg1, -1 71 %B = select i1 %A, i16 %val1, i16 %val2 72 ret i16 %B 73 } 74 75 define i16 @icmp_eq_immed04_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 76 ; CHECK: icmp_eq_immed04_i16: 77 ; CHECK: ilh 78 ; CHECK: ceqh 79 ; CHECK: selb $3, $5, $4, $3 80 81 entry: 82 %A = icmp eq i16 %arg1, 32768 83 %B = select i1 %A, i16 %val1, i16 %val2 84 ret i16 %B 85 } 86 87 define i16 @icmp_ne_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 88 ; CHECK: icmp_ne_select_i16: 89 ; CHECK: ceqh 90 ; CHECK: selb $3, $5, $6, $3 91 92 entry: 93 %A = icmp ne i16 %arg1, %arg2 94 %B = select i1 %A, i16 %val1, i16 %val2 95 ret i16 %B 96 } 97 98 define i1 @icmp_ne_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 99 ; CHECK: icmp_ne_setcc_i16: 100 ; CHECK: ceqh 101 ; CHECK: ilhu 102 ; CHECK: xorhi 103 ; CHECK: iohl 104 ; CHECK: shufb 105 106 entry: 107 %A = icmp ne i16 %arg1, %arg2 108 ret i1 %A 109 } 110 111 define i16 @icmp_ne_immed01_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 112 ; CHECK: icmp_ne_immed01_i16: 113 ; CHECK: ceqhi 114 ; CHECK: selb $3, $4, $5, $3 115 116 entry: 117 %A = icmp ne i16 %arg1, 511 118 %B = select i1 %A, i16 %val1, i16 %val2 119 ret i16 %B 120 } 121 122 define i16 @icmp_ne_immed02_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 123 ; CHECK: icmp_ne_immed02_i16: 124 ; CHECK: ceqhi 125 ; CHECK: selb $3, $4, $5, $3 126 127 entry: 128 %A = icmp ne i16 %arg1, -512 129 %B = select i1 %A, i16 %val1, i16 %val2 130 ret i16 %B 131 } 132 133 define i16 @icmp_ne_immed03_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 134 ; CHECK: icmp_ne_immed03_i16: 135 ; CHECK: ceqhi 136 ; CHECK: selb $3, $4, $5, $3 137 138 entry: 139 %A = icmp ne i16 %arg1, -1 140 %B = select i1 %A, i16 %val1, i16 %val2 141 ret i16 %B 142 } 143 144 define i16 @icmp_ne_immed04_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 145 ; CHECK: icmp_ne_immed04_i16: 146 ; CHECK: ilh 147 ; CHECK: ceqh 148 ; CHECK: selb $3, $4, $5, $3 149 150 entry: 151 %A = icmp ne i16 %arg1, 32768 152 %B = select i1 %A, i16 %val1, i16 %val2 153 ret i16 %B 154 } 155 156 define i16 @icmp_ugt_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 157 ; CHECK: icmp_ugt_select_i16: 158 ; CHECK: clgth 159 ; CHECK: selb $3, $6, $5, $3 160 161 entry: 162 %A = icmp ugt i16 %arg1, %arg2 163 %B = select i1 %A, i16 %val1, i16 %val2 164 ret i16 %B 165 } 166 167 define i1 @icmp_ugt_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 168 ; CHECK: icmp_ugt_setcc_i16: 169 ; CHECK: ilhu 170 ; CHECK: clgth 171 ; CHECK: iohl 172 ; CHECK: shufb 173 174 entry: 175 %A = icmp ugt i16 %arg1, %arg2 176 ret i1 %A 177 } 178 179 define i16 @icmp_ugt_immed01_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 180 ; CHECK: icmp_ugt_immed01_i16: 181 ; CHECK: clgthi 182 ; CHECK: selb $3, $5, $4, $3 183 184 entry: 185 %A = icmp ugt i16 %arg1, 500 186 %B = select i1 %A, i16 %val1, i16 %val2 187 ret i16 %B 188 } 189 190 define i16 @icmp_ugt_immed02_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 191 ; CHECK: icmp_ugt_immed02_i16: 192 ; CHECK: ceqhi 193 ; CHECK: selb $3, $4, $5, $3 194 195 entry: 196 %A = icmp ugt i16 %arg1, 0 197 %B = select i1 %A, i16 %val1, i16 %val2 198 ret i16 %B 199 } 200 201 define i16 @icmp_ugt_immed03_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 202 ; CHECK: icmp_ugt_immed03_i16: 203 ; CHECK: clgthi 204 ; CHECK: selb $3, $5, $4, $3 205 206 entry: 207 %A = icmp ugt i16 %arg1, 65024 208 %B = select i1 %A, i16 %val1, i16 %val2 209 ret i16 %B 210 } 211 212 define i16 @icmp_ugt_immed04_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 213 ; CHECK: icmp_ugt_immed04_i16: 214 ; CHECK: ilh 215 ; CHECK: clgth 216 ; CHECK: selb $3, $5, $4, $3 217 218 entry: 219 %A = icmp ugt i16 %arg1, 32768 220 %B = select i1 %A, i16 %val1, i16 %val2 221 ret i16 %B 222 } 223 224 define i16 @icmp_uge_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 225 ; CHECK: icmp_uge_select_i16: 226 ; CHECK: ceqh 227 ; CHECK: clgth 228 ; CHECK: or 229 ; CHECK: selb $3, $6, $5, $3 230 231 entry: 232 %A = icmp uge i16 %arg1, %arg2 233 %B = select i1 %A, i16 %val1, i16 %val2 234 ret i16 %B 235 } 236 237 define i1 @icmp_uge_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 238 ; CHECK: icmp_uge_setcc_i16: 239 ; CHECK: ceqh 240 ; CHECK: clgth 241 ; CHECK: ilhu 242 ; CHECK: or 243 ; CHECK: iohl 244 ; CHECK: shufb 245 246 entry: 247 %A = icmp uge i16 %arg1, %arg2 248 ret i1 %A 249 } 250 251 ;; Note: icmp uge i16 %arg1, <immed> can always be transformed into 252 ;; icmp ugt i16 %arg1, <immed>-1 253 ;; 254 ;; Consequently, even though the patterns exist to match, it's unlikely 255 ;; they'll ever be generated. 256 257 define i16 @icmp_ult_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 258 ; CHECK: icmp_ult_select_i16: 259 ; CHECK: ceqh 260 ; CHECK: clgth 261 ; CHECK: nor 262 ; CHECK: selb $3, $6, $5, $3 263 264 entry: 265 %A = icmp ult i16 %arg1, %arg2 266 %B = select i1 %A, i16 %val1, i16 %val2 267 ret i16 %B 268 } 269 270 define i1 @icmp_ult_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 271 ; CHECK: icmp_ult_setcc_i16: 272 ; CHECK: ceqh 273 ; CHECK: clgth 274 ; CHECK: ilhu 275 ; CHECK: nor 276 ; CHECK: iohl 277 ; CHECK: shufb 278 279 entry: 280 %A = icmp ult i16 %arg1, %arg2 281 ret i1 %A 282 } 283 284 define i16 @icmp_ult_immed01_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 285 ; CHECK: icmp_ult_immed01_i16: 286 ; CHECK: ceqhi 287 ; CHECK: clgthi 288 ; CHECK: nor 289 ; CHECK: selb $3, $5, $4, $3 290 291 entry: 292 %A = icmp ult i16 %arg1, 511 293 %B = select i1 %A, i16 %val1, i16 %val2 294 ret i16 %B 295 } 296 297 define i16 @icmp_ult_immed02_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 298 ; CHECK: icmp_ult_immed02_i16: 299 ; CHECK: ceqhi 300 ; CHECK: clgthi 301 ; CHECK: nor 302 ; CHECK: selb $3, $5, $4, $3 303 304 entry: 305 %A = icmp ult i16 %arg1, 65534 306 %B = select i1 %A, i16 %val1, i16 %val2 307 ret i16 %B 308 } 309 310 define i16 @icmp_ult_immed03_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 311 ; CHECK: icmp_ult_immed03_i16: 312 ; CHECK: ceqhi 313 ; CHECK: clgthi 314 ; CHECK: nor 315 ; CHECK: selb $3, $5, $4, $3 316 317 entry: 318 %A = icmp ult i16 %arg1, 65024 319 %B = select i1 %A, i16 %val1, i16 %val2 320 ret i16 %B 321 } 322 323 define i16 @icmp_ult_immed04_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 324 ; CHECK: icmp_ult_immed04_i16: 325 ; CHECK: ilh 326 ; CHECK: ceqh 327 ; CHECK: clgth 328 ; CHECK: nor 329 ; CHECK: selb $3, $5, $4, $3 330 331 entry: 332 %A = icmp ult i16 %arg1, 32769 333 %B = select i1 %A, i16 %val1, i16 %val2 334 ret i16 %B 335 } 336 337 define i16 @icmp_ule_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 338 ; CHECK: icmp_ule_select_i16: 339 ; CHECK: clgth 340 ; CHECK: selb $3, $5, $6, $3 341 342 entry: 343 %A = icmp ule i16 %arg1, %arg2 344 %B = select i1 %A, i16 %val1, i16 %val2 345 ret i16 %B 346 } 347 348 define i1 @icmp_ule_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 349 ; CHECK: icmp_ule_setcc_i16: 350 ; CHECK: clgth 351 ; CHECK: ilhu 352 ; CHECK: xorhi 353 ; CHECK: iohl 354 ; CHECK: shufb 355 356 entry: 357 %A = icmp ule i16 %arg1, %arg2 358 ret i1 %A 359 } 360 361 ;; Note: icmp ule i16 %arg1, <immed> can always be transformed into 362 ;; icmp ult i16 %arg1, <immed>+1 363 ;; 364 ;; Consequently, even though the patterns exist to match, it's unlikely 365 ;; they'll ever be generated. 366 367 define i16 @icmp_sgt_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 368 ; CHECK: icmp_sgt_select_i16: 369 ; CHECK: cgth 370 ; CHECK: selb $3, $6, $5, $3 371 372 entry: 373 %A = icmp sgt i16 %arg1, %arg2 374 %B = select i1 %A, i16 %val1, i16 %val2 375 ret i16 %B 376 } 377 378 define i1 @icmp_sgt_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 379 ; CHECK: icmp_sgt_setcc_i16: 380 ; CHECK: ilhu 381 ; CHECK: cgth 382 ; CHECK: iohl 383 ; CHECK: shufb 384 385 entry: 386 %A = icmp sgt i16 %arg1, %arg2 387 ret i1 %A 388 } 389 390 define i16 @icmp_sgt_immed01_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 391 ; CHECK: icmp_sgt_immed01_i16: 392 ; CHECK: cgthi 393 ; CHECK: selb $3, $5, $4, $3 394 395 entry: 396 %A = icmp sgt i16 %arg1, 511 397 %B = select i1 %A, i16 %val1, i16 %val2 398 ret i16 %B 399 } 400 401 define i16 @icmp_sgt_immed02_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 402 ; CHECK: icmp_sgt_immed02_i16: 403 ; CHECK: cgthi 404 ; CHECK: selb $3, $5, $4, $3 405 406 entry: 407 %A = icmp sgt i16 %arg1, -1 408 %B = select i1 %A, i16 %val1, i16 %val2 409 ret i16 %B 410 } 411 412 define i16 @icmp_sgt_immed03_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 413 ; CHECK: icmp_sgt_immed03_i16: 414 ; CHECK: cgthi 415 ; CHECK: selb $3, $5, $4, $3 416 417 entry: 418 %A = icmp sgt i16 %arg1, -512 419 %B = select i1 %A, i16 %val1, i16 %val2 420 ret i16 %B 421 } 422 423 define i16 @icmp_sgt_immed04_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 424 ; CHECK: icmp_sgt_immed04_i16: 425 ; CHECK: ilh 426 ; CHECK: ceqh 427 ; CHECK: selb $3, $4, $5, $3 428 429 entry: 430 %A = icmp sgt i16 %arg1, 32768 431 %B = select i1 %A, i16 %val1, i16 %val2 432 ret i16 %B 433 } 434 435 define i16 @icmp_sge_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 436 ; CHECK: icmp_sge_select_i16: 437 ; CHECK: ceqh 438 ; CHECK: cgth 439 ; CHECK: or 440 ; CHECK: selb $3, $6, $5, $3 441 442 entry: 443 %A = icmp sge i16 %arg1, %arg2 444 %B = select i1 %A, i16 %val1, i16 %val2 445 ret i16 %B 446 } 447 448 define i1 @icmp_sge_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 449 ; CHECK: icmp_sge_setcc_i16: 450 ; CHECK: ceqh 451 ; CHECK: cgth 452 ; CHECK: ilhu 453 ; CHECK: or 454 ; CHECK: iohl 455 ; CHECK: shufb 456 457 entry: 458 %A = icmp sge i16 %arg1, %arg2 459 ret i1 %A 460 } 461 462 ;; Note: icmp sge i16 %arg1, <immed> can always be transformed into 463 ;; icmp sgt i16 %arg1, <immed>-1 464 ;; 465 ;; Consequently, even though the patterns exist to match, it's unlikely 466 ;; they'll ever be generated. 467 468 define i16 @icmp_slt_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 469 ; CHECK: icmp_slt_select_i16: 470 ; CHECK: ceqh 471 ; CHECK: cgth 472 ; CHECK: nor 473 ; CHECK: selb $3, $6, $5, $3 474 475 entry: 476 %A = icmp slt i16 %arg1, %arg2 477 %B = select i1 %A, i16 %val1, i16 %val2 478 ret i16 %B 479 } 480 481 define i1 @icmp_slt_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 482 ; CHECK: icmp_slt_setcc_i16: 483 ; CHECK: ceqh 484 ; CHECK: cgth 485 ; CHECK: ilhu 486 ; CHECK: nor 487 ; CHECK: iohl 488 ; CHECK: shufb 489 490 entry: 491 %A = icmp slt i16 %arg1, %arg2 492 ret i1 %A 493 } 494 495 define i16 @icmp_slt_immed01_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 496 ; CHECK: icmp_slt_immed01_i16: 497 ; CHECK: ceqhi 498 ; CHECK: cgthi 499 ; CHECK: nor 500 ; CHECK: selb $3, $5, $4, $3 501 502 entry: 503 %A = icmp slt i16 %arg1, 511 504 %B = select i1 %A, i16 %val1, i16 %val2 505 ret i16 %B 506 } 507 508 define i16 @icmp_slt_immed02_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 509 ; CHECK: icmp_slt_immed02_i16: 510 ; CHECK: ceqhi 511 ; CHECK: cgthi 512 ; CHECK: nor 513 ; CHECK: selb $3, $5, $4, $3 514 515 entry: 516 %A = icmp slt i16 %arg1, -512 517 %B = select i1 %A, i16 %val1, i16 %val2 518 ret i16 %B 519 } 520 521 define i16 @icmp_slt_immed03_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 522 ; CHECK: icmp_slt_immed03_i16: 523 ; CHECK: ceqhi 524 ; CHECK: cgthi 525 ; CHECK: nor 526 ; CHECK: selb $3, $5, $4, $3 527 528 entry: 529 %A = icmp slt i16 %arg1, -1 530 %B = select i1 %A, i16 %val1, i16 %val2 531 ret i16 %B 532 } 533 534 define i16 @icmp_slt_immed04_i16(i16 %arg1, i16 %val1, i16 %val2) nounwind { 535 ; CHECK: icmp_slt_immed04_i16: 536 ; CHECK: lr 537 ; CHECK-NETX: bi 538 539 entry: 540 %A = icmp slt i16 %arg1, 32768 541 %B = select i1 %A, i16 %val1, i16 %val2 542 ret i16 %B 543 } 544 545 define i16 @icmp_sle_select_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 546 ; CHECK: icmp_sle_select_i16: 547 ; CHECK: cgth 548 ; CHECK: selb $3, $5, $6, $3 549 550 entry: 551 %A = icmp sle i16 %arg1, %arg2 552 %B = select i1 %A, i16 %val1, i16 %val2 553 ret i16 %B 554 } 555 556 define i1 @icmp_sle_setcc_i16(i16 %arg1, i16 %arg2, i16 %val1, i16 %val2) nounwind { 557 ; CHECK: icmp_sle_setcc_i16: 558 ; CHECK: cgth 559 ; CHECK: ilhu 560 ; CHECK: xorhi 561 ; CHECK: iohl 562 ; CHECK-NETX: bi 563 564 entry: 565 %A = icmp sle i16 %arg1, %arg2 566 ret i1 %A 567 } 568 569 ;; Note: icmp sle i16 %arg1, <immed> can always be transformed into 570 ;; icmp slt i16 %arg1, <immed>+1 571 ;; 572 ;; Consequently, even though the patterns exist to match, it's unlikely 573 ;; they'll ever be generated. 574 575