Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s
      2 
      3 define <8 x float> @sitofp00(<8 x i32> %a) nounwind {
      4 ; CHECK-LABEL: sitofp00:
      5 ; CHECK:       # BB#0:
      6 ; CHECK-NEXT:    vcvtdq2ps %ymm0, %ymm0
      7 ; CHECK-NEXT:    retq
      8   %b = sitofp <8 x i32> %a to <8 x float>
      9   ret <8 x float> %b
     10 }
     11 
     12 define <8 x i32> @fptosi00(<8 x float> %a) nounwind {
     13 ; CHECK-LABEL: fptosi00:
     14 ; CHECK:       # BB#0:
     15 ; CHECK-NEXT:    vcvttps2dq %ymm0, %ymm0
     16 ; CHECK-NEXT:    retq
     17   %b = fptosi <8 x float> %a to <8 x i32>
     18   ret <8 x i32> %b
     19 }
     20 
     21 define <4 x double> @sitofp01(<4 x i32> %a) {
     22 ; CHECK-LABEL: sitofp01:
     23 ; CHECK:       # BB#0:
     24 ; CHECK-NEXT:    vcvtdq2pd %xmm0, %ymm0
     25 ; CHECK-NEXT:    retq
     26   %b = sitofp <4 x i32> %a to <4 x double>
     27   ret <4 x double> %b
     28 }
     29 
     30 define <8 x float> @sitofp02(<8 x i16> %a) {
     31 ; CHECK-LABEL: sitofp02:
     32 ; CHECK:       # BB#0:
     33 ; CHECK-NEXT:    vpmovsxwd %xmm0, %xmm1
     34 ; CHECK-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
     35 ; CHECK-NEXT:    vpmovsxwd %xmm0, %xmm0
     36 ; CHECK-NEXT:    vinsertf128 $1, %xmm0, %ymm1, %ymm0
     37 ; CHECK-NEXT:    vcvtdq2ps %ymm0, %ymm0
     38 ; CHECK-NEXT:    retq
     39   %b = sitofp <8 x i16> %a to <8 x float>
     40   ret <8 x float> %b
     41 }
     42 
     43 define <4 x i32> @fptosi01(<4 x double> %a) {
     44 ; CHECK-LABEL: fptosi01:
     45 ; CHECK:       # BB#0:
     46 ; CHECK-NEXT:    vcvttpd2dqy %ymm0, %xmm0
     47 ; CHECK-NEXT:    vzeroupper
     48 ; CHECK-NEXT:    retq
     49   %b = fptosi <4 x double> %a to <4 x i32>
     50   ret <4 x i32> %b
     51 }
     52 
     53 define <8 x float> @fptrunc00(<8 x double> %b) nounwind {
     54 ; CHECK-LABEL: fptrunc00:
     55 ; CHECK:       # BB#0:
     56 ; CHECK-NEXT:    vcvtpd2psy %ymm0, %xmm0
     57 ; CHECK-NEXT:    vcvtpd2psy %ymm1, %xmm1
     58 ; CHECK-NEXT:    vinsertf128 $1, %xmm1, %ymm0, %ymm0
     59 ; CHECK-NEXT:    retq
     60   %a = fptrunc <8 x double> %b to <8 x float>
     61   ret <8 x float> %a
     62 }
     63 
     64 define <4 x double> @fpext00(<4 x float> %b) nounwind {
     65 ; CHECK-LABEL: fpext00:
     66 ; CHECK:       # BB#0:
     67 ; CHECK-NEXT:    vcvtps2pd %xmm0, %ymm0
     68 ; CHECK-NEXT:    retq
     69   %a = fpext <4 x float> %b to <4 x double>
     70   ret <4 x double> %a
     71 }
     72 
     73 define double @funcA(i64* nocapture %e) nounwind uwtable readonly ssp {
     74 ; CHECK-LABEL: funcA:
     75 ; CHECK:       # BB#0:
     76 ; CHECK-NEXT:    vcvtsi2sdq (%rdi), %xmm0, %xmm0
     77 ; CHECK-NEXT:    retq
     78   %tmp1 = load i64, i64* %e, align 8
     79   %conv = sitofp i64 %tmp1 to double
     80   ret double %conv
     81 }
     82 
     83 define double @funcB(i32* nocapture %e) nounwind uwtable readonly ssp {
     84 ; CHECK-LABEL: funcB:
     85 ; CHECK:       # BB#0:
     86 ; CHECK-NEXT:    vcvtsi2sdl (%rdi), %xmm0, %xmm0
     87 ; CHECK-NEXT:    retq
     88   %tmp1 = load i32, i32* %e, align 4
     89   %conv = sitofp i32 %tmp1 to double
     90   ret double %conv
     91 }
     92 
     93 define float @funcC(i32* nocapture %e) nounwind uwtable readonly ssp {
     94 ; CHECK-LABEL: funcC:
     95 ; CHECK:       # BB#0:
     96 ; CHECK-NEXT:    vcvtsi2ssl (%rdi), %xmm0, %xmm0
     97 ; CHECK-NEXT:    retq
     98   %tmp1 = load i32, i32* %e, align 4
     99   %conv = sitofp i32 %tmp1 to float
    100   ret float %conv
    101 }
    102 
    103 define float @funcD(i64* nocapture %e) nounwind uwtable readonly ssp {
    104 ; CHECK-LABEL: funcD:
    105 ; CHECK:       # BB#0:
    106 ; CHECK-NEXT:    vcvtsi2ssq (%rdi), %xmm0, %xmm0
    107 ; CHECK-NEXT:    retq
    108   %tmp1 = load i64, i64* %e, align 8
    109   %conv = sitofp i64 %tmp1 to float
    110   ret float %conv
    111 }
    112 
    113 define void @fpext() nounwind uwtable {
    114 ; CHECK-LABEL: fpext:
    115 ; CHECK:       # BB#0:
    116 ; CHECK-NEXT:    vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    117 ; CHECK-NEXT:    vcvtss2sd %xmm0, %xmm0, %xmm0
    118 ; CHECK-NEXT:    vmovsd %xmm0, -{{[0-9]+}}(%rsp)
    119 ; CHECK-NEXT:    retq
    120   %f = alloca float, align 4
    121   %d = alloca double, align 8
    122   %tmp = load float, float* %f, align 4
    123   %conv = fpext float %tmp to double
    124   store double %conv, double* %d, align 8
    125   ret void
    126 }
    127 
    128 define double @nearbyint_f64(double %a) {
    129 ; CHECK-LABEL: nearbyint_f64:
    130 ; CHECK:       # BB#0:
    131 ; CHECK-NEXT:    vroundsd $12, %xmm0, %xmm0, %xmm0
    132 ; CHECK-NEXT:    retq
    133   %res = call double @llvm.nearbyint.f64(double %a)
    134   ret double %res
    135 }
    136 declare double @llvm.nearbyint.f64(double %p)
    137 
    138 define float @floor_f32(float %a) {
    139 ; CHECK-LABEL: floor_f32:
    140 ; CHECK:       # BB#0:
    141 ; CHECK-NEXT:    vroundss $1, %xmm0, %xmm0, %xmm0
    142 ; CHECK-NEXT:    retq
    143   %res = call float @llvm.floor.f32(float %a)
    144   ret float %res
    145 }
    146 declare float @llvm.floor.f32(float %p)
    147 
    148 
    149