Beispiel #1
0
static bool
fold_const_pow (real_value *result, const real_value *arg0,
		const real_value *arg1, const real_format *format)
{
  if (do_mpfr_arg2 (result, mpfr_pow, arg0, arg1, format))
    return true;

  /* Check for an integer exponent.  */
  REAL_VALUE_TYPE cint1;
  HOST_WIDE_INT n1 = real_to_integer (arg1);
  real_from_integer (&cint1, VOIDmode, n1, SIGNED);
  /* Attempt to evaluate pow at compile-time, unless this should
     raise an exception.  */
  if (real_identical (arg1, &cint1)
      && (n1 > 0
	  || (!flag_trapping_math && !flag_errno_math)
	  || !real_equal (arg0, &dconst0)))
    {
      bool inexact = real_powi (result, format, arg0, n1);
      if (flag_unsafe_math_optimizations || !inexact)
	return true;
    }

  return false;
}
Beispiel #2
0
static bool
fold_const_call_sss (real_value *result, built_in_function fn,
		     const wide_int_ref &arg0, const real_value *arg1,
		     const real_format *format)
{
  switch (fn)
    {
    CASE_FLT_FN (BUILT_IN_JN):
      return do_mpfr_arg2 (result, mpfr_jn, arg0, arg1, format);

    CASE_FLT_FN (BUILT_IN_YN):
      return (real_compare (GT_EXPR, arg1, &dconst0)
	      && do_mpfr_arg2 (result, mpfr_yn, arg0, arg1, format));

    default:
      return false;
    }
}
Beispiel #3
0
static bool
fold_const_call_sss (real_value *result, combined_fn fn,
		     const wide_int_ref &arg0, const real_value *arg1,
		     const real_format *format)
{
  switch (fn)
    {
    CASE_CFN_JN:
      return do_mpfr_arg2 (result, mpfr_jn, arg0, arg1, format);

    CASE_CFN_YN:
      return (real_compare (GT_EXPR, arg1, &dconst0)
	      && do_mpfr_arg2 (result, mpfr_yn, arg0, arg1, format));

    default:
      return false;
    }
}
Beispiel #4
0
static bool
fold_const_call_sc (real_value *result, built_in_function fn,
		    const real_value *arg_real, const real_value *arg_imag,
		    const real_format *format)
{
  switch (fn)
    {
    CASE_FLT_FN (BUILT_IN_CABS):
      return do_mpfr_arg2 (result, mpfr_hypot, arg_real, arg_imag, format);

    default:
      return false;
    }
}
Beispiel #5
0
static bool
fold_const_call_sc (real_value *result, combined_fn fn,
		    const real_value *arg_real, const real_value *arg_imag,
		    const real_format *format)
{
  switch (fn)
    {
    CASE_CFN_CABS:
      return do_mpfr_arg2 (result, mpfr_hypot, arg_real, arg_imag, format);

    default:
      return false;
    }
}
Beispiel #6
0
static bool
fold_const_call_sss (real_value *result, combined_fn fn,
		     const real_value *arg0, const real_value *arg1,
		     const real_format *format)
{
  switch (fn)
    {
    CASE_CFN_DREM:
    CASE_CFN_REMAINDER:
      return do_mpfr_arg2 (result, mpfr_remainder, arg0, arg1, format);

    CASE_CFN_ATAN2:
      return do_mpfr_arg2 (result, mpfr_atan2, arg0, arg1, format);

    CASE_CFN_FDIM:
      return do_mpfr_arg2 (result, mpfr_dim, arg0, arg1, format);

    CASE_CFN_HYPOT:
      return do_mpfr_arg2 (result, mpfr_hypot, arg0, arg1, format);

    CASE_CFN_COPYSIGN:
    CASE_CFN_COPYSIGN_FN:
      *result = *arg0;
      real_copysign (result, arg1);
      return true;

    CASE_CFN_FMIN:
    CASE_CFN_FMIN_FN:
      return do_mpfr_arg2 (result, mpfr_min, arg0, arg1, format);

    CASE_CFN_FMAX:
    CASE_CFN_FMAX_FN:
      return do_mpfr_arg2 (result, mpfr_max, arg0, arg1, format);

    CASE_CFN_POW:
      return fold_const_pow (result, arg0, arg1, format);

    default:
      return false;
    }
}
Beispiel #7
0
static bool
fold_const_call_sss (real_value *result, built_in_function fn,
		     const real_value *arg0, const real_value *arg1,
		     const real_format *format)
{
  switch (fn)
    {
    CASE_FLT_FN (BUILT_IN_DREM):
    CASE_FLT_FN (BUILT_IN_REMAINDER):
      return do_mpfr_arg2 (result, mpfr_remainder, arg0, arg1, format);

    CASE_FLT_FN (BUILT_IN_ATAN2):
      return do_mpfr_arg2 (result, mpfr_atan2, arg0, arg1, format);

    CASE_FLT_FN (BUILT_IN_FDIM):
      return do_mpfr_arg2 (result, mpfr_dim, arg0, arg1, format);

    CASE_FLT_FN (BUILT_IN_HYPOT):
      return do_mpfr_arg2 (result, mpfr_hypot, arg0, arg1, format);

    CASE_FLT_FN (BUILT_IN_COPYSIGN):
      *result = *arg0;
      real_copysign (result, arg1);
      return true;

    CASE_FLT_FN (BUILT_IN_FMIN):
      return do_mpfr_arg2 (result, mpfr_min, arg0, arg1, format);

    CASE_FLT_FN (BUILT_IN_FMAX):
      return do_mpfr_arg2 (result, mpfr_max, arg0, arg1, format);

    CASE_FLT_FN (BUILT_IN_POW):
      return fold_const_pow (result, arg0, arg1, format);

    default:
      return false;
    }
}