Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s
      2 
      3 ; Check that we generate vector conversion from float to narrower int types
      4 
      5 %f32vec_t = type <8 x float>
      6 %i16vec_t = type <8 x i16>
      7 %i8vec_t =  type <8 x i8>
      8 
      9 define void @fptoui16(%f32vec_t %a, %i16vec_t *%p) {
     10 ; CHECK-LABEL: fptoui16:
     11 ; CHECK:       # BB#0:
     12 ; CHECK-NEXT:    vcvttps2dq %ymm0, %ymm0
     13 ; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
     14 ; CHECK-NEXT:    vmovdqa {{.*#+}} xmm2 = [0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
     15 ; CHECK-NEXT:    vpshufb %xmm2, %xmm1, %xmm1
     16 ; CHECK-NEXT:    vpshufb %xmm2, %xmm0, %xmm0
     17 ; CHECK-NEXT:    vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
     18 ; CHECK-NEXT:    vmovdqa %xmm0, (%rdi)
     19 ; CHECK-NEXT:    vzeroupper
     20 ; CHECK-NEXT:    retq
     21   %b = fptoui %f32vec_t %a to %i16vec_t
     22   store %i16vec_t %b, %i16vec_t * %p
     23   ret void
     24 }
     25 
     26 define void @fptosi16(%f32vec_t %a, %i16vec_t *%p) {
     27 ; CHECK-LABEL: fptosi16:
     28 ; CHECK:       # BB#0:
     29 ; CHECK-NEXT:    vcvttps2dq %ymm0, %ymm0
     30 ; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
     31 ; CHECK-NEXT:    vmovdqa {{.*#+}} xmm2 = [0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
     32 ; CHECK-NEXT:    vpshufb %xmm2, %xmm1, %xmm1
     33 ; CHECK-NEXT:    vpshufb %xmm2, %xmm0, %xmm0
     34 ; CHECK-NEXT:    vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
     35 ; CHECK-NEXT:    vmovdqa %xmm0, (%rdi)
     36 ; CHECK-NEXT:    vzeroupper
     37 ; CHECK-NEXT:    retq
     38   %b = fptosi %f32vec_t %a to %i16vec_t
     39   store %i16vec_t %b, %i16vec_t * %p
     40   ret void
     41 }
     42 
     43 define void @fptoui8(%f32vec_t %a, %i8vec_t *%p) {
     44 ; CHECK-LABEL: fptoui8:
     45 ; CHECK:       # BB#0:
     46 ; CHECK-NEXT:    vcvttps2dq %ymm0, %ymm0
     47 ; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
     48 ; CHECK-NEXT:    vmovdqa {{.*#+}} xmm2 = [0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
     49 ; CHECK-NEXT:    vpshufb %xmm2, %xmm1, %xmm1
     50 ; CHECK-NEXT:    vpshufb %xmm2, %xmm0, %xmm0
     51 ; CHECK-NEXT:    vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
     52 ; CHECK-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
     53 ; CHECK-NEXT:    vmovq %xmm0, (%rdi)
     54 ; CHECK-NEXT:    vzeroupper
     55 ; CHECK-NEXT:    retq
     56   %b = fptoui %f32vec_t %a to %i8vec_t
     57   store %i8vec_t %b, %i8vec_t * %p
     58   ret void
     59 }
     60 
     61 define void @fptosi8(%f32vec_t %a, %i8vec_t *%p) {
     62 ; CHECK-LABEL: fptosi8:
     63 ; CHECK:       # BB#0:
     64 ; CHECK-NEXT:    vcvttps2dq %ymm0, %ymm0
     65 ; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm1
     66 ; CHECK-NEXT:    vmovdqa {{.*#+}} xmm2 = [0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15]
     67 ; CHECK-NEXT:    vpshufb %xmm2, %xmm1, %xmm1
     68 ; CHECK-NEXT:    vpshufb %xmm2, %xmm0, %xmm0
     69 ; CHECK-NEXT:    vpunpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
     70 ; CHECK-NEXT:    vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
     71 ; CHECK-NEXT:    vmovq %xmm0, (%rdi)
     72 ; CHECK-NEXT:    vzeroupper
     73 ; CHECK-NEXT:    retq
     74   %b = fptosi %f32vec_t %a to %i8vec_t
     75   store %i8vec_t %b, %i8vec_t * %p
     76   ret void
     77 }
     78