Apologies for late a late reply. A quick skim of the code suggests that you can eliminate some of the range_check() calls in the simplifications. For example, you have
+gfc_expr * +gfc_simplify_acospi (gfc_expr *x) +{ + gfc_expr *result; + + if (x->expr_type != EXPR_CONSTANT) + return NULL; + + if (mpfr_cmp_si (x->value.real, 1) > 0 || mpfr_cmp_si (x->value.real, -1) < 0) + { + gfc_error ("Argument of ACOSPI at %L must be between -1 and 1", + &x->where); + return &gfc_bad_expr; + } This error check should be sufficient, so that ... + result = gfc_get_constant_expr (x->ts.type, x->ts.kind, &x->where); + +#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0) + mpfr_acospi (result->value.real, x->value.real, GFC_RND_MODE); +#else + mpfr_t pi, tmp; + mpfr_inits2 (2 * mpfr_get_prec (x->value.real), pi, tmp, NULL); + mpfr_const_pi (pi, GFC_RND_MODE); + mpfr_acos (tmp, x->value.real, GFC_RND_MODE); + mpfr_div (result->value.real, tmp, pi, GFC_RND_MODE); + mpfr_clears (pi, tmp, NULL); +#endif + + return range_check (result, "ACOSPI"); this range_check() is unneeded. As a side note, the error message is slightly misleading (although it will not be issued). Technically, x = -1 or 1 are allowed values, and neither is **between** -1 and 1. A better error message might be gfc_error ("Argument of ACOSPI at %L must be within the " closed interval [-1,1]"); or gfc_error ("Argument X of ACOSPI at %L must satisfy -1 <= X <= 1"); -- steve