1 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -enable-unsafe-fp-math -mattr=-vsx | FileCheck %s
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -mattr=-vsx | FileCheck -check-prefix=CHECK-SAFE %s
4 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"
5 target triple = "powerpc64-unknown-linux-gnu"
7 declare double @llvm.sqrt.f64(double)
8 declare float @llvm.sqrt.f32(float)
9 declare <4 x float> @llvm.sqrt.v4f32(<4 x float>)
11 define double @foo(double %a, double %b) nounwind {
12 %x = call double @llvm.sqrt.f64(double %b)
13 %r = fdiv double %a, %x
34 define double @no_estimate_refinement_f64(double %a, double %b) #0 {
35 %x = call double @llvm.sqrt.f64(double %b)
36 %r = fdiv double %a, %x
39 ; CHECK-LABEL: @no_estimate_refinement_f64
48 define double @foof(double %a, float %b) nounwind {
49 %x = call float @llvm.sqrt.f32(float %b)
50 %y = fpext float %x to double
51 %r = fdiv double %a, %y
69 define float @food(float %a, double %b) nounwind {
70 %x = call double @llvm.sqrt.f64(double %b)
71 %y = fptrunc double %x to float
72 %r = fdiv float %a, %y
94 define float @goo(float %a, float %b) nounwind {
95 %x = call float @llvm.sqrt.f32(float %b)
96 %r = fdiv float %a, %x
100 ; CHECK-DAG: frsqrtes
115 define float @no_estimate_refinement_f32(float %a, float %b) #0 {
116 %x = call float @llvm.sqrt.f32(float %b)
117 %r = fdiv float %a, %x
120 ; CHECK-LABEL: @no_estimate_refinement_f32
128 ; Recognize that this is rsqrt(a) * rcp(b) * c,
129 ; not 1 / ( 1 / sqrt(a)) * rcp(b) * c.
130 define float @rsqrt_fmul(float %a, float %b, float %c) {
131 %x = call float @llvm.sqrt.f32(float %a)
132 %y = fmul float %x, %b
133 %z = fdiv float %c, %y
137 ; CHECK-DAG: frsqrtes
149 ; CHECK-SAFE: @rsqrt_fmul
156 define <4 x float> @hoo(<4 x float> %a, <4 x float> %b) nounwind {
157 %x = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %b)
158 %r = fdiv <4 x float> %a, %x
165 ; CHECK-SAFE-NOT: vrsqrtefp
169 define double @foo2(double %a, double %b) nounwind {
170 %r = fdiv double %a, %b
187 define float @goo2(float %a, float %b) nounwind {
188 %r = fdiv float %a, %b
203 define <4 x float> @hoo2(<4 x float> %a, <4 x float> %b) nounwind {
204 %r = fdiv <4 x float> %a, %b
211 ; CHECK-SAFE-NOT: vrefp
215 define double @foo3(double %a) nounwind {
216 %r = call double @llvm.sqrt.f64(double %a)
237 define float @goo3(float %a) nounwind {
238 %r = call float @llvm.sqrt.f32(float %a)
243 ; CHECK-DAG: frsqrtes
256 define <4 x float> @hoo3(<4 x float> %a) nounwind {
257 %r = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
262 ; CHECK-DAG: vcmpeqfp
265 ; CHECK-SAFE-NOT: vrsqrtefp
269 attributes #0 = { nounwind "reciprocal-estimates"="sqrtf:0,sqrtd:0" }