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]

Re: [RFC Patch]: Implement remainder() as built-in function [PR fortran/24518]


Hello!

optimization point of view.  Currently -fno-errno-math ignores errno
completely and -ferrno-math tries to match the C library behavior by
re-dispatching to it for setting errno (where possible - so, not for lrint
for example).  One problem is that gcc does currently not know how to
access the errno location, so it has to dispatch to libc always for this.

Attached revision incorporates all Roger's suggestions, and the reason that we can't short-cut for y=0 was highlighted in my previous message. The call to libc is needed for the reason outlined by Richard in above text.

BTW: During november 2005 i have exchanged many (private) mails with
Paul Thomas about MOD optimizations The discussion died at that time,
but this patch picks up, where we left.

BTW2: I have renamed drem optab to remainder in the gcc sources, as
"remainder"  is standardised C99 function name, where "drem" is
considered an obsoleted synonym.

Patch is bootstrapped on i686-pc-linux-gnu and fully regression tested
for c, c++ and fortran. A compile-time test is included.

OK for mainline?

2006-10-24 Uros Bizjak <uros@kss-loka.si>

	* optabs.h (enum optab_index): Rename OTI_drem to OTI_remainder.
	(remainder_optab): Define corresponding macro.
	(drem_optab): Remove.
	* optabs.c (init_optabs): Initialize remainder_optab.  Remove
	drem_optab initialization.
	* genopinit.c (optabs): Implement remainder_optab using
	remainder?f3 patterns.  Remove drem_optab.
	* builtins.c (expand_builtin_mathfn_2): Handle
	BUILT_IN_REMAINDER{,F,L} using remainder_optab.
	(expand_builtin): Expand BUILT_IN_REMAINDER{,F,L} using
	expand_builtin_mathfn_2.

	(expand_builtin) [BUILT_IN_FMOD], [BUILT_IN_DREM]: Do not
	depend on flag_unsafe_math_optimizations.

	* config/i386/i386.md ("remaindersf3", "remainderdf3")
	("remainderxf3"): Renamed from "drem{s,d,x}f3" expanders.
	Do not depend on flag_unsafe_math_optimizations.  Use
	truncxf?f expander instead of truncxf?f_i387_noop.

	("fpremxf4", "fprem1xf4"): Do not depend on
	flag_unsafe_math_optimizations.
	("fmodsf3", "fmoddf3", "fmodxf3"): Do not depend on
	flag_unsafe_math_optimizations.  Use truncxf?f expander
	instead of truncxf?f_i387_noop.

testsuite/ChangeLog:

	* gcc.dg/builtins-40.c: Also check remainder(), remainderf()
	and remainderl() built-in functions.  Remove -ffast-math from
	dg-options.

Uros.

Attachment: i386-remainder-2.diff
Description: Binary data


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