From 0a4613f0c53a129aedcc1296a031b761b444e5d8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 11 Oct 2016 23:45:34 +0200 Subject: [PATCH] iresolve.c (is_trig_resolved, [...]): Formatting fixes. * iresolve.c (is_trig_resolved, resolve_trig_call): Formatting fixes. * simplify.c (simplify_trig_call, degrees_f, radians_f, gfc_simplify_atrigd, gfc_simplify_cotan): Likewise. From-SVN: r241010 --- gcc/fortran/ChangeLog | 6 +++ gcc/fortran/iresolve.c | 46 +++++++++---------- gcc/fortran/simplify.c | 101 ++++++++++++++++++++--------------------- 3 files changed, 77 insertions(+), 76 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 15105753ed5..5c801b66ed0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-10-11 Jakub Jelinek + + * iresolve.c (is_trig_resolved, resolve_trig_call): Formatting fixes. + * simplify.c (simplify_trig_call, degrees_f, radians_f, + gfc_simplify_atrigd, gfc_simplify_cotan): Likewise. + 2016-10-11 Steven G. Kargl PR fortran/77942 diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c index 9ae0b6e2c8e..078e47dbaa0 100644 --- a/gcc/fortran/iresolve.c +++ b/gcc/fortran/iresolve.c @@ -685,8 +685,8 @@ is_trig_resolved (gfc_expr *f) { /* We know we've already resolved the function if we see the lib call starting with '__'. */ - return f->value.function.name != NULL - && 0 == strncmp ("__", f->value.function.name, 2); + return (f->value.function.name != NULL + && strncmp ("__", f->value.function.name, 2) == 0); } /* Return a shallow copy of the function expression f. The original expression @@ -2744,28 +2744,26 @@ resolve_trig_call (gfc_expr *f, gfc_expr *x) { switch (f->value.function.isym->id) { - case GFC_ISYM_ACOS: - return gfc_resolve_acos (f, x); - case GFC_ISYM_ASIN: - return gfc_resolve_asin (f, x); - case GFC_ISYM_ATAN: - return gfc_resolve_atan (f, x); - case GFC_ISYM_ATAN2: - /* NB. arg3 is unused for atan2 */ - return gfc_resolve_atan2 (f, x, NULL); - case GFC_ISYM_COS: - return gfc_resolve_cos (f, x); - case GFC_ISYM_COTAN: - return gfc_resolve_cotan (f, x); - case GFC_ISYM_SIN: - return gfc_resolve_sin (f, x); - case GFC_ISYM_TAN: - return gfc_resolve_tan (f, x); - default: - break; - } - - gcc_unreachable (); + case GFC_ISYM_ACOS: + return gfc_resolve_acos (f, x); + case GFC_ISYM_ASIN: + return gfc_resolve_asin (f, x); + case GFC_ISYM_ATAN: + return gfc_resolve_atan (f, x); + case GFC_ISYM_ATAN2: + /* NB. arg3 is unused for atan2 */ + return gfc_resolve_atan2 (f, x, NULL); + case GFC_ISYM_COS: + return gfc_resolve_cos (f, x); + case GFC_ISYM_COTAN: + return gfc_resolve_cotan (f, x); + case GFC_ISYM_SIN: + return gfc_resolve_sin (f, x); + case GFC_ISYM_TAN: + return gfc_resolve_tan (f, x); + default: + gcc_unreachable (); + } } /* Resolve degree trig function as trigd (x) = trig (radians (x)). */ diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index b593bce1f4a..549d900538b 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -1717,27 +1717,24 @@ simplify_trig_call (gfc_expr *icall) /* The actual simplifiers will return NULL for non-constant x. */ switch (func) - { + { case GFC_ISYM_ACOS: - return gfc_simplify_acos (x); + return gfc_simplify_acos (x); case GFC_ISYM_ASIN: - return gfc_simplify_asin (x); + return gfc_simplify_asin (x); case GFC_ISYM_ATAN: - return gfc_simplify_atan (x); + return gfc_simplify_atan (x); case GFC_ISYM_COS: - return gfc_simplify_cos (x); + return gfc_simplify_cos (x); case GFC_ISYM_COTAN: - return gfc_simplify_cotan (x); + return gfc_simplify_cotan (x); case GFC_ISYM_SIN: - return gfc_simplify_sin (x); + return gfc_simplify_sin (x); case GFC_ISYM_TAN: - return gfc_simplify_tan (x); + return gfc_simplify_tan (x); default: - break; - } - - gfc_internal_error ("in simplify_trig_call(): Bad intrinsic"); - return NULL; + gfc_internal_error ("in simplify_trig_call(): Bad intrinsic"); + } } /* Convert a floating-point number from radians to degrees. */ @@ -1745,22 +1742,22 @@ simplify_trig_call (gfc_expr *icall) static void degrees_f (mpfr_t x, mp_rnd_t rnd_mode) { - mpfr_t tmp; - mpfr_init (tmp); + mpfr_t tmp; + mpfr_init (tmp); - /* Set x = x % 2pi to avoid offsets with large angles. */ - mpfr_const_pi (tmp, rnd_mode); - mpfr_mul_ui (tmp, tmp, 2, rnd_mode); - mpfr_fmod (tmp, x, tmp, rnd_mode); + /* Set x = x % 2pi to avoid offsets with large angles. */ + mpfr_const_pi (tmp, rnd_mode); + mpfr_mul_ui (tmp, tmp, 2, rnd_mode); + mpfr_fmod (tmp, x, tmp, rnd_mode); - /* Set x = x * 180. */ - mpfr_mul_ui (x, x, 180, rnd_mode); + /* Set x = x * 180. */ + mpfr_mul_ui (x, x, 180, rnd_mode); - /* Set x = x / pi. */ - mpfr_const_pi (tmp, rnd_mode); - mpfr_div (x, x, tmp, rnd_mode); + /* Set x = x / pi. */ + mpfr_const_pi (tmp, rnd_mode); + mpfr_div (x, x, tmp, rnd_mode); - mpfr_clear (tmp); + mpfr_clear (tmp); } /* Convert a floating-point number from degrees to radians. */ @@ -1768,21 +1765,21 @@ degrees_f (mpfr_t x, mp_rnd_t rnd_mode) static void radians_f (mpfr_t x, mp_rnd_t rnd_mode) { - mpfr_t tmp; - mpfr_init (tmp); + mpfr_t tmp; + mpfr_init (tmp); - /* Set x = x % 360 to avoid offsets with large angles. */ - mpfr_set_ui (tmp, 360, rnd_mode); - mpfr_fmod (tmp, x, tmp, rnd_mode); + /* Set x = x % 360 to avoid offsets with large angles. */ + mpfr_set_ui (tmp, 360, rnd_mode); + mpfr_fmod (tmp, x, tmp, rnd_mode); - /* Set x = x * pi. */ - mpfr_const_pi (tmp, rnd_mode); - mpfr_mul (x, x, tmp, rnd_mode); + /* Set x = x * pi. */ + mpfr_const_pi (tmp, rnd_mode); + mpfr_mul (x, x, tmp, rnd_mode); - /* Set x = x / 180. */ - mpfr_div_ui (x, x, 180, rnd_mode); + /* Set x = x / 180. */ + mpfr_div_ui (x, x, 180, rnd_mode); - mpfr_clear (tmp); + mpfr_clear (tmp); } @@ -1820,11 +1817,11 @@ gfc_simplify_atrigd (gfc_expr *icall) result = simplify_trig_call (icall); if (result && result->expr_type == EXPR_CONSTANT) - { + { /* Convert constant to degrees after passing off to actual simplifier. */ degrees_f (result->value.real, GFC_RND_MODE); return result; - } + } /* Let gfc_resolve_atrigd take care of the non-constant case. */ return NULL; @@ -6403,22 +6400,22 @@ gfc_simplify_cotan (gfc_expr *x) switch (x->ts.type) { - case BT_REAL: - mpfr_cot (result->value.real, x->value.real, GFC_RND_MODE); - break; + case BT_REAL: + mpfr_cot (result->value.real, x->value.real, GFC_RND_MODE); + break; - case BT_COMPLEX: - /* There is no builtin mpc_cot, so compute cot = cos / sin. */ - val = &result->value.complex; - mpc_init2 (swp, mpfr_get_default_prec ()); - mpc_cos (swp, x->value.complex, GFC_MPC_RND_MODE); - mpc_sin (*val, x->value.complex, GFC_MPC_RND_MODE); - mpc_div (*val, swp, *val, GFC_MPC_RND_MODE); - mpc_clear (swp); - break; + case BT_COMPLEX: + /* There is no builtin mpc_cot, so compute cot = cos / sin. */ + val = &result->value.complex; + mpc_init2 (swp, mpfr_get_default_prec ()); + mpc_cos (swp, x->value.complex, GFC_MPC_RND_MODE); + mpc_sin (*val, x->value.complex, GFC_MPC_RND_MODE); + mpc_div (*val, swp, *val, GFC_MPC_RND_MODE); + mpc_clear (swp); + break; - default: - gcc_unreachable (); + default: + gcc_unreachable (); } return range_check (result, "COTAN"); -- 2.30.2