1 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -mattr=-vsx | FileCheck %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"
6 declare double @llvm.sqrt.f64(double)
7 declare float @llvm.sqrt.f32(float)
8 declare <4 x float> @llvm.sqrt.v4f32(<4 x float>)
10 define double @foo_fmf(double %a, double %b) nounwind {
23 %x = call fast double @llvm.sqrt.f64(double %b)
24 %r = fdiv fast double %a, %x
28 define double @foo_safe(double %a, double %b) nounwind {
33 %x = call double @llvm.sqrt.f64(double %b)
34 %r = fdiv double %a, %x
38 define double @no_estimate_refinement_f64(double %a, double %b) #0 {
39 ; CHECK-LABEL: @no_estimate_refinement_f64
45 %x = call fast double @llvm.sqrt.f64(double %b)
46 %r = fdiv fast double %a, %x
50 define double @foof_fmf(double %a, float %b) nounwind {
59 %x = call fast float @llvm.sqrt.f32(float %b)
60 %y = fpext float %x to double
61 %r = fdiv fast double %a, %y
65 define double @foof_safe(double %a, float %b) nounwind {
70 %x = call float @llvm.sqrt.f32(float %b)
71 %y = fpext float %x to double
72 %r = fdiv double %a, %y
76 define float @food_fmf(float %a, double %b) nounwind {
90 %x = call fast double @llvm.sqrt.f64(double %b)
91 %y = fptrunc double %x to float
92 %r = fdiv fast float %a, %y
96 define float @food_safe(float %a, double %b) nounwind {
101 %x = call double @llvm.sqrt.f64(double %b)
102 %y = fptrunc double %x to float
103 %r = fdiv float %a, %y
107 define float @goo_fmf(float %a, float %b) nounwind {
109 ; CHECK-DAG: frsqrtes
116 %x = call fast float @llvm.sqrt.f32(float %b)
117 %r = fdiv fast float %a, %x
121 define float @goo_safe(float %a, float %b) nounwind {
126 %x = call float @llvm.sqrt.f32(float %b)
127 %r = fdiv float %a, %x
131 define float @no_estimate_refinement_f32(float %a, float %b) #0 {
132 ; CHECK-LABEL: @no_estimate_refinement_f32
138 %x = call fast float @llvm.sqrt.f32(float %b)
139 %r = fdiv fast float %a, %x
143 ; Recognize that this is rsqrt(a) * rcp(b) * c,
144 ; not 1 / ( 1 / sqrt(a)) * rcp(b) * c.
145 define float @rsqrt_fmul_fmf(float %a, float %b, float %c) {
146 ; CHECK: @rsqrt_fmul_fmf
147 ; CHECK-DAG: frsqrtes
152 ; CHECK-COUNT-3: fmuls
157 %x = call fast float @llvm.sqrt.f32(float %a)
158 %y = fmul fast float %x, %b
159 %z = fdiv fast float %c, %y
163 ; Recognize that this is rsqrt(a) * rcp(b) * c,
164 ; not 1 / ( 1 / sqrt(a)) * rcp(b) * c.
165 define float @rsqrt_fmul_safe(float %a, float %b, float %c) {
166 ; CHECK: @rsqrt_fmul_safe
171 %x = call float @llvm.sqrt.f32(float %a)
172 %y = fmul float %x, %b
173 %z = fdiv float %c, %y
177 define <4 x float> @hoo_fmf(<4 x float> %a, <4 x float> %b) nounwind {
180 %x = call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %b)
181 %r = fdiv fast <4 x float> %a, %x
185 define <4 x float> @hoo_safe(<4 x float> %a, <4 x float> %b) nounwind {
187 ; CHECK-NOT: vrsqrtefp
189 %x = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %b)
190 %r = fdiv <4 x float> %a, %x
194 define double @foo2_fmf(double %a, double %b) nounwind {
203 %r = fdiv fast double %a, %b
207 define double @foo2_safe(double %a, double %b) nounwind {
211 %r = fdiv double %a, %b
215 define float @goo2_fmf(float %a, float %b) nounwind {
222 %r = fdiv fast float %a, %b
226 define float @goo2_safe(float %a, float %b) nounwind {
230 %r = fdiv float %a, %b
234 define <4 x float> @hoo2_fmf(<4 x float> %a, <4 x float> %b) nounwind {
237 %r = fdiv fast <4 x float> %a, %b
241 define <4 x float> @hoo2_safe(<4 x float> %a, <4 x float> %b) nounwind {
245 %r = fdiv <4 x float> %a, %b
249 define double @foo3_fmf(double %a) nounwind {
262 %r = call fast double @llvm.sqrt.f64(double %a)
266 define double @foo3_safe(double %a) nounwind {
270 %r = call double @llvm.sqrt.f64(double %a)
274 define float @goo3_fmf(float %a) nounwind {
277 ; CHECK-DAG: frsqrtes
283 %r = call fast float @llvm.sqrt.f32(float %a)
287 define float @goo3_safe(float %a) nounwind {
291 %r = call float @llvm.sqrt.f32(float %a)
295 define <4 x float> @hoo3_fmf(<4 x float> %a) nounwind {
298 ; CHECK-DAG: vcmpeqfp
299 %r = call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
303 define <4 x float> @hoo3_safe(<4 x float> %a) nounwind {
305 ; CHECK-NOT: vrsqrtefp
307 %r = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
311 attributes #0 = { nounwind "reciprocal-estimates"="sqrtf:0,sqrtd:0" }