1 ; RUN: llc < %s -mcpu=core2 | FileCheck %s 2 3 ; generated using "clang -S -O2 -ffast-math -emit-llvm sqrt.c" from 4 ; #include <math.h> 5 ; 6 ; double fd(double d){ 7 ; return sqrt(d); 8 ; } 9 ; 10 ; float ff(float f){ 11 ; return sqrtf(f); 12 ; } 13 ; 14 ; long double fld(long double ld){ 15 ; return sqrtl(ld); 16 ; } 17 ; 18 ; Tests conversion of sqrt function calls into sqrt instructions when 19 ; -ffast-math is in effect. 20 21 ; ModuleID = 'sqrt.c' 22 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-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 23 target triple = "x86_64-unknown-linux-gnu" 24 25 ; Function Attrs: nounwind readnone uwtable 26 define double @fd(double %d) #0 { 27 entry: 28 ; CHECK: sqrtsd 29 %call = tail call double @__sqrt_finite(double %d) #2 30 ret double %call 31 } 32 33 ; Function Attrs: nounwind readnone 34 declare double @__sqrt_finite(double) #1 35 36 ; Function Attrs: nounwind readnone uwtable 37 define float @ff(float %f) #0 { 38 entry: 39 ; CHECK: sqrtss 40 %call = tail call float @__sqrtf_finite(float %f) #2 41 ret float %call 42 } 43 44 ; Function Attrs: nounwind readnone 45 declare float @__sqrtf_finite(float) #1 46 47 ; Function Attrs: nounwind readnone uwtable 48 define x86_fp80 @fld(x86_fp80 %ld) #0 { 49 entry: 50 ; CHECK: fsqrt 51 %call = tail call x86_fp80 @__sqrtl_finite(x86_fp80 %ld) #2 52 ret x86_fp80 %call 53 } 54 55 ; Function Attrs: nounwind readnone 56 declare x86_fp80 @__sqrtl_finite(x86_fp80) #1 57 58 attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" "use-soft-float"="false" } 59 attributes #1 = { nounwind readnone "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" "use-soft-float"="false" } 60 attributes #2 = { nounwind readnone } 61