예제 #1
0
static bool
fold_const_call_ss (real_value *result, built_in_function fn,
		    const real_value *arg, const real_format *format)
{
  switch (fn)
    {
    CASE_FLT_FN (BUILT_IN_SQRT):
      return (real_compare (GE_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_sqrt, arg, format));

    CASE_FLT_FN (BUILT_IN_CBRT):
      return do_mpfr_arg1 (result, mpfr_cbrt, arg, format);

    CASE_FLT_FN (BUILT_IN_ASIN):
      return (real_compare (GE_EXPR, arg, &dconstm1)
	      && real_compare (LE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_asin, arg, format));

    CASE_FLT_FN (BUILT_IN_ACOS):
      return (real_compare (GE_EXPR, arg, &dconstm1)
	      && real_compare (LE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_acos, arg, format));

    CASE_FLT_FN (BUILT_IN_ATAN):
      return do_mpfr_arg1 (result, mpfr_atan, arg, format);

    CASE_FLT_FN (BUILT_IN_ASINH):
      return do_mpfr_arg1 (result, mpfr_asinh, arg, format);

    CASE_FLT_FN (BUILT_IN_ACOSH):
      return (real_compare (GE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_acosh, arg, format));

    CASE_FLT_FN (BUILT_IN_ATANH):
      return (real_compare (GE_EXPR, arg, &dconstm1)
	      && real_compare (LE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_atanh, arg, format));

    CASE_FLT_FN (BUILT_IN_SIN):
      return do_mpfr_arg1 (result, mpfr_sin, arg, format);

    CASE_FLT_FN (BUILT_IN_COS):
      return do_mpfr_arg1 (result, mpfr_cos, arg, format);

    CASE_FLT_FN (BUILT_IN_TAN):
      return do_mpfr_arg1 (result, mpfr_tan, arg, format);

    CASE_FLT_FN (BUILT_IN_SINH):
      return do_mpfr_arg1 (result, mpfr_sinh, arg, format);

    CASE_FLT_FN (BUILT_IN_COSH):
      return do_mpfr_arg1 (result, mpfr_cosh, arg, format);

    CASE_FLT_FN (BUILT_IN_TANH):
      return do_mpfr_arg1 (result, mpfr_tanh, arg, format);

    CASE_FLT_FN (BUILT_IN_ERF):
      return do_mpfr_arg1 (result, mpfr_erf, arg, format);

    CASE_FLT_FN (BUILT_IN_ERFC):
      return do_mpfr_arg1 (result, mpfr_erfc, arg, format);

    CASE_FLT_FN (BUILT_IN_TGAMMA):
      return do_mpfr_arg1 (result, mpfr_gamma, arg, format);

    CASE_FLT_FN (BUILT_IN_EXP):
      return do_mpfr_arg1 (result, mpfr_exp, arg, format);

    CASE_FLT_FN (BUILT_IN_EXP2):
      return do_mpfr_arg1 (result, mpfr_exp2, arg, format);

    CASE_FLT_FN (BUILT_IN_EXP10):
    CASE_FLT_FN (BUILT_IN_POW10):
      return do_mpfr_arg1 (result, mpfr_exp10, arg, format);

    CASE_FLT_FN (BUILT_IN_EXPM1):
      return do_mpfr_arg1 (result, mpfr_expm1, arg, format);

    CASE_FLT_FN (BUILT_IN_LOG):
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_log, arg, format));

    CASE_FLT_FN (BUILT_IN_LOG2):
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_log2, arg, format));

    CASE_FLT_FN (BUILT_IN_LOG10):
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_log10, arg, format));

    CASE_FLT_FN (BUILT_IN_LOG1P):
      return (real_compare (GT_EXPR, arg, &dconstm1)
	      && do_mpfr_arg1 (result, mpfr_log1p, arg, format));

    CASE_FLT_FN (BUILT_IN_J0):
      return do_mpfr_arg1 (result, mpfr_j0, arg, format);

    CASE_FLT_FN (BUILT_IN_J1):
      return do_mpfr_arg1 (result, mpfr_j1, arg, format);

    CASE_FLT_FN (BUILT_IN_Y0):
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_y0, arg, format));

    CASE_FLT_FN (BUILT_IN_Y1):
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_y1, arg, format));

    CASE_FLT_FN (BUILT_IN_FLOOR):
      if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
	{
	  real_floor (result, format, arg);
	  return true;
	}
      return false;

    CASE_FLT_FN (BUILT_IN_CEIL):
      if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
	{
	  real_ceil (result, format, arg);
	  return true;
	}
      return false;

    CASE_FLT_FN (BUILT_IN_TRUNC):
      real_trunc (result, format, arg);
      return true;

    CASE_FLT_FN (BUILT_IN_ROUND):
      if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
	{
	  real_round (result, format, arg);
	  return true;
	}
      return false;

    CASE_FLT_FN (BUILT_IN_LOGB):
      return fold_const_logb (result, arg, format);

    CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
      return fold_const_significand (result, arg, format);

    default:
      return false;
    }
}
예제 #2
0
static bool
fold_const_call_ss (real_value *result, combined_fn fn,
		    const real_value *arg, const real_format *format)
{
  switch (fn)
    {
    CASE_CFN_SQRT:
      return (real_compare (GE_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_sqrt, arg, format));

    CASE_CFN_CBRT:
      return do_mpfr_arg1 (result, mpfr_cbrt, arg, format);

    CASE_CFN_ASIN:
      return (real_compare (GE_EXPR, arg, &dconstm1)
	      && real_compare (LE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_asin, arg, format));

    CASE_CFN_ACOS:
      return (real_compare (GE_EXPR, arg, &dconstm1)
	      && real_compare (LE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_acos, arg, format));

    CASE_CFN_ATAN:
      return do_mpfr_arg1 (result, mpfr_atan, arg, format);

    CASE_CFN_ASINH:
      return do_mpfr_arg1 (result, mpfr_asinh, arg, format);

    CASE_CFN_ACOSH:
      return (real_compare (GE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_acosh, arg, format));

    CASE_CFN_ATANH:
      return (real_compare (GE_EXPR, arg, &dconstm1)
	      && real_compare (LE_EXPR, arg, &dconst1)
	      && do_mpfr_arg1 (result, mpfr_atanh, arg, format));

    CASE_CFN_SIN:
      return do_mpfr_arg1 (result, mpfr_sin, arg, format);

    CASE_CFN_COS:
      return do_mpfr_arg1 (result, mpfr_cos, arg, format);

    CASE_CFN_TAN:
      return do_mpfr_arg1 (result, mpfr_tan, arg, format);

    CASE_CFN_SINH:
      return do_mpfr_arg1 (result, mpfr_sinh, arg, format);

    CASE_CFN_COSH:
      return do_mpfr_arg1 (result, mpfr_cosh, arg, format);

    CASE_CFN_TANH:
      return do_mpfr_arg1 (result, mpfr_tanh, arg, format);

    CASE_CFN_ERF:
      return do_mpfr_arg1 (result, mpfr_erf, arg, format);

    CASE_CFN_ERFC:
      return do_mpfr_arg1 (result, mpfr_erfc, arg, format);

    CASE_CFN_TGAMMA:
      return do_mpfr_arg1 (result, mpfr_gamma, arg, format);

    CASE_CFN_EXP:
      return do_mpfr_arg1 (result, mpfr_exp, arg, format);

    CASE_CFN_EXP2:
      return do_mpfr_arg1 (result, mpfr_exp2, arg, format);

    CASE_CFN_EXP10:
    CASE_CFN_POW10:
      return do_mpfr_arg1 (result, mpfr_exp10, arg, format);

    CASE_CFN_EXPM1:
      return do_mpfr_arg1 (result, mpfr_expm1, arg, format);

    CASE_CFN_LOG:
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_log, arg, format));

    CASE_CFN_LOG2:
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_log2, arg, format));

    CASE_CFN_LOG10:
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_log10, arg, format));

    CASE_CFN_LOG1P:
      return (real_compare (GT_EXPR, arg, &dconstm1)
	      && do_mpfr_arg1 (result, mpfr_log1p, arg, format));

    CASE_CFN_J0:
      return do_mpfr_arg1 (result, mpfr_j0, arg, format);

    CASE_CFN_J1:
      return do_mpfr_arg1 (result, mpfr_j1, arg, format);

    CASE_CFN_Y0:
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_y0, arg, format));

    CASE_CFN_Y1:
      return (real_compare (GT_EXPR, arg, &dconst0)
	      && do_mpfr_arg1 (result, mpfr_y1, arg, format));

    CASE_CFN_FLOOR:
      if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
	{
	  real_floor (result, format, arg);
	  return true;
	}
      return false;

    CASE_CFN_CEIL:
      if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
	{
	  real_ceil (result, format, arg);
	  return true;
	}
      return false;

    CASE_CFN_TRUNC:
      real_trunc (result, format, arg);
      return true;

    CASE_CFN_ROUND:
      if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
	{
	  real_round (result, format, arg);
	  return true;
	}
      return false;

    CASE_CFN_LOGB:
      return fold_const_logb (result, arg, format);

    CASE_CFN_SIGNIFICAND:
      return fold_const_significand (result, arg, format);

    default:
      return false;
    }
}