aboutsummaryrefslogtreecommitdiff
path: root/gcc/optabs-query.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-12-02 09:08:49 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-12-02 09:08:49 +0000
commitd95ab70a3cab2998b4671d842e1ad769e75f19a3 (patch)
tree72dd378628c948224552d17ec9c275577e55462a /gcc/optabs-query.c
parent886456e210ef12d77f625ace8f312ab23d208aff (diff)
downloadgcc-d95ab70a3cab2998b4671d842e1ad769e75f19a3.zip
gcc-d95ab70a3cab2998b4671d842e1ad769e75f19a3.tar.gz
gcc-d95ab70a3cab2998b4671d842e1ad769e75f19a3.tar.bz2
PR 68432: Add a target hook to control size/speed optab choices
The problem in the PR is that some i386 optabs FAIL when optimising for size rather than speed. The gimple level generally needs access to this information before calling the generator, so this patch adds a new hook to say whether an optab should be used when optimising for size or speed. It also has a "both" option for cases where we want code that is optimised for both size and speed. I've passed the optab to the target hook because I think in most cases that's more useful than the instruction code. We could pass both if there's a use for it though. At the moment the match-and-simplify code doesn't have direct access to the target block, so for now I've used "both" there. Tested on x86_64-linux-gnu and powerpc64-linux-gnu. gcc/ PR tree-optimization/68432 * coretypes.h (optimization_type): New enum. * doc/tm.texi.in (TARGET_OPTAB_SUPPORTED_P): New hook. * doc/tm.texi: Regenerate. * target.def (optab_supported_p): New hook. * targhooks.h (default_optab_supported_p): Declare. * targhooks.c (default_optab_supported_p): New function. * predict.h (function_optimization_type): Declare. (bb_optimization_type): Likewise. * predict.c (function_optimization_type): New function. (bb_optimization_type): Likewise. * optabs-query.h (convert_optab_handler): Define an overload that takes an optimization type. (direct_optab_handler): Likewise. * optabs-query.c (convert_optab_handler): Likewise. (direct_optab_handler): Likewise. * internal-fn.h (direct_internal_fn_supported_p): Take an optimization_type argument. * internal-fn.c (direct_optab_supported_p): Likewise. (multi_vector_optab_supported_p): Likewise. (direct_internal_fn_supported_p): Likewise. * builtins.c (replacement_internal_fn): Update call to direct_internal_fn_supported_p. * gimple-match-head.c (build_call_internal): Likewise. * tree-vect-patterns.c (vect_recog_pow_pattern): Likewise. * tree-vect-stmts.c (vectorizable_internal_function): Likewise. * tree.c (maybe_build_call_expr_loc): Likewise. * config/i386/i386.c (ix86_optab_supported_p): New function. (TARGET_OPTAB_SUPPORTED_P): Define. * config/i386/i386.md (asinxf2): Remove optimize_insn_for_size_p check. (asin<mode>2, acosxf2, acos<mode>2, log1pxf2, log1p<mode>2) (expNcorexf3, expxf2, exp<mode>2, exp10xf2, exp10<mode>2, exp2xf2) (exp2<mode>2, expm1xf2, expm1<mode>2, ldexpxf3, ldexp<mode>3) (scalbxf3, scalb<mode>3, rint<mode>2, round<mode>2) (<rounding_insn>xf2, <rounding_insn><mode>2): Likewise. gcc/testsuite/ * gcc.target/i386/pr68432-1.c: New test. * gcc.target/i386/pr68432-2.c: Likewise. * gcc.target/i386/pr68432-3.c: Likewise. From-SVN: r231161
Diffstat (limited to 'gcc/optabs-query.c')
-rw-r--r--gcc/optabs-query.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/optabs-query.c b/gcc/optabs-query.c
index c20597c..2f9c7cd 100644
--- a/gcc/optabs-query.c
+++ b/gcc/optabs-query.c
@@ -35,6 +35,36 @@ struct target_optabs *this_fn_optabs = &default_target_optabs;
struct target_optabs *this_target_optabs = &default_target_optabs;
#endif
+/* Return the insn used to perform conversion OP from mode FROM_MODE
+ to mode TO_MODE; return CODE_FOR_nothing if the target does not have
+ such an insn, or if it is unsuitable for optimization type OPT_TYPE. */
+
+insn_code
+convert_optab_handler (convert_optab optab, machine_mode to_mode,
+ machine_mode from_mode, optimization_type opt_type)
+{
+ insn_code icode = convert_optab_handler (optab, to_mode, from_mode);
+ if (icode == CODE_FOR_nothing
+ || !targetm.optab_supported_p (optab, to_mode, from_mode, opt_type))
+ return CODE_FOR_nothing;
+ return icode;
+}
+
+/* Return the insn used to implement mode MODE of OP; return
+ CODE_FOR_nothing if the target does not have such an insn,
+ or if it is unsuitable for optimization type OPT_TYPE. */
+
+insn_code
+direct_optab_handler (convert_optab optab, machine_mode mode,
+ optimization_type opt_type)
+{
+ insn_code icode = direct_optab_handler (optab, mode);
+ if (icode == CODE_FOR_nothing
+ || !targetm.optab_supported_p (optab, mode, mode, opt_type))
+ return CODE_FOR_nothing;
+ return icode;
+}
+
/* Enumerates the possible types of structure operand to an
extraction_insn. */
enum extraction_type { ET_unaligned_mem, ET_reg };