Home | History | Annotate | Download | only in CellSPU
      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 ; i8 integer comparisons:
     19 define i8 @icmp_eq_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
     20 ; CHECK:      icmp_eq_select_i8:
     21 ; CHECK:        ceqb
     22 ; CHECK:        selb $3, $6, $5, $3
     23 
     24 entry:
     25        %A = icmp eq i8 %arg1, %arg2
     26        %B = select i1 %A, i8 %val1, i8 %val2
     27        ret i8 %B
     28 }
     29 
     30 define i1 @icmp_eq_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
     31 ; CHECK:      icmp_eq_setcc_i8:
     32 ; CHECK:        ceqb
     33 ; CHECK-NEXT:   bi
     34 
     35 entry:
     36        %A = icmp eq i8 %arg1, %arg2
     37        ret i1 %A
     38 }
     39 
     40 define i8 @icmp_eq_immed01_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
     41 ; CHECK:      icmp_eq_immed01_i8:
     42 ; CHECK:        ceqbi
     43 ; CHECK:        selb $3, $5, $4, $3
     44 
     45 entry:
     46        %A = icmp eq i8 %arg1, 127
     47        %B = select i1 %A, i8 %val1, i8 %val2
     48        ret i8 %B
     49 }
     50 
     51 define i8 @icmp_eq_immed02_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
     52 ; CHECK:      icmp_eq_immed02_i8:
     53 ; CHECK:        ceqbi
     54 ; CHECK:        selb $3, $5, $4, $3
     55 
     56 entry:
     57        %A = icmp eq i8 %arg1, -128
     58        %B = select i1 %A, i8 %val1, i8 %val2
     59        ret i8 %B
     60 }
     61 
     62 define i8 @icmp_eq_immed03_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
     63 ; CHECK:      icmp_eq_immed03_i8:
     64 ; CHECK:        ceqbi
     65 ; CHECK:        selb $3, $5, $4, $3
     66 
     67 entry:
     68        %A = icmp eq i8 %arg1, -1
     69        %B = select i1 %A, i8 %val1, i8 %val2
     70        ret i8 %B
     71 }
     72 
     73 define i8 @icmp_ne_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
     74 ; CHECK:      icmp_ne_select_i8:
     75 ; CHECK:        ceqb
     76 ; CHECK:        selb $3, $5, $6, $3
     77 
     78 entry:
     79        %A = icmp ne i8 %arg1, %arg2
     80        %B = select i1 %A, i8 %val1, i8 %val2
     81        ret i8 %B
     82 }
     83 
     84 define i1 @icmp_ne_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
     85 ; CHECK:      icmp_ne_setcc_i8:
     86 ; CHECK:        ceqb
     87 ; CHECK:        xorbi
     88 ; CHECK-NEXT:   bi
     89 
     90 entry:
     91        %A = icmp ne i8 %arg1, %arg2
     92        ret i1 %A
     93 }
     94 
     95 define i8 @icmp_ne_immed01_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
     96 ; CHECK:      icmp_ne_immed01_i8:
     97 ; CHECK:        ceqbi
     98 ; CHECK:        selb $3, $4, $5, $3
     99 
    100 entry:
    101        %A = icmp ne i8 %arg1, 127
    102        %B = select i1 %A, i8 %val1, i8 %val2
    103        ret i8 %B
    104 }
    105 
    106 define i8 @icmp_ne_immed02_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    107 ; CHECK:      icmp_ne_immed02_i8:
    108 ; CHECK:        ceqbi
    109 ; CHECK:        selb $3, $4, $5, $3
    110 
    111 entry:
    112        %A = icmp ne i8 %arg1, -128
    113        %B = select i1 %A, i8 %val1, i8 %val2
    114        ret i8 %B
    115 }
    116 
    117 define i8 @icmp_ne_immed03_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    118 ; CHECK:      icmp_ne_immed03_i8:
    119 ; CHECK:        ceqbi
    120 ; CHECK:        selb $3, $4, $5, $3
    121 
    122 entry:
    123        %A = icmp ne i8 %arg1, -1
    124        %B = select i1 %A, i8 %val1, i8 %val2
    125        ret i8 %B
    126 }
    127 
    128 define i8 @icmp_ugt_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    129 ; CHECK:      icmp_ugt_select_i8:
    130 ; CHECK:        clgtb
    131 ; CHECK:        selb $3, $6, $5, $3
    132 
    133 entry:
    134        %A = icmp ugt i8 %arg1, %arg2
    135        %B = select i1 %A, i8 %val1, i8 %val2
    136        ret i8 %B
    137 }
    138 
    139 define i1 @icmp_ugt_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    140 ; CHECK:      icmp_ugt_setcc_i8:
    141 ; CHECK:        clgtb
    142 ; CHECK-NEXT:   bi
    143 
    144 entry:
    145        %A = icmp ugt i8 %arg1, %arg2
    146        ret i1 %A
    147 }
    148 
    149 define i8 @icmp_ugt_immed01_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    150 ; CHECK:      icmp_ugt_immed01_i8:
    151 ; CHECK:        clgtbi
    152 ; CHECK:        selb $3, $5, $4, $3
    153 
    154 entry:
    155        %A = icmp ugt i8 %arg1, 126
    156        %B = select i1 %A, i8 %val1, i8 %val2
    157        ret i8 %B
    158 }
    159 
    160 define i8 @icmp_uge_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    161 ; CHECK:      icmp_uge_select_i8:
    162 ; CHECK:        ceqb
    163 ; CHECK:        clgtb
    164 ; CHECK:        or
    165 ; CHECK:        selb $3, $6, $5, $3
    166 
    167 entry:
    168        %A = icmp uge i8 %arg1, %arg2
    169        %B = select i1 %A, i8 %val1, i8 %val2
    170        ret i8 %B
    171 }
    172 
    173 define i1 @icmp_uge_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    174 ; CHECK:      icmp_uge_setcc_i8:
    175 ; CHECK:        ceqb
    176 ; CHECK:        clgtb
    177 ; CHECK:        or
    178 ; CHECK-NEXT:   bi
    179 
    180 entry:
    181        %A = icmp uge i8 %arg1, %arg2
    182        ret i1 %A
    183 }
    184 
    185 ;; Note: icmp uge i8 %arg1, <immed> can always be transformed into
    186 ;;       icmp ugt i8 %arg1, <immed>-1
    187 ;;
    188 ;; Consequently, even though the patterns exist to match, it's unlikely
    189 ;; they'll ever be generated.
    190 
    191 define i8 @icmp_ult_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    192 ; CHECK:      icmp_ult_select_i8:
    193 ; CHECK:        ceqb
    194 ; CHECK:        clgtb
    195 ; CHECK:        nor
    196 ; CHECK:        selb $3, $6, $5, $3
    197 
    198 entry:
    199        %A = icmp ult i8 %arg1, %arg2
    200        %B = select i1 %A, i8 %val1, i8 %val2
    201        ret i8 %B
    202 }
    203 
    204 define i1 @icmp_ult_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    205 ; CHECK:      icmp_ult_setcc_i8:
    206 ; CHECK:        ceqb
    207 ; CHECK:        clgtb
    208 ; CHECK:        nor
    209 ; CHECK-NEXT:   bi
    210 
    211 entry:
    212        %A = icmp ult i8 %arg1, %arg2
    213        ret i1 %A
    214 }
    215 
    216 define i8 @icmp_ult_immed01_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    217 ; CHECK:      icmp_ult_immed01_i8:
    218 ; CHECK:        ceqbi
    219 ; CHECK:        clgtbi
    220 ; CHECK:        nor
    221 ; CHECK:        selb $3, $5, $4, $3
    222 
    223 entry:
    224        %A = icmp ult i8 %arg1, 253
    225        %B = select i1 %A, i8 %val1, i8 %val2
    226        ret i8 %B
    227 }
    228 
    229 define i8 @icmp_ult_immed02_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    230 ; CHECK:      icmp_ult_immed02_i8:
    231 ; CHECK:        ceqbi
    232 ; CHECK:        clgtbi
    233 ; CHECK:        nor
    234 ; CHECK:        selb $3, $5, $4, $3
    235 
    236 entry:
    237        %A = icmp ult i8 %arg1, 129
    238        %B = select i1 %A, i8 %val1, i8 %val2
    239        ret i8 %B
    240 }
    241 
    242 define i8 @icmp_ule_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    243 ; CHECK:      icmp_ule_select_i8:
    244 ; CHECK:        clgtb
    245 ; CHECK:        selb $3, $5, $6, $3
    246 
    247 entry:
    248        %A = icmp ule i8 %arg1, %arg2
    249        %B = select i1 %A, i8 %val1, i8 %val2
    250        ret i8 %B
    251 }
    252 
    253 define i1 @icmp_ule_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    254 ; CHECK:      icmp_ule_setcc_i8:
    255 ; CHECK:        clgtb
    256 ; CHECK:        xorbi
    257 ; CHECK-NEXT:   bi
    258 
    259 entry:
    260        %A = icmp ule i8 %arg1, %arg2
    261        ret i1 %A
    262 }
    263 
    264 ;; Note: icmp ule i8 %arg1, <immed> can always be transformed into
    265 ;;       icmp ult i8 %arg1, <immed>+1
    266 ;;
    267 ;; Consequently, even though the patterns exist to match, it's unlikely
    268 ;; they'll ever be generated.
    269 
    270 define i8 @icmp_sgt_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    271 ; CHECK:      icmp_sgt_select_i8:
    272 ; CHECK:        cgtb
    273 ; CHECK:        selb $3, $6, $5, $3
    274 
    275 entry:
    276        %A = icmp sgt i8 %arg1, %arg2
    277        %B = select i1 %A, i8 %val1, i8 %val2
    278        ret i8 %B
    279 }
    280 
    281 define i1 @icmp_sgt_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    282 ; CHECK:      icmp_sgt_setcc_i8:
    283 ; CHECK:        cgtb
    284 ; CHECK-NEXT:   bi
    285 
    286 entry:
    287        %A = icmp sgt i8 %arg1, %arg2
    288        ret i1 %A
    289 }
    290 
    291 define i8 @icmp_sgt_immed01_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    292 ; CHECK:      icmp_sgt_immed01_i8:
    293 ; CHECK:        cgtbi
    294 ; CHECK:        selb $3, $5, $4, $3
    295 
    296 entry:
    297        %A = icmp sgt i8 %arg1, 96
    298        %B = select i1 %A, i8 %val1, i8 %val2
    299        ret i8 %B
    300 }
    301 
    302 define i8 @icmp_sgt_immed02_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    303 ; CHECK:      icmp_sgt_immed02_i8:
    304 ; CHECK:        cgtbi
    305 ; CHECK:        selb $3, $5, $4, $3
    306 
    307 entry:
    308        %A = icmp sgt i8 %arg1, -1
    309        %B = select i1 %A, i8 %val1, i8 %val2
    310        ret i8 %B
    311 }
    312 
    313 define i8 @icmp_sgt_immed03_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    314 ; CHECK:      icmp_sgt_immed03_i8:
    315 ; CHECK:        ceqbi
    316 ; CHECK:        selb $3, $4, $5, $3
    317 
    318 entry:
    319        %A = icmp sgt i8 %arg1, -128
    320        %B = select i1 %A, i8 %val1, i8 %val2
    321        ret i8 %B
    322 }
    323 
    324 define i8 @icmp_sge_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    325 ; CHECK:      icmp_sge_select_i8:
    326 ; CHECK:        ceqb
    327 ; CHECK:        cgtb
    328 ; CHECK:        or
    329 ; CHECK:        selb $3, $6, $5, $3
    330 
    331 entry:
    332        %A = icmp sge i8 %arg1, %arg2
    333        %B = select i1 %A, i8 %val1, i8 %val2
    334        ret i8 %B
    335 }
    336 
    337 define i1 @icmp_sge_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    338 ; CHECK:      icmp_sge_setcc_i8:
    339 ; CHECK:        ceqb
    340 ; CHECK:        cgtb
    341 ; CHECK:        or
    342 ; CHECK-NEXT:   bi
    343 
    344 entry:
    345        %A = icmp sge i8 %arg1, %arg2
    346        ret i1 %A
    347 }
    348 
    349 ;; Note: icmp sge i8 %arg1, <immed> can always be transformed into
    350 ;;       icmp sgt i8 %arg1, <immed>-1
    351 ;;
    352 ;; Consequently, even though the patterns exist to match, it's unlikely
    353 ;; they'll ever be generated.
    354 
    355 define i8 @icmp_slt_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    356 ; CHECK:      icmp_slt_select_i8:
    357 ; CHECK:        ceqb
    358 ; CHECK:        cgtb
    359 ; CHECK:        nor
    360 ; CHECK:        selb $3, $6, $5, $3
    361 
    362 entry:
    363        %A = icmp slt i8 %arg1, %arg2
    364        %B = select i1 %A, i8 %val1, i8 %val2
    365        ret i8 %B
    366 }
    367 
    368 define i1 @icmp_slt_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    369 ; CHECK:      icmp_slt_setcc_i8:
    370 ; CHECK:        ceqb
    371 ; CHECK:        cgtb
    372 ; CHECK:        nor
    373 ; CHECK-NEXT:   bi
    374 
    375 entry:
    376        %A = icmp slt i8 %arg1, %arg2
    377        ret i1 %A
    378 }
    379 
    380 define i8 @icmp_slt_immed01_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    381 ; CHECK:      icmp_slt_immed01_i8:
    382 ; CHECK:        ceqbi
    383 ; CHECK:        cgtbi
    384 ; CHECK:        nor
    385 ; CHECK:        selb $3, $5, $4, $3
    386 
    387 entry:
    388        %A = icmp slt i8 %arg1, 96
    389        %B = select i1 %A, i8 %val1, i8 %val2
    390        ret i8 %B
    391 }
    392 
    393 define i8 @icmp_slt_immed02_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    394 ; CHECK:      icmp_slt_immed02_i8:
    395 ; CHECK:        ceqbi
    396 ; CHECK:        cgtbi
    397 ; CHECK:        nor
    398 ; CHECK:        selb $3, $5, $4, $3
    399 
    400 entry:
    401        %A = icmp slt i8 %arg1, -120
    402        %B = select i1 %A, i8 %val1, i8 %val2
    403        ret i8 %B
    404 }
    405 
    406 define i8 @icmp_slt_immed03_i8(i8 %arg1, i8 %val1, i8 %val2) nounwind {
    407 ; CHECK:      icmp_slt_immed03_i8:
    408 ; CHECK:        ceqbi
    409 ; CHECK:        cgtbi
    410 ; CHECK:        nor
    411 ; CHECK:        selb $3, $5, $4, $3
    412 
    413 entry:
    414        %A = icmp slt i8 %arg1, -1
    415        %B = select i1 %A, i8 %val1, i8 %val2
    416        ret i8 %B
    417 }
    418 
    419 define i8 @icmp_sle_select_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    420 ; CHECK:      icmp_sle_select_i8:
    421 ; CHECK:        cgtb
    422 ; CHECK:        selb $3, $5, $6, $3
    423 
    424 entry:
    425        %A = icmp sle i8 %arg1, %arg2
    426        %B = select i1 %A, i8 %val1, i8 %val2
    427        ret i8 %B
    428 }
    429 
    430 define i1 @icmp_sle_setcc_i8(i8 %arg1, i8 %arg2, i8 %val1, i8 %val2) nounwind {
    431 ; CHECK:      icmp_sle_setcc_i8:
    432 ; CHECK:        cgtb
    433 ; CHECK:        xorbi
    434 ; CHECK-NEXT:   bi
    435 
    436 entry:
    437        %A = icmp sle i8 %arg1, %arg2
    438        ret i1 %A
    439 }
    440 
    441 ;; Note: icmp sle i8 %arg1, <immed> can always be transformed into
    442 ;;       icmp slt i8 %arg1, <immed>+1
    443 ;;
    444 ;; Consequently, even though the patterns exist to match, it's unlikely
    445 ;; they'll ever be generated.
    446 
    447