Home | History | Annotate | Download | only in PowerPC
      1 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2q -enable-unsafe-fp-math | FileCheck %s
      2 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2q | FileCheck -check-prefix=CHECK-SAFE %s
      3 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
      4 target triple = "powerpc64-unknown-linux-gnu"
      5 
      6 declare <4 x double> @llvm.sqrt.v4f64(<4 x double>)
      7 declare <4 x float> @llvm.sqrt.v4f32(<4 x float>)
      8 
      9 define <4 x double> @foo(<4 x double> %a, <4 x double> %b) nounwind {
     10 entry:
     11   %x = call <4 x double> @llvm.sqrt.v4f64(<4 x double> %b)
     12   %r = fdiv <4 x double> %a, %x
     13   ret <4 x double> %r
     14 
     15 ; CHECK-LABEL: @foo
     16 ; CHECK: qvfrsqrte
     17 ; CHECK: qvfmul
     18 ; FIXME: We're currently loading two constants here (1.5 and -1.5), and using
     19 ;        an qvfmadd instead of a qvfnmsub
     20 ; CHECK: qvfmadd
     21 ; CHECK: qvfmadd
     22 ; CHECK: qvfmul
     23 ; CHECK: qvfmul
     24 ; CHECK: qvfmadd
     25 ; CHECK: qvfmul
     26 ; CHECK: qvfmul
     27 ; CHECK: blr
     28 
     29 ; CHECK-SAFE-LABEL: @foo
     30 ; CHECK-SAFE: fsqrt
     31 ; CHECK-SAFE: fdiv
     32 ; CHECK-SAFE: blr
     33 }
     34 
     35 define <4 x double> @foof(<4 x double> %a, <4 x float> %b) nounwind {
     36 entry:
     37   %x = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %b)
     38   %y = fpext <4 x float> %x to <4 x double>
     39   %r = fdiv <4 x double> %a, %y
     40   ret <4 x double> %r
     41 
     42 ; CHECK-LABEL: @foof
     43 ; CHECK: qvfrsqrtes
     44 ; CHECK: qvfmuls
     45 ; FIXME: We're currently loading two constants here (1.5 and -1.5), and using
     46 ;        an qvfmadd instead of a qvfnmsubs
     47 ; CHECK: qvfmadds
     48 ; CHECK: qvfmadds
     49 ; CHECK: qvfmuls
     50 ; CHECK: qvfmul
     51 ; CHECK: blr
     52 
     53 ; CHECK-SAFE-LABEL: @foof
     54 ; CHECK-SAFE: fsqrts
     55 ; CHECK-SAFE: fdiv
     56 ; CHECK-SAFE: blr
     57 }
     58 
     59 define <4 x float> @food(<4 x float> %a, <4 x double> %b) nounwind {
     60 entry:
     61   %x = call <4 x double> @llvm.sqrt.v4f64(<4 x double> %b)
     62   %y = fptrunc <4 x double> %x to <4 x float>
     63   %r = fdiv <4 x float> %a, %y
     64   ret <4 x float> %r
     65 
     66 ; CHECK-LABEL: @food
     67 ; CHECK: qvfrsqrte
     68 ; CHECK: qvfmul
     69 ; FIXME: We're currently loading two constants here (1.5 and -1.5), and using
     70 ;        an qvfmadd instead of a qvfnmsub
     71 ; CHECK: qvfmadd
     72 ; CHECK: qvfmadd
     73 ; CHECK: qvfmul
     74 ; CHECK: qvfmul
     75 ; CHECK: qvfmadd
     76 ; CHECK: qvfmul
     77 ; CHECK: qvfrsp
     78 ; CHECK: qvfmuls
     79 ; CHECK: blr
     80 
     81 ; CHECK-SAFE-LABEL: @food
     82 ; CHECK-SAFE: fsqrt
     83 ; CHECK-SAFE: fdivs
     84 ; CHECK-SAFE: blr
     85 }
     86 
     87 define <4 x float> @goo(<4 x float> %a, <4 x float> %b) nounwind {
     88 entry:
     89   %x = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %b)
     90   %r = fdiv <4 x float> %a, %x
     91   ret <4 x float> %r
     92 
     93 ; CHECK-LABEL: @goo
     94 ; CHECK: qvfrsqrtes
     95 ; CHECK: qvfmuls
     96 ; FIXME: We're currently loading two constants here (1.5 and -1.5), and using
     97 ;        an qvfmadd instead of a qvfnmsubs
     98 ; CHECK: qvfmadds
     99 ; CHECK: qvfmadds
    100 ; CHECK: qvfmuls
    101 ; CHECK: qvfmuls
    102 ; CHECK: blr
    103 
    104 ; CHECK-SAFE-LABEL: @goo
    105 ; CHECK-SAFE: fsqrts
    106 ; CHECK-SAFE: fdivs
    107 ; CHECK-SAFE: blr
    108 }
    109 
    110 define <4 x double> @foo2(<4 x double> %a, <4 x double> %b) nounwind {
    111 entry:
    112   %r = fdiv <4 x double> %a, %b
    113   ret <4 x double> %r
    114 
    115 ; CHECK-LABEL: @foo2
    116 ; CHECK: qvfre
    117 ; CHECK: qvfnmsub
    118 ; CHECK: qvfmadd
    119 ; CHECK: qvfnmsub
    120 ; CHECK: qvfmadd
    121 ; CHECK: qvfmul
    122 ; CHECK: blr
    123 
    124 ; CHECK-SAFE-LABEL: @foo2
    125 ; CHECK-SAFE: fdiv
    126 ; CHECK-SAFE: blr
    127 }
    128 
    129 define <4 x float> @goo2(<4 x float> %a, <4 x float> %b) nounwind {
    130 entry:
    131   %r = fdiv <4 x float> %a, %b
    132   ret <4 x float> %r
    133 
    134 ; CHECK-LABEL: @goo2
    135 ; CHECK: qvfres
    136 ; CHECK: qvfnmsubs
    137 ; CHECK: qvfmadds
    138 ; CHECK: qvfmuls
    139 ; CHECK: blr
    140 
    141 ; CHECK-SAFE-LABEL: @goo2
    142 ; CHECK-SAFE: fdivs
    143 ; CHECK-SAFE: blr
    144 }
    145 
    146 define <4 x double> @foo3(<4 x double> %a) nounwind {
    147 entry:
    148   %r = call <4 x double> @llvm.sqrt.v4f64(<4 x double> %a)
    149   ret <4 x double> %r
    150 
    151 ; CHECK-LABEL: @foo3
    152 ; CHECK: qvfrsqrte
    153 ; CHECK: qvfmul
    154 ; FIXME: We're currently loading two constants here (1.5 and -1.5), and using
    155 ;        an qvfmadd instead of a qvfnmsub
    156 ; CHECK-DAG: qvfmadd
    157 ; CHECK-DAG: qvfcmpeq
    158 ; CHECK-DAG: qvfmadd
    159 ; CHECK-DAG: qvfmul
    160 ; CHECK-DAG: qvfmul
    161 ; CHECK-DAG: qvfmadd
    162 ; CHECK-DAG: qvfmul
    163 ; CHECK-DAG: qvfmul
    164 ; CHECK: qvfsel
    165 ; CHECK: blr
    166 
    167 ; CHECK-SAFE-LABEL: @foo3
    168 ; CHECK-SAFE: fsqrt
    169 ; CHECK-SAFE: blr
    170 }
    171 
    172 define <4 x float> @goo3(<4 x float> %a) nounwind {
    173 entry:
    174   %r = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
    175   ret <4 x float> %r
    176 
    177 ; CHECK-LABEL: @goo3
    178 ; CHECK: qvfrsqrtes
    179 ; CHECK: qvfmuls
    180 ; FIXME: We're currently loading two constants here (1.5 and -1.5), and using
    181 ;        an qvfmadds instead of a qvfnmsubs
    182 ; CHECK-DAG: qvfmadds
    183 ; CHECK-DAG: qvfcmpeq
    184 ; CHECK-DAG: qvfmadds
    185 ; CHECK-DAG: qvfmuls
    186 ; CHECK-DAG: qvfmuls
    187 ; CHECK: qvfsel
    188 ; CHECK: blr
    189 
    190 ; CHECK-SAFE-LABEL: @goo3
    191 ; CHECK-SAFE: fsqrts
    192 ; CHECK-SAFE: blr
    193 }
    194 
    195