PING! Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Oct 10 19:56:00 GMT 2016


On Mon, Oct 10, 2016 at 12:29:32PM -0700, Jerry DeLisle wrote:
> On 10/10/2016 08:06 AM, Fritz Reese wrote:
> > https://gcc.gnu.org/ml/fortran/2016-09/msg00163.html [original]
> > https://gcc.gnu.org/ml/fortran/2016-09/msg00183.html [latest]
> > 
> > On Wed, Sep 28, 2016 at 4:14 PM, Fritz Reese <fritzoreese@gmail.com> wrote:
> >> Attached is a patch extending the GNU Fortran front-end to support
> >> some additional math intrinsics, enabled with a new compile flag
> >> -fdec-math. The flag adds the COTAN intrinsic (cotangent), as well as
> >> degree versions of all trigonometric intrinsics (SIND, TAND, ACOSD,
> >> etc...). This extension allows for further compatibility with legacy
> >> code that depends on the compiler to support such intrinsic functions.
> > 
> > Patch is still pending. Current draft of the patch is re-attached for
> > convenience, since it was amended twice since the original post. OK
> > for trunk?
> > 
> 
> OK, thanks for the work.
> 

Sorry about following behind. I did intend to review the patch, but
time got away from me.  There are a few small clean-up that can be
done.  For example,

+static gfc_expr *
+get_radians (gfc_expr *deg)
+{
+  mpfr_t tmp;
...

+  /* Set factor = pi / 180.  */
+  factor = gfc_get_constant_expr (deg->ts.type, deg->ts.kind, &deg->where);
+  mpfr_const_pi (factor->value.real, GFC_RND_MODE);
+  mpfr_init (tmp);
+  mpfr_set_d (tmp, 180.0, GFC_RND_MODE);
+  mpfr_div (factor->value.real, factor->value.real, tmp, GFC_RND_MODE);
+  mpfr_clear (tmp);

the tmp variable is unneeded in the above.  Converting the double
precision 180.0 to mpfr_t and then dividing is probably slower
than just dividing by 180.

+  /* Set factor = pi / 180.  */
+  factor = gfc_get_constant_expr (deg->ts.type, deg->ts.kind, &deg->where);
+  mpfr_const_pi (factor->value.real, GFC_RND_MODE);
+  mpfr_div_ui (factor->value.real, factor->value.real, 180, GFC_RND_MODE);

Of course, the clean-up can be done post-commit by Fritz.

-- 
Steve



More information about the Gcc-patches mailing list