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=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefix=ALL --check-prefix=X32
      3 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2 | FileCheck %s --check-prefix=ALL --check-prefix=X64
      4 
      5 ;
      6 ; Library Functions
      7 ;
      8 
      9 define float @tst1(float %a, float %b) nounwind {
     10 ; X32-LABEL: tst1:
     11 ; X32:       # %bb.0:
     12 ; X32-NEXT:    subl $8, %esp
     13 ; X32-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     14 ; X32-NEXT:    movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
     15 ; X32-NEXT:    movss %xmm1, {{[0-9]+}}(%esp)
     16 ; X32-NEXT:    movss %xmm0, (%esp)
     17 ; X32-NEXT:    calll copysignf
     18 ; X32-NEXT:    addl $8, %esp
     19 ; X32-NEXT:    retl
     20 ;
     21 ; X64-LABEL: tst1:
     22 ; X64:       # %bb.0:
     23 ; X64-NEXT:    movaps %xmm0, %xmm2
     24 ; X64-NEXT:    movaps %xmm1, %xmm0
     25 ; X64-NEXT:    movaps %xmm2, %xmm1
     26 ; X64-NEXT:    jmp copysignf # TAILCALL
     27   %tmp = tail call float @copysignf( float %b, float %a )
     28   ret float %tmp
     29 }
     30 
     31 define double @tst2(double %a, float %b, float %c) nounwind {
     32 ; X32-LABEL: tst2:
     33 ; X32:       # %bb.0:
     34 ; X32-NEXT:    subl $16, %esp
     35 ; X32-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
     36 ; X32-NEXT:    movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
     37 ; X32-NEXT:    addss {{[0-9]+}}(%esp), %xmm1
     38 ; X32-NEXT:    cvtss2sd %xmm1, %xmm1
     39 ; X32-NEXT:    movsd %xmm0, (%esp)
     40 ; X32-NEXT:    movsd %xmm1, {{[0-9]+}}(%esp)
     41 ; X32-NEXT:    calll copysign
     42 ; X32-NEXT:    addl $16, %esp
     43 ; X32-NEXT:    retl
     44 ;
     45 ; X64-LABEL: tst2:
     46 ; X64:       # %bb.0:
     47 ; X64-NEXT:    addss %xmm2, %xmm1
     48 ; X64-NEXT:    cvtss2sd %xmm1, %xmm1
     49 ; X64-NEXT:    jmp copysign # TAILCALL
     50   %tmp1 = fadd float %b, %c
     51   %tmp2 = fpext float %tmp1 to double
     52   %tmp = tail call double @copysign( double %a, double %tmp2 )
     53   ret double %tmp
     54 }
     55 
     56 declare float @copysignf(float, float)
     57 declare double @copysign(double, double)
     58 
     59 ;
     60 ; LLVM Intrinsic
     61 ;
     62 
     63 define float @int1(float %a, float %b) nounwind {
     64 ; X32-LABEL: int1:
     65 ; X32:       # %bb.0:
     66 ; X32-NEXT:    pushl %eax
     67 ; X32-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
     68 ; X32-NEXT:    movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
     69 ; X32-NEXT:    andps {{\.LCPI.*}}, %xmm1
     70 ; X32-NEXT:    andps {{\.LCPI.*}}, %xmm0
     71 ; X32-NEXT:    orps %xmm1, %xmm0
     72 ; X32-NEXT:    movss %xmm0, (%esp)
     73 ; X32-NEXT:    flds (%esp)
     74 ; X32-NEXT:    popl %eax
     75 ; X32-NEXT:    retl
     76 ;
     77 ; X64-LABEL: int1:
     78 ; X64:       # %bb.0:
     79 ; X64-NEXT:    andps {{.*}}(%rip), %xmm0
     80 ; X64-NEXT:    andps {{.*}}(%rip), %xmm1
     81 ; X64-NEXT:    orps %xmm1, %xmm0
     82 ; X64-NEXT:    retq
     83   %tmp = tail call float @llvm.copysign.f32( float %b, float %a )
     84   ret float %tmp
     85 }
     86 
     87 define double @int2(double %a, float %b, float %c) nounwind {
     88 ; X32-LABEL: int2:
     89 ; X32:       # %bb.0:
     90 ; X32-NEXT:    pushl %ebp
     91 ; X32-NEXT:    movl %esp, %ebp
     92 ; X32-NEXT:    andl $-8, %esp
     93 ; X32-NEXT:    subl $8, %esp
     94 ; X32-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
     95 ; X32-NEXT:    movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
     96 ; X32-NEXT:    addss 20(%ebp), %xmm1
     97 ; X32-NEXT:    andps {{\.LCPI.*}}, %xmm0
     98 ; X32-NEXT:    cvtss2sd %xmm1, %xmm1
     99 ; X32-NEXT:    andps {{\.LCPI.*}}, %xmm1
    100 ; X32-NEXT:    orps %xmm0, %xmm1
    101 ; X32-NEXT:    movlps %xmm1, (%esp)
    102 ; X32-NEXT:    fldl (%esp)
    103 ; X32-NEXT:    movl %ebp, %esp
    104 ; X32-NEXT:    popl %ebp
    105 ; X32-NEXT:    retl
    106 ;
    107 ; X64-LABEL: int2:
    108 ; X64:       # %bb.0:
    109 ; X64-NEXT:    addss %xmm2, %xmm1
    110 ; X64-NEXT:    cvtss2sd %xmm1, %xmm1
    111 ; X64-NEXT:    andps {{.*}}(%rip), %xmm1
    112 ; X64-NEXT:    andps {{.*}}(%rip), %xmm0
    113 ; X64-NEXT:    orps %xmm1, %xmm0
    114 ; X64-NEXT:    retq
    115   %tmp1 = fadd float %b, %c
    116   %tmp2 = fpext float %tmp1 to double
    117   %tmp = tail call double @llvm.copysign.f64( double %a, double %tmp2 )
    118   ret double %tmp
    119 }
    120 
    121 define float @cst1() nounwind {
    122 ; X32-LABEL: cst1:
    123 ; X32:       # %bb.0:
    124 ; X32-NEXT:    fld1
    125 ; X32-NEXT:    fchs
    126 ; X32-NEXT:    retl
    127 ;
    128 ; X64-LABEL: cst1:
    129 ; X64:       # %bb.0:
    130 ; X64-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
    131 ; X64-NEXT:    retq
    132   %tmp = tail call float @llvm.copysign.f32( float 1.0, float -2.0 )
    133   ret float %tmp
    134 }
    135 
    136 define double @cst2() nounwind {
    137 ; X32-LABEL: cst2:
    138 ; X32:       # %bb.0:
    139 ; X32-NEXT:    fldz
    140 ; X32-NEXT:    fchs
    141 ; X32-NEXT:    retl
    142 ;
    143 ; X64-LABEL: cst2:
    144 ; X64:       # %bb.0:
    145 ; X64-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
    146 ; X64-NEXT:    retq
    147   %tmp1 = fadd float -1.0, -1.0
    148   %tmp2 = fpext float %tmp1 to double
    149   %tmp = tail call double @llvm.copysign.f64( double 0.0, double %tmp2 )
    150   ret double %tmp
    151 }
    152 
    153 declare float     @llvm.copysign.f32(float  %Mag, float  %Sgn)
    154 declare double    @llvm.copysign.f64(double %Mag, double %Sgn)
    155