Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl  | FileCheck %s
      2 
      3 ; CHECK-LABEL: select00
      4 ; CHECK: vmovaps
      5 ; CHECK-NEXT: LBB
      6 define <16 x i32> @select00(i32 %a, <16 x i32> %b) nounwind {
      7   %cmpres = icmp eq i32 %a, 255
      8   %selres = select i1 %cmpres, <16 x i32> zeroinitializer, <16 x i32> %b
      9   %res = xor <16 x i32> %b, %selres
     10   ret <16 x i32> %res
     11 }
     12 
     13 ; CHECK-LABEL: select01
     14 ; CHECK: vmovaps
     15 ; CHECK-NEXT: LBB
     16 define <8 x i64> @select01(i32 %a, <8 x i64> %b) nounwind {
     17   %cmpres = icmp eq i32 %a, 255
     18   %selres = select i1 %cmpres, <8 x i64> zeroinitializer, <8 x i64> %b
     19   %res = xor <8 x i64> %b, %selres
     20   ret <8 x i64> %res
     21 }
     22 
     23 ; CHECK-LABEL: @select02
     24 ; CHECK: cmpless %xmm0, %xmm3, %k1
     25 ; CHECK-NEXT: vmovss  %xmm2, {{.*}}%xmm1 {%k1}
     26 ; CHECK: ret
     27 define float @select02(float %a, float %b, float %c, float %eps) {
     28   %cmp = fcmp oge float %a, %eps
     29   %cond = select i1 %cmp, float %c, float %b
     30   ret float %cond
     31 }
     32 
     33 ; CHECK-LABEL: @select03
     34 ; CHECK: cmplesd %xmm0, %xmm3, %k1
     35 ; CHECK-NEXT: vmovsd  %xmm2, {{.*}}%xmm1 {%k1}
     36 ; CHECK: ret
     37 define double @select03(double %a, double %b, double %c, double %eps) {
     38   %cmp = fcmp oge double %a, %eps
     39   %cond = select i1 %cmp, double %c, double %b
     40   ret double %cond
     41 }
     42 
     43 ; CHECK-LABEL: @select04
     44 ; CHECK: vmovaps %zmm3, %zmm1
     45 ; CHECK-NEXT: ret
     46 ; PR20677
     47 define <16 x double> @select04(<16 x double> %a, <16 x double> %b) {
     48   %sel = select <16 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <16 x double> %a, <16 x double> %b
     49   ret <16 x double> %sel
     50 }
     51 
     52 ; CHECK-LABEL: select05
     53 ; CHECK: movzbl  %sil, %eax
     54 ; CHECK: kmovw   %eax, %k0
     55 ; CHECK: movzbl  %dil, %eax
     56 ; CHECK: kmovw   %eax, %k1
     57 ; CHECK-NEXT: korw    %k1, %k0, %k0
     58 ; CHECK-NEXT: kmovw   %k0, %eax
     59 define i8 @select05(i8 %a.0, i8 %m) {
     60   %mask = bitcast i8 %m to <8 x i1>
     61   %a = bitcast i8 %a.0 to <8 x i1>
     62   %r = select <8 x i1> %mask, <8 x i1> <i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1>, <8 x i1> %a
     63   %res = bitcast <8 x i1> %r to i8
     64   ret i8 %res;
     65 }
     66 
     67 ; CHECK-LABEL: select06
     68 ; CHECK: movzbl  %sil, %eax
     69 ; CHECK: kmovw   %eax, %k0
     70 ; CHECK: movzbl  %dil, %eax
     71 ; CHECK: kmovw   %eax, %k1
     72 ; CHECK-NEXT: kandw    %k1, %k0, %k0
     73 ; CHECK-NEXT: kmovw   %k0, %eax
     74 define i8 @select06(i8 %a.0, i8 %m) {
     75   %mask = bitcast i8 %m to <8 x i1>
     76   %a = bitcast i8 %a.0 to <8 x i1>
     77   %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> zeroinitializer
     78   %res = bitcast <8 x i1> %r to i8
     79   ret i8 %res;
     80 }
     81 
     82 ; CHECK-LABEL: select07
     83 ; CHECK-DAG: movzbl  %dl, %eax
     84 ; CHECK-DAG: kmovw   %eax, %k0
     85 ; CHECK-DAG: movzbl  %dil, %eax
     86 ; CHECK-DAG: kmovw   %eax, %k1
     87 ; CHECK-DAG: movzbl  %sil, %eax
     88 ; CHECK-DAG: kmovw   %eax, %k2
     89 ; CHECK: kandw %k0, %k1, %k1
     90 ; CHECK-NEXT: knotw    %k0, %k0
     91 ; CHECK-NEXT: kandw    %k0, %k2, %k0
     92 ; CHECK-NEXT: korw %k0, %k1, %k0
     93 ; CHECK-NEXT: kmovw   %k0, %eax
     94 define i8 @select07(i8 %a.0, i8 %b.0, i8 %m) {
     95   %mask = bitcast i8 %m to <8 x i1>
     96   %a = bitcast i8 %a.0 to <8 x i1>
     97   %b = bitcast i8 %b.0 to <8 x i1>
     98   %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> %b
     99   %res = bitcast <8 x i1> %r to i8
    100   ret i8 %res;
    101 }
    102