Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc -mtriple=aarch64-unknown-unknown < %s | FileCheck %s
      2 
      3 ; Following test cases check:
      4 ;   a / D; b / D; c / D;
      5 ;                =>
      6 ;   recip = 1.0 / D; a * recip; b * recip; c * recip;
      7 define void @three_fdiv_float(float %D, float %a, float %b, float %c) #0 {
      8 ; CHECK-LABEL: three_fdiv_float:
      9 ; CHECK: fdiv s
     10 ; CHECK-NOT: fdiv
     11 ; CHECK: fmul
     12 ; CHECK: fmul
     13 ; CHECK: fmul
     14   %div = fdiv float %a, %D
     15   %div1 = fdiv float %b, %D
     16   %div2 = fdiv float %c, %D
     17   tail call void @foo_3f(float %div, float %div1, float %div2)
     18   ret void
     19 }
     20 
     21 define void @three_fdiv_double(double %D, double %a, double %b, double %c) #0 {
     22 ; CHECK-LABEL: three_fdiv_double:
     23 ; CHECK: fdiv d
     24 ; CHECK-NOT: fdiv
     25 ; CHECK: fmul
     26 ; CHECK: fmul
     27 ; CHECK: fmul
     28   %div = fdiv double %a, %D
     29   %div1 = fdiv double %b, %D
     30   %div2 = fdiv double %c, %D
     31   tail call void @foo_3d(double %div, double %div1, double %div2)
     32   ret void
     33 }
     34 
     35 define void @three_fdiv_4xfloat(<4 x float> %D, <4 x float> %a, <4 x float> %b, <4 x float> %c) #0 {
     36 ; CHECK-LABEL: three_fdiv_4xfloat:
     37 ; CHECK: fdiv v
     38 ; CHECK-NOT: fdiv
     39 ; CHECK: fmul
     40 ; CHECK: fmul
     41 ; CHECK: fmul
     42   %div = fdiv <4 x float> %a, %D
     43   %div1 = fdiv <4 x float> %b, %D
     44   %div2 = fdiv <4 x float> %c, %D
     45   tail call void @foo_3_4xf(<4 x float> %div, <4 x float> %div1, <4 x float> %div2)
     46   ret void
     47 }
     48 
     49 define void @three_fdiv_2xdouble(<2 x double> %D, <2 x double> %a, <2 x double> %b, <2 x double> %c) #0 {
     50 ; CHECK-LABEL: three_fdiv_2xdouble:
     51 ; CHECK: fdiv v
     52 ; CHECK-NOT: fdiv
     53 ; CHECK: fmul
     54 ; CHECK: fmul
     55 ; CHECK: fmul
     56   %div = fdiv <2 x double> %a, %D
     57   %div1 = fdiv <2 x double> %b, %D
     58   %div2 = fdiv <2 x double> %c, %D
     59   tail call void @foo_3_2xd(<2 x double> %div, <2 x double> %div1, <2 x double> %div2)
     60   ret void
     61 }
     62 
     63 ; Following test cases check we never combine two FDIVs if neither of them
     64 ; calculates a reciprocal.
     65 define void @two_fdiv_float(float %D, float %a, float %b) #0 {
     66 ; CHECK-LABEL: two_fdiv_float:
     67 ; CHECK: fdiv s
     68 ; CHECK: fdiv s
     69 ; CHECK-NOT: fmul
     70   %div = fdiv float %a, %D
     71   %div1 = fdiv float %b, %D
     72   tail call void @foo_2f(float %div, float %div1)
     73   ret void
     74 }
     75 
     76 define void @two_fdiv_double(double %D, double %a, double %b) #0 {
     77 ; CHECK-LABEL: two_fdiv_double:
     78 ; CHECK: fdiv d
     79 ; CHECK: fdiv d
     80 ; CHECK-NOT: fmul
     81   %div = fdiv double %a, %D
     82   %div1 = fdiv double %b, %D
     83   tail call void @foo_2d(double %div, double %div1)
     84   ret void
     85 }
     86 
     87 declare void @foo_3f(float, float, float)
     88 declare void @foo_3d(double, double, double)
     89 declare void @foo_3_4xf(<4 x float>, <4 x float>, <4 x float>)
     90 declare void @foo_3_2xd(<2 x double>, <2 x double>, <2 x double>)
     91 declare void @foo_2f(float, float)
     92 declare void @foo_2d(double, double)
     93 
     94 attributes #0 = { "unsafe-fp-math"="true" }
     95