From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx-relay52-hz2.antispameurope.com (mx-relay52-hz2.antispameurope.com [94.100.136.252]) by sourceware.org (Postfix) with ESMTPS id C648C385E00B for ; Sat, 28 Mar 2020 07:10:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C648C385E00B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=net-b.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=prvs=0349ec6c1f=burnus@net-b.de Received: from s041.bre.qsc.de ([195.90.7.81]) by mx-relay52-hz2.antispameurope.com; Sat, 28 Mar 2020 08:10:40 +0100 Received: from [192.168.145.128] (port-92-195-132-167.dynamic.as20676.net [92.195.132.167]) by s041.bre.qsc.de (Postfix) with ESMTPSA id B6A222C0128; Sat, 28 Mar 2020 08:10:38 +0100 (CET) Subject: Re: PATCH -- Fix degree trignometric functions To: Fritz Reese , Steve Kargl Cc: gcc-patches , fortran References: <20200306231819.GA66443@troutmask.apl.washington.edu> From: Tobias Burnus Message-ID: Date: Sat, 28 Mar 2020 08:10:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-cloud-security-sender: burnus@net-b.de X-cloud-security-recipient: gcc-patches@gcc.gnu.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mx-relay52-hz2.antispameurope.com with 313D6E044D8 X-cloud-security-connect: s041.bre.qsc.de[195.90.7.81], TLS=1, IP=195.90.7.81 X-cloud-security: scantime:.1796 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2020 07:10:44 -0000 Two remarks: * As the file trigd_lib.inc is shared between libgfortran and gcc/fortran, I wonder whether it should be placed under include/ (under the GCC toplevel directroy) * All included files need dependency; I do not quickly see whether that' the case. Cheers, Tobias On 3/28/20 12:36 AM, Fritz Reese via Fortran wrote: > On Fri, Mar 6, 2020 at 6:18 PM Steve Kargl > wrote: > [...] >> TL;DR version. >> >> Fix the simplification and handling of the degree trigonometric functions. >> This includes fixing a number of ICEs. See PR 93871. > An updated version of the patch is attached. Regression tests (and new > test cases) are pending. > > Changes since Steve's patch of note: > > * libgfortran/intrinsics/trigd.c now indirectly includes trigd.inc > (formerly trigd_inc.c) through trigd_lib.inc. trigd.inc is now written > using GMP/MPFR functions, so that the same file can be included from > the front-end for simplification. The GMP/MPFR functions are > pre-processed into native code by trigd_lib.inc. This ensures that > both the FE and the library are using the same code for resolving > these functions, preventing future maintenance woes. > > * TAND(90, 270) returns +Infinity and -Infinity, instead of NaN. This > is compatible with behavior of (at least some) DEC compilers. > > * COTAN[D] are implemented as -TAN[D](x + 90 degrees) rather than 1 / > COTAN[D] for speed and to avoid singularities (though the new > implementation of TAND allows 1 / TAND to return zero when TAND > returns infinity). > > * SMALL thresholds and signs of some specific values are corrected. > For REAL(10) and REAL(16), the SMALL threshold for SIND(x) = D2R(x) is > eliminated, since there would be loss of precision. The other > thresholds achieve COSD(x) = 1 and SIND(x) = D2R(x) without loss of > precision. > > ChangeLogs are below. I will post an update soon after I perform > regression tests, which include some new tests which I will add. > > gcc/fortran/ChangeLog: > > PR fortran/93871 > > * gfortran.h (GFC_ISYM_ACOSD, GFC_ISYM_ASIND, GFC_ISYM_ATAN2D, > GFC_ISYM_ATAND, GFC_ISYM_COSD, GFC_ISYM_COTAND, GFC_ISYM_SIND, > GFC_ISYM_TAND): New. > * intrinsic.c (add_functions): Remove check for flag_dec_math. > Give degree trig functions simplification and name resolution > functions (e.g, gfc_simplify_atrigd () and gfc_resolve_atrigd ()). > (do_simplify): Remove special casing of degree trig functions. > * intrinsic.h (gfc_simplify_acosd, gfc_simplify_asind, > gfc_simplify_atand, gfc_simplify_cosd, gfc_simplify_cotand, > gfc_simplify_sind, gfc_simplify_tand, gfc_resolve_trigd2): Add new > prototypes. > (gfc_simplify_atrigd, gfc_simplify_trigd, gfc_resolve_cotan, > resolve_atrigd): Remove prototypes of deleted functions. > * iresolve.c (is_trig_resolved, copy_replace_function_shallow, > gfc_resolve_cotan, get_radians, get_degrees, resolve_trig_call, > gfc_resolve_atrigd, gfc_resolve_atan2d): Delete functions. > (gfc_resolve_trigd, gfc_resolve_trigd2): Resolve to library functions. > * simplify.c (rad2deg, deg2rad, gfc_simplify_acosd, gfc_simplify_asind, > gfc_simplify_atand, gfc_simplify_atan2d, gfc_simplify_cosd, > gfc_simplify_sind, gfc_simplify_tand, gfc_simplify_cotand): New > functions. > (gfc_simplify_atan2): Fix error message. > (simplify_trig_call, gfc_simplify_trigd, gfc_simplify_atrigd, > radians_f): Delete functions. > * trans-intrinsic.c: Add LIB_FUNCTION decls for sind, cosd, tand. > (rad2deg, gfc_conv_intrinsic_atrigd, gfc_conv_intrinsic_cotan, > gfc_conv_intrinsic_cotand, gfc_conv_intrinsic_atan2d): New functions. > (gfc_conv_intrinsic_function): Handle ACOSD, ASIND, ATAND, COTAN, > COTAND, ATAN2D. > * trigd_fe.inc: New file. Included by simplify.c to implement > simplify_sind, simplify_cosd, simplify_tand with code common to the > libgfortran implementation. > > libgfortran/ChangeLog: > > PR fortran/93871 > * Makefile.am, Makefile.in: New make rule for intrinsics/trigd.c. > * gfortran.map: New routines for {sind, cosd, tand}X{r4, r8, r10, r16}. > * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc: > New files. Defines native degree-valued trig functions.