Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s
      3 
      4 define <4 x i32> @test1(<4 x float> %a, <4 x float> %b, <4 x i32> %c) {
      5 ; CHECK-LABEL: test1:
      6 ; CHECK:       # %bb.0:
      7 ; CHECK-NEXT:    vcmpnleps %xmm0, %xmm1, %xmm0
      8 ; CHECK-NEXT:    vandps %xmm2, %xmm0, %xmm0
      9 ; CHECK-NEXT:    retq
     10   %f = fcmp ult <4 x float> %a, %b
     11   %r = select <4 x i1> %f, <4 x i32> %c, <4 x i32> zeroinitializer
     12   ret <4 x i32> %r
     13 }
     14 
     15 define <4 x i32> @test2(<4 x float> %a, <4 x float> %b, <4 x i32> %c) {
     16 ; CHECK-LABEL: test2:
     17 ; CHECK:       # %bb.0:
     18 ; CHECK-NEXT:    vcmpnleps %xmm0, %xmm1, %xmm0
     19 ; CHECK-NEXT:    vorps %xmm2, %xmm0, %xmm0
     20 ; CHECK-NEXT:    retq
     21   %f = fcmp ult <4 x float> %a, %b
     22   %r = select <4 x i1> %f, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %c
     23   ret <4 x i32> %r
     24 }
     25 
     26 define <4 x i32> @test3(<4 x float> %a, <4 x float> %b, <4 x i32> %c) {
     27 ; CHECK-LABEL: test3:
     28 ; CHECK:       # %bb.0:
     29 ; CHECK-NEXT:    vcmpleps %xmm0, %xmm1, %xmm0
     30 ; CHECK-NEXT:    vandps %xmm2, %xmm0, %xmm0
     31 ; CHECK-NEXT:    retq
     32   %f = fcmp ult <4 x float> %a, %b
     33   %r = select <4 x i1> %f, <4 x i32> zeroinitializer, <4 x i32> %c
     34   ret <4 x i32> %r
     35 }
     36 
     37 define <4 x i32> @test4(<4 x float> %a, <4 x float> %b, <4 x i32> %c) {
     38 ; CHECK-LABEL: test4:
     39 ; CHECK:       # %bb.0:
     40 ; CHECK-NEXT:    vcmpleps %xmm0, %xmm1, %xmm0
     41 ; CHECK-NEXT:    vorps %xmm2, %xmm0, %xmm0
     42 ; CHECK-NEXT:    retq
     43   %f = fcmp ult <4 x float> %a, %b
     44   %r = select <4 x i1> %f, <4 x i32> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
     45   ret <4 x i32> %r
     46 }
     47 
     48 define <4 x i32> @test5(<4 x float> %a, <4 x float> %b, <4 x i32> %c) {
     49 ; CHECK-LABEL: test5:
     50 ; CHECK:       # %bb.0:
     51 ; CHECK-NEXT:    vcmpnleps %xmm0, %xmm1, %xmm0
     52 ; CHECK-NEXT:    retq
     53   %f = fcmp ult <4 x float> %a, %b
     54   %r = sext <4 x i1> %f to <4 x i32>
     55   ret <4 x i32> %r
     56 }
     57 
     58 define <4 x i32> @test6(<4 x float> %a, <4 x float> %b, <4 x i32> %c) {
     59 ; CHECK-LABEL: test6:
     60 ; CHECK:       # %bb.0:
     61 ; CHECK-NEXT:    vcmpleps %xmm0, %xmm1, %xmm0
     62 ; CHECK-NEXT:    retq
     63   %not.f = fcmp oge <4 x float> %a, %b
     64   %r = sext <4 x i1> %not.f to <4 x i32>
     65   ret <4 x i32> %r
     66 }
     67 
     68 define <4 x i32> @test7(<4 x float> %a, <4 x float> %b, <4 x i32>* %p) {
     69 ; CHECK-LABEL: test7:
     70 ; CHECK:       # %bb.0:
     71 ; CHECK-NEXT:    vcmpnleps %xmm0, %xmm1, %xmm0
     72 ; CHECK-NEXT:    vandps (%rdi), %xmm0, %xmm0
     73 ; CHECK-NEXT:    retq
     74   %f = fcmp ult <4 x float> %a, %b
     75   %l = load <4 x i32>, <4 x i32>* %p, align 16
     76   %r = select <4 x i1> %f, <4 x i32> %l, <4 x i32> zeroinitializer
     77   ret <4 x i32> %r
     78 }
     79 
     80 ; Repeat all with FP types for the select operands. Also, use different comparison predicates for better test coverage.
     81 
     82 define <2 x double> @test1f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
     83 ; CHECK-LABEL: test1f:
     84 ; CHECK:       # %bb.0:
     85 ; CHECK-NEXT:    vcmpltpd %xmm0, %xmm1, %xmm0
     86 ; CHECK-NEXT:    vandpd %xmm2, %xmm0, %xmm0
     87 ; CHECK-NEXT:    retq
     88   %f = fcmp ogt <2 x double> %a, %b
     89   %r = select <2 x i1> %f, <2 x double> %c, <2 x double> zeroinitializer
     90   ret <2 x double> %r
     91 }
     92 
     93 define <2 x double> @test2f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
     94 ; CHECK-LABEL: test2f:
     95 ; CHECK:       # %bb.0:
     96 ; CHECK-NEXT:    vcmplepd %xmm0, %xmm1, %xmm0
     97 ; CHECK-NEXT:    vorpd %xmm2, %xmm0, %xmm0
     98 ; CHECK-NEXT:    retq
     99   %f = fcmp oge <2 x double> %a, %b
    100   %r = select <2 x i1> %f, <2 x double> <double 0xffffffffffffffff, double 0xffffffffffffffff>, <2 x double> %c
    101   ret <2 x double> %r
    102 }
    103 
    104 define <2 x double> @test3f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
    105 ; CHECK-LABEL: test3f:
    106 ; CHECK:       # %bb.0:
    107 ; CHECK-NEXT:    vcmpnltpd %xmm1, %xmm0, %xmm0
    108 ; CHECK-NEXT:    vandpd %xmm2, %xmm0, %xmm0
    109 ; CHECK-NEXT:    retq
    110   %f = fcmp olt <2 x double> %a, %b
    111   %r = select <2 x i1> %f, <2 x double> zeroinitializer, <2 x double> %c
    112   ret <2 x double> %r
    113 }
    114 
    115 define <2 x double> @test4f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
    116 ; CHECK-LABEL: test4f:
    117 ; CHECK:       # %bb.0:
    118 ; CHECK-NEXT:    vcmpnlepd %xmm1, %xmm0, %xmm0
    119 ; CHECK-NEXT:    vorpd %xmm2, %xmm0, %xmm0
    120 ; CHECK-NEXT:    retq
    121   %f = fcmp ole <2 x double> %a, %b
    122   %r = select <2 x i1> %f, <2 x double> %c, <2 x double> <double 0xffffffffffffffff, double 0xffffffffffffffff>
    123   ret <2 x double> %r
    124 }
    125 
    126 define <2 x double> @test5f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
    127 ; CHECK-LABEL: test5f:
    128 ; CHECK:       # %bb.0:
    129 ; CHECK-NEXT:    vcmpnlepd %xmm1, %xmm0, %xmm0
    130 ; CHECK-NEXT:    retq
    131   %f = fcmp ugt <2 x double> %a, %b
    132   %r = select <2 x i1> %f, <2 x double> <double 0xffffffffffffffff, double 0xffffffffffffffff>, <2 x double> zeroinitializer
    133   ret <2 x double> %r
    134 }
    135 
    136 define <2 x double> @test6f(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
    137 ; CHECK-LABEL: test6f:
    138 ; CHECK:       # %bb.0:
    139 ; CHECK-NEXT:    vcmpltpd %xmm0, %xmm1, %xmm0
    140 ; CHECK-NEXT:    retq
    141   %f = fcmp ule <2 x double> %a, %b
    142   %r = select <2 x i1> %f, <2 x double> zeroinitializer, <2 x double> <double 0xffffffffffffffff, double 0xffffffffffffffff>
    143   ret <2 x double> %r
    144 }
    145 
    146 define <2 x double> @test7f(<2 x double> %a, <2 x double> %b, <2 x double>* %p) {
    147 ; CHECK-LABEL: test7f:
    148 ; CHECK:       # %bb.0:
    149 ; CHECK-NEXT:    vcmpeqpd %xmm1, %xmm0, %xmm0
    150 ; CHECK-NEXT:    vandpd (%rdi), %xmm0, %xmm0
    151 ; CHECK-NEXT:    retq
    152   %f = fcmp oeq <2 x double> %a, %b
    153   %l = load <2 x double>, <2 x double>* %p, align 16
    154   %r = select <2 x i1> %f, <2 x double> %l, <2 x double> zeroinitializer
    155   ret <2 x double> %r
    156 }
    157 
    158