int main() { printf("%f\n", __builtin_fabsf(negative10())); printf("%f\n", __builtin_fabsf(positive42())); printf("%f\n", __builtin_fabsf(negative_dbl_max())); printf("%f\n", __builtin_fabs(negative10())); printf("%f\n", __builtin_fabs(positive42())); printf("%f\n", __builtin_fabs(negative_dbl_max())); }
float __hide_kernel_tanf(float x, float y, int iy) { float z,r,v,w,s; int ix,hx; GET_FLOAT_WORD(hx,x); ix = hx&0x7fffffff; /* high word of |x| */ if(ix<0x31800000) /* x < 2**-28 */ {if((int)x==0) { /* generate inexact */ if((ix|(iy+1))==0) return one/__builtin_fabsf(x); else return (iy==1)? x: -one/x; } } if(ix>=0x3f2ca140) { /* |x|>=0.6744 */ if(hx<0) {x = -x; y = -y;} z = pio4-x; w = pio4lo-y; x = z+w; y = 0.0; } z = x*x; w = z*z; /* Break x^5*(T[1]+x^2*T[2]+...) into * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) */ r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); s = z*x; r = y + z*(s*(r+v)+y); r += T[0]*s; w = x+r; if(ix>=0x3f2ca140) { v = (float)iy; return (float)(1-((hx>>30)&2))*(v-(float)2.0*(x-(w*w/(w+v)-r))); }
static inline Math::Vector3<float> Vector3Orthonormalize(const float &eps, const Math::Vector3<float> &u, const Math::Vector3<float> &v) { Math::Vector3<float> p; float D = __builtin_sqrtf(v.x * v.x + v.y * v.y + v.z * v.z); if( __builtin_fabsf( D - 1.0 ) > eps ) { double N = u.x * v.x + u.y * v.y + u.z * v.z; double Q = N / D; p.x = u.x - Q * v.x; p.y = u.y - Q * v.y; p.z = u.z - Q * v.z; double L = 1.0 / __builtin_sqrtf(p.x * p.x + p.y * p.y + p.z * p.z); p.x *= L; p.y *= L; p.z *= L; } // if return p; } // Vector3Orthonormalize
// CHECK-LABEL: define void @test_float_builtin_ops void test_float_builtin_ops(float F, double D, long double LD) { volatile float resf; volatile double resd; volatile long double resld; resf = __builtin_fmodf(F,F); // CHECK: frem float resd = __builtin_fmod(D,D); // CHECK: frem double resld = __builtin_fmodl(LD,LD); // CHECK: frem x86_fp80 resf = __builtin_fabsf(F); resd = __builtin_fabs(D); resld = __builtin_fabsl(LD); // CHECK: call float @llvm.fabs.f32(float // CHECK: call double @llvm.fabs.f64(double // CHECK: call x86_fp80 @llvm.fabs.f80(x86_fp80 resf = __builtin_canonicalizef(F); resd = __builtin_canonicalize(D); resld = __builtin_canonicalizel(LD); // CHECK: call float @llvm.canonicalize.f32(float // CHECK: call double @llvm.canonicalize.f64(double // CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80 }
float __builtin_j0f(float x) /* wrapper j0f */ { #ifdef _IEEE_LIBM return __hide_ieee754_j0f(x); #else struct exception exc; float z = __hide_ieee754_j0f(x); if(_LIB_VERSION == _IEEE_ || __builtin_isnan(x)) return z; if(__builtin_fabsf(x)>(float)X_TLOSS) { /* j0f(|x|>X_TLOSS) */ exc.type = TLOSS; exc.name = "j0f"; exc.err = 0; exc.arg1 = exc.arg2 = (double)x; exc.retval = 0.0; if (_LIB_VERSION == _POSIX_) errno = ERANGE; else if (!__builtin_matherr(&exc)) { errno = ERANGE; } if (exc.err != 0) errno = exc.err; return (float)exc.retval; } else return z; #endif }
int __fpclassifyf( float x ) { x = __builtin_fabsf(x); if( EXPECT_FALSE( x == 0.0f ) ) return FP_ZERO; if( EXPECT_FALSE( x < 0x1.0p-126f ) ) return FP_SUBNORMAL; if( EXPECT_TRUE( x < __builtin_inff() ) ) return FP_NORMAL; if( EXPECT_TRUE( x == __builtin_inff() ) ) return FP_INFINITE; return FP_NAN; }
static inline Math::Vector2<float> Vector2Normalize(const float eps, const Math::Vector2<float> &v) { Math::Vector2<float> p(v); float L = __builtin_sqrtf(v.x * v.x + v.y * v.y); if( __builtin_fabsf( L - 1.0 ) > eps ) { L = 1.0/L; p.x *= L; p.y *= L; } // if return p; } // Vector2Normalize
float __kernel_sinf (float x, float y, int iy) { float z, r, v; float ix; ix = __builtin_fabsf (x); if (ix < twom27) { /* |x| < 2**-27 */ if (x == 0.0) return x; } z = x * x; v = z * x; r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6))); if (iy == 0) return x + v * (S1 + z * r); else return x - ((z * (half * y - v * r) - y) - v * S1); }
float __builtin_atanhf(float x) /* wrapper atanhf */ { #ifdef _IEEE_LIBM return __hide_ieee754_atanhf(x); #else float z,y; struct exception exc; z = __hide_ieee754_atanhf(x); if(_LIB_VERSION == _IEEE_ || __builtin_isnan(x)) return z; y = __builtin_fabsf(x); if(y>=(float)1.0) { if(y>(float)1.0) { /* atanhf(|x|>1) */ exc.type = DOMAIN; exc.name = "atanhf"; exc.err = 0; exc.arg1 = exc.arg2 = (double)x; exc.retval = 0.0/0.0; if (_LIB_VERSION == _POSIX_) errno = EDOM; else if (!__builtin_matherr(&exc)) { errno = EDOM; } } else { /* atanhf(|x|=1) */ exc.type = SING; exc.name = "atanhf"; exc.err = 0; exc.arg1 = exc.arg2 = (double)x; exc.retval = x/0.0; /* sign(x)*inf */ if (_LIB_VERSION == _POSIX_) errno = EDOM; else if (!__builtin_matherr(&exc)) { errno = EDOM; } } if (exc.err != 0) errno = exc.err; return (float)exc.retval; } else return z; #endif }
float __cosf (float x) { float y[2], z = 0.0; float ix; int32_t n; ix = __builtin_fabsf (x); /* |x| ~< pi/4 */ if (ix <= pio4) { return __kernel_cosf (x, z); /* cos(Inf or NaN) is NaN */ } else if (isnanf (ix)) { return x - x; } else if (isinff (ix)) { __set_errno (EDOM); return x - x; } /* argument reduction needed */ else { n = __ieee754_rem_pio2f (x, y); switch (n & 3) { case 0: return __kernel_cosf (y[0], y[1]); case 1: return -__kernel_sinf (y[0], y[1], 1); case 2: return -__kernel_cosf (y[0], y[1]); default: return __kernel_sinf (y[0], y[1], 1); } } }
float f2 (float f) { return __builtin_fabsf (f); }
// GCC constant folds these too (via native strtol): //double g6_1 = __builtin_nan("1"); //float g7_1 = __builtin_nanf("1"); //long double g8_1 = __builtin_nanl("1"); // APFloat doesn't have signalling NaN functions. //double g9 = __builtin_nans(""); //float g10 = __builtin_nansf(""); //long double g11 = __builtin_nansl(""); //int g12 = __builtin_abs(-12); double g13 = __builtin_fabs(-12.); double g13_0 = __builtin_fabs(-0.); double g13_1 = __builtin_fabs(-__builtin_inf()); float g14 = __builtin_fabsf(-12.f); // GCC doesn't eat this one. //long double g15 = __builtin_fabsfl(-12.0L); float g16 = __builtin_copysign(1.0, -1.0); double g17 = __builtin_copysignf(1.0f, -1.0f); long double g18 = __builtin_copysignl(1.0L, -1.0L); char classify_nan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nan(""))]; char classify_snan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nans(""))]; char classify_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, __builtin_inf())]; char classify_neg_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, -__builtin_inf())]; char classify_normal [__builtin_fpclassify(-1, -1, +1, -1, -1, 1.539)]; char classify_normal2 [__builtin_fpclassify(-1, -1, +1, -1, -1, 1e-307)]; char classify_denorm [__builtin_fpclassify(-1, -1, -1, +1, -1, 1e-308)]; char classify_denorm2 [__builtin_fpclassify(-1, -1, -1, +1, -1, -1e-308)];
void test_long(long x) { (void)abs(x); // no warning - int and long are same length for this target (void)labs(x); (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)__builtin_abs(x); // no warning - int and long are same length for // this target (void)__builtin_labs(x); (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" }
void test_unsigned_long(unsigned long x) { (void)abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"" (void)labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)__builtin_abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"" (void)__builtin_labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" }
void test_complex_long_double(_Complex long double x) { (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)cabsf(x); // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)cabs(x); // expected-warning@-1 {{absolute value function 'cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)cabsl(x); (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_cabsf(x); // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_cabs(x); // expected-warning@-1 {{absolute value function '__builtin_cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_cabsl(x); }
void test_complex_float(_Complex float x) { (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)cabsf(x); (void)cabs(x); (void)cabsl(x); (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_cabsf(x); (void)__builtin_cabs(x); (void)__builtin_cabsl(x); }
int32_t __ieee754_rem_pio2f (float x, float *y) { float ax, z, n, r, w, t, e0; float tx[3]; int32_t i, nx; ax = __builtin_fabsf (x); if (ax <= pio4) { y[0] = x; y[1] = 0; return 0; } if (ax < pio3_4) { if (x > 0) { z = x - pio2_1; if (!__float_and_test28 (ax, pio2_24b)) { y[0] = z - pio2_1t; y[1] = (z - y[0]) - pio2_1t; } else { z -= pio2_2; y[0] = z - pio2_2t; y[1] = (z - y[0]) - pio2_2t; } return 1; } else { z = x + pio2_1; if (!__float_and_test28 (ax, pio2_24b)) { y[0] = z + pio2_1t; y[1] = (z - y[0]) + pio2_1t; } else { z += pio2_2; y[0] = z + pio2_2t; y[1] = (z - y[0]) + pio2_2t; } return -1; } } if (ax <= pio2_2e7) { n = __floorf (ax * invpio2 + half); i = (int32_t) n; r = ax - n * pio2_1; w = n * pio2_1t; /* 1st round good to 40 bit */ if (i < 32 && !__float_and_test24 (ax, npio2_hw[i - 1])) { y[0] = r - w; } else { float i, j; j = __float_and8 (ax); y[0] = r - w; i = __float_and8 (y[0]); if (j / i > 256.0 || j / i < 3.9062500e-3) { /* 2nd iterations needed, good to 57 */ t = r; w = n * pio2_2; r = t - w; w = n * pio2_2t - ((t - r) - w); y[0] = r - w; i = __float_and8 (y[0]); if (j / i > 33554432 || j / i < 2.9802322e-8) { /* 3rd iteration needed, 74 bits acc */ t = r; w = n * pio2_3; r = t - w; w = n * pio2_3t - ((t - r) - w); y[0] = r - w; } } } y[1] = (r - y[0]) - w; if (x < 0) { y[0] = -y[0]; y[1] = -y[1]; return -i; } else { return i; } } /* all other (large) arguments */ if (isnanf (x) || isinff (x)) { y[0] = y[1] = x - x; return 0; } /* set z = scalbn(|x|,ilogb(x)-7) */ e0 = __float_and8 (ax / 128.0); z = ax / e0; tx[0] = __floorf (z); z = (z - tx[0]) * two8; tx[1] = __floorf (z); z = (z - tx[1]) * two8; tx[2] = __floorf (z); nx = 3; while (tx[nx - 1] == zero) nx--; i = __fp_kernel_rem_pio2f (tx, y, e0, nx); if (x < 0) { y[0] = -y[0]; y[1] = -y[1]; return -i; } return i; }
void test_int(int x) { (void)std::abs(x); (void)abs(x); (void)labs(x); (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); (void)__builtin_labs(x); (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" }
NOMIPS16 float fabsf_legacy (float f) { return __builtin_fabsf (f); }
/*:::::*/ FBCALL float fb_FIXSingle( float x ) { return __builtin_floorf( __builtin_fabsf( x ) ) * fb_SGNSingle( x ); }
void test_long_long(long long x) { (void)abs(x); // expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}} // expected-note@-2{{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"llabs" (void)labs(x); // expected-warning@-1{{absolute value function 'labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}} // expected-note@-2{{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs" (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)__builtin_abs(x); // expected-warning@-1{{absolute value function '__builtin_abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}} // expected-note@-2{{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_llabs" (void)__builtin_labs(x); // expected-warning@-1{{absolute value function '__builtin_labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}} // expected-note@-2{{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs" (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" }
float __fabsf (float x) { return __builtin_fabsf (x); }
// CHECK-LABEL: define void @test_float_builtin_ops void test_float_builtin_ops(float F, double D, long double LD) { volatile float resf; volatile double resd; volatile long double resld; resf = __builtin_fmodf(F,F); // CHECK: frem float resd = __builtin_fmod(D,D); // CHECK: frem double resld = __builtin_fmodl(LD,LD); // CHECK: frem x86_fp80 resf = __builtin_fabsf(F); resd = __builtin_fabs(D); resld = __builtin_fabsl(LD); // CHECK: call float @llvm.fabs.f32(float // CHECK: call double @llvm.fabs.f64(double // CHECK: call x86_fp80 @llvm.fabs.f80(x86_fp80 resf = __builtin_canonicalizef(F); resd = __builtin_canonicalize(D); resld = __builtin_canonicalizel(LD); // CHECK: call float @llvm.canonicalize.f32(float // CHECK: call double @llvm.canonicalize.f64(double // CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80 resf = __builtin_fminf(F, F); // CHECK: call float @llvm.minnum.f32 resd = __builtin_fmin(D, D); // CHECK: call double @llvm.minnum.f64 resld = __builtin_fminl(LD, LD); // CHECK: call x86_fp80 @llvm.minnum.f80 resf = __builtin_fmaxf(F, F); // CHECK: call float @llvm.maxnum.f32 resd = __builtin_fmax(D, D); // CHECK: call double @llvm.maxnum.f64 resld = __builtin_fmaxl(LD, LD); // CHECK: call x86_fp80 @llvm.maxnum.f80 resf = __builtin_fabsf(F); // CHECK: call float @llvm.fabs.f32 resd = __builtin_fabs(D); // CHECK: call double @llvm.fabs.f64 resld = __builtin_fabsl(LD); // CHECK: call x86_fp80 @llvm.fabs.f80 resf = __builtin_copysignf(F, F); // CHECK: call float @llvm.copysign.f32 resd = __builtin_copysign(D, D); // CHECK: call double @llvm.copysign.f64 resld = __builtin_copysignl(LD, LD); // CHECK: call x86_fp80 @llvm.copysign.f80 resf = __builtin_ceilf(F); // CHECK: call float @llvm.ceil.f32 resd = __builtin_ceil(D); // CHECK: call double @llvm.ceil.f64 resld = __builtin_ceill(LD); // CHECK: call x86_fp80 @llvm.ceil.f80 resf = __builtin_floorf(F); // CHECK: call float @llvm.floor.f32 resd = __builtin_floor(D); // CHECK: call double @llvm.floor.f64 resld = __builtin_floorl(LD); // CHECK: call x86_fp80 @llvm.floor.f80 resf = __builtin_truncf(F); // CHECK: call float @llvm.trunc.f32 resd = __builtin_trunc(D); // CHECK: call double @llvm.trunc.f64 resld = __builtin_truncl(LD); // CHECK: call x86_fp80 @llvm.trunc.f80 resf = __builtin_rintf(F); // CHECK: call float @llvm.rint.f32 resd = __builtin_rint(D); // CHECK: call double @llvm.rint.f64 resld = __builtin_rintl(LD); // CHECK: call x86_fp80 @llvm.rint.f80 resf = __builtin_nearbyintf(F); // CHECK: call float @llvm.nearbyint.f32 resd = __builtin_nearbyint(D); // CHECK: call double @llvm.nearbyint.f64 resld = __builtin_nearbyintl(LD); // CHECK: call x86_fp80 @llvm.nearbyint.f80 resf = __builtin_roundf(F); // CHECK: call float @llvm.round.f32 resd = __builtin_round(D); // CHECK: call double @llvm.round.f64 resld = __builtin_roundl(LD); // CHECK: call x86_fp80 @llvm.round.f80 }