This is the mail archive of the gcc-cvs@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]

r231229 - in /trunk/gcc: ChangeLog config/aarch...


Author: rsandifo
Date: Thu Dec  3 14:31:55 2015
New Revision: 231229

URL: https://gcc.gnu.org/viewcvs?rev=231229&root=gcc&view=rev
Log:
Add an rsqrt_optab and IFN_RSQRT internal function

All current uses of builtin_reciprocal convert 1.0/sqrt into rsqrt.
This patch adds an rsqrt optab and associated internal function for
that instead.  We can then pick up the vector forms of rsqrt automatically,
fixing an AArch64 regression from my internal_fn patches.

With that change, builtin_reciprocal only needs to handle target-specific
built-in functions.  I've restricted the hook to those since, if we need
a reciprocal of another standard function later, I think there should be
a strong preference for adding a new optab and internal function for it,
rather than hiding the code in a backend.

Three targets implement builtin_reciprocal: aarch64, i386 and rs6000.
i386 and rs6000 already used the obvious rsqrt<mode>2 pattern names
for the instructions, so they pick up the new code automatically.
aarch64 needs a slight rename.

mn10300 is unusual in that its native operation is rsqrt, and
sqrt is approximated as 1.0/rsqrt.  The port also uses rsqrt<mode>2
for the rsqrt pattern, so after the patch we now pick it up as a native
operation.

Two other ports define rsqrt patterns: sh and v850.  AFAICT these
patterns aren't currently used, but I think the patch does what the
authors of the patterns would have expected.  There's obviously some
risk of fallout though.

Tested on x86_64-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf
(as a target without the hooks) and powerpc64-linux-gnu.

gcc/
	* internal-fn.def (RSQRT): New function.
	* optabs.def (rsqrt_optab): New optab.
	* doc/md.texi (rsqrtM2): Document.
	* target.def (builtin_reciprocal): Replace gcall argument with
	a function decl.  Restrict hook to machine functions.
	* doc/tm.texi: Regenerate.
	* targhooks.h (default_builtin_reciprocal): Update prototype.
	* targhooks.c (default_builtin_reciprocal): Likewise.
	* tree-ssa-math-opts.c: Include internal-fn.h.
	(internal_fn_reciprocal): New function.
	(pass_cse_reciprocals::execute): Call it, and build a call to an
	internal function on success.  Only call targetm.builtin_reciprocal
	for machine functions.
	* config/aarch64/aarch64-protos.h (aarch64_builtin_rsqrt): Remove
	second argument.
	* config/aarch64/aarch64-builtins.c (aarch64_expand_builtin_rsqrt):
	Rename aarch64_rsqrt_<mode>2 to rsqrt<mode>2.
	(aarch64_builtin_rsqrt): Remove md_fn argument and only handle
	machine functions.
	* config/aarch64/aarch64.c (use_rsqrt_p): New function.
	(aarch64_builtin_reciprocal): Replace gcall argument with a
	function decl.  Use use_rsqrt_p.  Remove optimize_size check.
	Only handle machine functions.  Update call to aarch64_builtin_rsqrt.
	(aarch64_optab_supported_p): New function.
	(TARGET_OPTAB_SUPPORTED_P): Define.
	* config/aarch64/aarch64-simd.md (aarch64_rsqrt_<mode>2): Rename to...
	(rsqrt<mode>2): ...this.
	* config/i386/i386.c (use_rsqrt_p): New function.
	(ix86_builtin_reciprocal): Replace gcall argument with a
	function decl.  Use use_rsqrt_p.  Remove optimize_insn_for_size_p
	check.  Only handle machine functions.
	(ix86_optab_supported_p): Handle rsqrt_optab.
	* config/rs6000/rs6000.c (TARGET_OPTAB_SUPPORTED_P): Define.
	(rs6000_builtin_reciprocal): Replace gcall argument with a
	function decl.  Remove optimize_insn_for_size_p check.
	Only handle machine functions.
	(rs6000_optab_supported_p): New function.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/aarch64/aarch64-builtins.c
    trunk/gcc/config/aarch64/aarch64-protos.h
    trunk/gcc/config/aarch64/aarch64-simd.md
    trunk/gcc/config/aarch64/aarch64.c
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/doc/md.texi
    trunk/gcc/doc/tm.texi
    trunk/gcc/internal-fn.def
    trunk/gcc/optabs.def
    trunk/gcc/target.def
    trunk/gcc/targhooks.c
    trunk/gcc/targhooks.h
    trunk/gcc/tree-ssa-math-opts.c


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