* simplify.c (twos_complement): New function.
(gfc_simplify_ishft, gfc_simplify_ishftc): Revise.
+ * simplify.c (gfc_simplify_abs): Use mpfr_hypot for CABS.
+
2004-10-06 Paul Brook <paul@codesourcery.com>
* trans-stmt.c (gfc_trans_simple_do): New function.
gfc_simplify_abs (gfc_expr * e)
{
gfc_expr *result;
- mpfr_t a, b;
if (e->expr_type != EXPR_CONSTANT)
return NULL;
result = gfc_constant_result (BT_REAL, e->ts.kind, &e->where);
gfc_set_model_kind (e->ts.kind);
- mpfr_init (a);
- mpfr_init (b);
- /* FIXME: Possible numerical problems. */
- mpfr_mul (a, e->value.complex.r, e->value.complex.r, GFC_RND_MODE);
- mpfr_mul (b, e->value.complex.i, e->value.complex.i, GFC_RND_MODE);
- mpfr_add (a, a, b, GFC_RND_MODE);
- mpfr_sqrt (result->value.real, a, GFC_RND_MODE);
-
- mpfr_clear (a);
- mpfr_clear (b);
+ mpfr_hypot (result->value.real, e->value.complex.r,
+ e->value.complex.i, GFC_RND_MODE);
result = range_check (result, "CABS");
break;