summaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-30 14:56:08 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-30 14:56:08 +0000
commit851c1b0cf306bd436efb3daefc3bc6d8d13b97cb (patch)
tree85c8ca3151ec7fc442e5d5aa3ec4917317da3cff /gcc/config
parenteec2f3074df2224e0de2473225dc66c4483c54bf (diff)
downloadgcc-851c1b0cf306bd436efb3daefc3bc6d8d13b97cb.tar.gz
PR tree-optimization/68501
* target.def (builtin_reciprocal): Replace the 3 arguments with a gcall * one, adjust description. * targhooks.h (default_builtin_reciprocal): Replace the 3 arguments with a gcall * one. * targhooks.c (default_builtin_reciprocal): Likewise. * tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Use targetm.builtin_reciprocal even on internal functions, adjust the arguments and allow replacing an internal function with normal built-in. * config/i386/i386.c (ix86_builtin_reciprocal): Replace the 3 arguments with a gcall * one. Handle internal fns too. * config/rs6000/rs6000.c (rs6000_builtin_reciprocal): Likewise. * config/aarch64/aarch64.c (aarch64_builtin_reciprocal): Likewise. * doc/tm.texi (builtin_reciprocal): Document. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231075 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/aarch64/aarch64.c12
-rw-r--r--gcc/config/i386/i386.c32
-rw-r--r--gcc/config/rs6000/rs6000.c38
3 files changed, 68 insertions, 14 deletions
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 3fe2f0f180d..b150283569d 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -7103,19 +7103,21 @@ aarch64_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED,
reciprocal square root builtins. */
static tree
-aarch64_builtin_reciprocal (unsigned int fn,
- bool md_fn,
- bool)
+aarch64_builtin_reciprocal (gcall *call)
{
if (flag_trapping_math
|| !flag_unsafe_math_optimizations
|| optimize_size
|| ! (aarch64_tune_params.extra_tuning_flags
& AARCH64_EXTRA_TUNE_RECIP_SQRT))
- {
return NULL_TREE;
- }
+ if (gimple_call_internal_p (call)
+ return NULL_TREE;
+
+ tree fndecl = gimple_call_fndecl (call);
+ enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
+ bool md_fn = DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD;
return aarch64_builtin_rsqrt (fn, md_fn);
}
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 2ac6c259f41..23a42734007 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -42680,16 +42680,40 @@ ix86_vectorize_builtin_scatter (const_tree vectype,
reciprocal of the function, or NULL_TREE if not available. */
static tree
-ix86_builtin_reciprocal (unsigned int fn, bool md_fn, bool)
+ix86_builtin_reciprocal (gcall *call)
{
if (! (TARGET_SSE_MATH && !optimize_insn_for_size_p ()
&& flag_finite_math_only && !flag_trapping_math
&& flag_unsafe_math_optimizations))
return NULL_TREE;
- if (md_fn)
+ if (gimple_call_internal_p (call))
+ switch (gimple_call_internal_fn (call))
+ {
+ tree type;
+ case IFN_SQRT:
+ type = TREE_TYPE (gimple_call_lhs (call));
+ switch (TYPE_MODE (type))
+ {
+ /* Vectorized version of sqrt to rsqrt conversion. */
+ case V4SFmode:
+ return ix86_get_builtin (IX86_BUILTIN_RSQRTPS_NR);
+
+ case V8SFmode:
+ return ix86_get_builtin (IX86_BUILTIN_RSQRTPS_NR256);
+
+ default:
+ return NULL_TREE;
+ }
+
+ default:
+ return NULL_TREE;
+ }
+
+ tree fndecl = gimple_call_fndecl (call);
+ if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
/* Machine dependent builtins. */
- switch (fn)
+ switch (DECL_FUNCTION_CODE (fndecl))
{
/* Vectorized version of sqrt to rsqrt conversion. */
case IX86_BUILTIN_SQRTPS_NR:
@@ -42703,7 +42727,7 @@ ix86_builtin_reciprocal (unsigned int fn, bool md_fn, bool)
}
else
/* Normal builtins. */
- switch (fn)
+ switch (DECL_FUNCTION_CODE (fndecl))
{
/* Sqrt to rsqrt conversion. */
case BUILT_IN_SQRTF:
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a38e70d2c33..c4e3f2fb538 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -32643,14 +32643,42 @@ rs6000_memory_move_cost (machine_mode mode, reg_class_t rclass,
reciprocal of the function, or NULL_TREE if not available. */
static tree
-rs6000_builtin_reciprocal (unsigned int fn, bool md_fn,
- bool sqrt ATTRIBUTE_UNUSED)
+rs6000_builtin_reciprocal (gcall *call)
{
if (optimize_insn_for_size_p ())
return NULL_TREE;
- if (md_fn)
- switch (fn)
+ if (gimple_call_internal_p (call))
+ switch (gimple_call_internal_fn (call))
+ {
+ tree type;
+ case IFN_SQRT:
+ type = TREE_TYPE (gimple_call_lhs (call));
+ switch (TYPE_MODE (type))
+ {
+ case V2DFmode:
+ if (!RS6000_RECIP_AUTO_RSQRTE_P (V2DFmode))
+ return NULL_TREE;
+
+ return rs6000_builtin_decls[VSX_BUILTIN_RSQRT_2DF];
+
+ case V4SFmode:
+ if (!RS6000_RECIP_AUTO_RSQRTE_P (V4SFmode))
+ return NULL_TREE;
+
+ return rs6000_builtin_decls[VSX_BUILTIN_RSQRT_4SF];
+
+ default:
+ return NULL_TREE;
+ }
+
+ default:
+ return NULL_TREE;
+ }
+
+ tree fndecl = gimple_call_fndecl (call);
+ if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
+ switch (DECL_FUNCTION_CODE (fndecl))
{
case VSX_BUILTIN_XVSQRTDP:
if (!RS6000_RECIP_AUTO_RSQRTE_P (V2DFmode))
@@ -32669,7 +32697,7 @@ rs6000_builtin_reciprocal (unsigned int fn, bool md_fn,
}
else
- switch (fn)
+ switch (DECL_FUNCTION_CODE (fndecl))
{
case BUILT_IN_SQRT:
if (!RS6000_RECIP_AUTO_RSQRTE_P (DFmode))