This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Reduce rounding overhead in sin/cos/tan functions on x86


The trigonometric functions of children of Ada.Numerics are implemented by
inline assembly statements on the x86 architecture, and for sin/cos/tan
a special range reduction algorithm is used to avoid a loss of accuracy in
range reduction implemented in hardware on x86 processors.

This algorithm contains a rounding step and it was implemented inefficiently
by a call to a routine of the runtime.  This patch changes it to using a more
efficient inline sequence of machine instructions instead.

The same change is applied to the range reduction algorithm used prior to
calling the libc routines on PowerPC/Darwin.

The patch also changes the definition of the Double type used to interface
the libc routines in other implementations so as to use the built-in type
corresponding to the C type (Long_Float, except for Long_Long_Float on x86).

Compiling the following package at -O2 -gnatpgn must yield no calls to the
rounding routines of the runtime on x86:

with Ada.Numerics.Generic_Elementary_Functions;

package P is new Ada.Numerics.Generic_Elementary_Functions (Long_Float);

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-04-25  Eric Botcazou  <ebotcazou@adacore.com>

	* a-numaux.ads: Fix description of a-numaux-darwin
	and a-numaux-x86.
	(Double): Define to Long_Float.
	* a-numaux-vxworks.ads (Double): Likewise.
	* a-numaux-darwin.ads
	(Double): Likewise.
	* a-numaux-libc-x86.ads (Double): Define to Long_Long_Float.
	* a-numaux-x86.ads: Fix package description.
	* a-numaux-x86.adb (Is_Nan): Minor tweak.
	(Reduce): Adjust and complete description. Call Is_Nan instead of
	testing manually. Use an integer temporary to hold rounded value.
	* a-numaux-darwin.adb (Reduce): Likewise.
	(Is_Nan): New function.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]