Commit Graph

9 Commits

Author SHA1 Message Date
Torvald Riegel 969a32ce93 Fix __atomic to not implement atomic loads with CAS.
gcc/
	* builtins.c (fold_builtin_atomic_always_lock_free): Make "lock-free"
	conditional on existance of a fast atomic load.
	* optabs-query.c (can_atomic_load_p): New function.
	* optabs-query.h (can_atomic_load_p): Declare it.
	* optabs.c (expand_atomic_exchange): Always delegate to libatomic if
	no fast atomic load is available for the particular size of access.
	(expand_atomic_compare_and_swap): Likewise.
	(expand_atomic_load): Likewise.
	(expand_atomic_store): Likewise.
	(expand_atomic_fetch_op): Likewise.
	* testsuite/lib/target-supports.exp
	(check_effective_target_sync_int_128): Remove x86 because it provides
	no fast atomic load.
	(check_effective_target_sync_int_128_runtime): Likewise.

libatomic/
	* acinclude.m4: Add #define FAST_ATOMIC_LDST_*.
	* auto-config.h.in: Regenerate.
	* config/x86/host-config.h (FAST_ATOMIC_LDST_16): Define to 0.
	(atomic_compare_exchange_n): New.
	* glfree.c (EXACT, LARGER): Change condition and add comments.

From-SVN: r245098
2017-02-01 17:21:59 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 96592eeda1 re PR target/78102 (GCC refuses to generate PCMPEQQ instruction for SSE4.1)
PR target/78102
	* optabs.def (vcondeq_optab, vec_cmpeq_optab): New optabs.
	* optabs.c (expand_vec_cond_expr): For comparison codes
	EQ_EXPR and NE_EXPR, attempt vcondeq_optab as fallback.
	(expand_vec_cmp_expr): For comparison codes
	EQ_EXPR and NE_EXPR, attempt vec_cmpeq_optab as fallback.
	* optabs-tree.h (expand_vec_cmp_expr_p, expand_vec_cond_expr_p):
	Add enum tree_code argument.
	* optabs-query.h (get_vec_cmp_eq_icode, get_vcond_eq_icode): New
	inline functions.
	* optabs-tree.c (expand_vec_cmp_expr_p): Add CODE argument.  For
	CODE EQ_EXPR or NE_EXPR, attempt to use vec_cmpeq_optab as
	fallback.
	(expand_vec_cond_expr_p): Add CODE argument.  For CODE EQ_EXPR or
	NE_EXPR, attempt to use vcondeq_optab as fallback.
	* tree-vect-generic.c (expand_vector_comparison,
	expand_vector_divmod, expand_vector_condition): Adjust
	expand_vec_cmp_expr_p and expand_vec_cond_expr_p callers.
	* tree-vect-stmts.c (vectorizable_condition,
	vectorizable_comparison): Likewise.
	* tree-vect-patterns.c (vect_recog_mixed_size_cond_pattern,
	check_bool_pattern, search_type_for_mask_1): Likewise.
	* expr.c (do_store_flag): Likewise.
	* doc/md.texi (@code{vec_cmpeq@var{m}@var{n}},
	@code{vcondeq@var{m}@var{n}}): Document.
	* config/i386/sse.md (vec_cmpeqv2div2di, vcondeq<VI8F_128:mode>v2di):
	New expanders.
testsuite/
	* gcc.target/i386/pr78102.c: New test.

From-SVN: r241525
2016-10-25 18:26:12 +02:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Richard Sandiford d95ab70a3c 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
2015-12-02 09:08:49 +00:00
Ilya Enkovich a414c77f2a optabs-query.h (get_vcond_mask_icode): New.
gcc/

2015-11-10  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* optabs-query.h (get_vcond_mask_icode): New.
	* optabs-tree.c (expand_vec_cond_expr_p): Use
	get_vcond_mask_icode for VEC_COND_EXPR with mask.
	* optabs.c (expand_vec_cond_mask_expr): New.
	(expand_vec_cond_expr): Use get_vcond_mask_icode
	when possible.
	* optabs.def (vcond_mask_optab): New.
	* tree-vect-patterns.c (vect_recog_bool_pattern): Don't
	generate redundant comparison for COND_EXPR.
	* tree-vect-stmts.c (vect_is_simple_cond): Allow SSA_NAME
	as a condition.
	(vectorizable_condition): Likewise.
	* tree-vect-slp.c (vect_get_and_check_slp_defs): Allow
	cond_exp with no embedded comparison.
	(vect_build_slp_tree_1): Likewise.

From-SVN: r230101
2015-11-10 12:14:19 +00:00
Ilya Enkovich 045c12782c internal-fn.c (expand_MASK_LOAD): Adjust to maskload optab changes.
gcc/

	* internal-fn.c (expand_MASK_LOAD): Adjust to maskload optab changes.
	(expand_MASK_STORE): Adjust to maskstore optab changes.
	* optabs-query.c (can_vec_mask_load_store_p): Add MASK_MODE arg.
	 Adjust to maskload, maskstore optab changes.
	* optabs-query.h (can_vec_mask_load_store_p): Add MASK_MODE arg.
	* optabs.def (maskload_optab): Transform into convert optab.
	(maskstore_optab): Likewise.
	* tree-if-conv.c (ifcvt_can_use_mask_load_store): Adjust to
	can_vec_mask_load_store_p signature change.
	(predicate_mem_writes): Use boolean mask.
	* tree-vect-stmts.c (vectorizable_mask_load_store): Adjust to
	can_vec_mask_load_store_p signature change.  Allow invariant masks.
	(vectorizable_operation): Ignore type precision for boolean vectors.

gcc/testsuite/

	* gcc.target/i386/avx2-vec-mask-bit-not.c: New test.

From-SVN: r230099
2015-11-10 12:06:05 +00:00
Ilya Enkovich 42fd8198b4 expr.c (do_store_flag): Use expand_vec_cmp_expr for mask results.
gcc/

	* expr.c (do_store_flag): Use expand_vec_cmp_expr for mask results.
	(const_vector_mask_from_tree): New.
	(const_vector_from_tree): Use const_vector_mask_from_tree
	for boolean vectors.
	* optabs-query.h (get_vec_cmp_icode): New.
	* optabs-tree.c (expand_vec_cmp_expr_p): New.
	* optabs-tree.h (expand_vec_cmp_expr_p): New.
	* optabs.c (vector_compare_rtx): Add OPNO arg.
	(expand_vec_cond_expr): Adjust to vector_compare_rtx change.
	(expand_vec_cmp_expr): New.
	* optabs.def (vec_cmp_optab): New.
	(vec_cmpu_optab): New.
	* optabs.h (expand_vec_cmp_expr): New.
	* tree-vect-generic.c (expand_vector_comparison): Add vector
	comparison optabs check.
	* tree-vect-loop.c (vect_determine_vectorization_factor):  Ignore mask
	operations for VF.  Add mask type computation.
	* tree-vect-stmts.c (get_mask_type_for_scalar_type): New.
	(vectorizable_comparison): New.
	(vect_analyze_stmt): Add vectorizable_comparison.
	(vect_transform_stmt): Likewise.
	(vect_init_vector): Support boolean vector invariants.
	(vect_get_vec_def_for_operand): Add VECTYPE arg.
	(vectorizable_condition): Directly provide vectype for invariants
	used in comparison.
	* tree-vectorizer.h (get_mask_type_for_scalar_type): New.
	(enum vect_var_kind): Add vect_mask_var.
	(enum stmt_vec_info_type): Add comparison_vec_info_type.
	(vectorizable_comparison): New.
	(vect_get_vec_def_for_operand): Add VECTYPE arg.
	* tree-vect-data-refs.c (vect_get_new_vect_var): Support vect_mask_var.
	(vect_create_destination_var): Likewise.
	* tree-vect-patterns.c (check_bool_pattern): Check fails
	if we can vectorize comparison directly.
	(search_type_for_mask): New.
	(vect_recog_bool_pattern): Support cases when bool pattern
	check fails.
	* tree-vect-slp.c (vect_build_slp_tree_1): Allow
	comparison statements.
	(vect_get_constant_vectors): Support boolean vector
	constants.
	* config/i386/i386-protos.h (ix86_expand_mask_vec_cmp): New.
	(ix86_expand_int_vec_cmp): New.
	(ix86_expand_fp_vec_cmp): New.
	* config/i386/i386.c (ix86_expand_sse_cmp): Allow NULL for
	op_true and op_false.
	(ix86_int_cmp_code_to_pcmp_immediate): New.
	(ix86_fp_cmp_code_to_pcmp_immediate): New.
	(ix86_cmp_code_to_pcmp_immediate): New.
	(ix86_expand_mask_vec_cmp): New.
	(ix86_expand_fp_vec_cmp): New.
	(ix86_expand_int_sse_cmp): New.
	(ix86_expand_int_vcond): Use ix86_expand_int_sse_cmp.
	(ix86_expand_int_vec_cmp): New.
	(ix86_get_mask_mode): New.
	(TARGET_VECTORIZE_GET_MASK_MODE): New.
	* config/i386/sse.md (avx512fmaskmodelower): New.
	(vec_cmp<mode><avx512fmaskmodelower>): New.
	(vec_cmp<mode><sseintvecmodelower>): New.
	(vec_cmpv2div2di): New.
	(vec_cmpu<mode><avx512fmaskmodelower>): New.
	(vec_cmpu<mode><sseintvecmodelower>): New.
	(vec_cmpuv2div2di): New.

gcc/testsuite/

	* gcc.dg/vect/slp-cond-5.c: New test.

From-SVN: r230098
2015-11-10 11:57:34 +00:00
Richard Sandiford 385399a875 Split up optabs.[hc]
optabs.[hc] is a bit of a behemoth.  It includes basic functions for querying
what a target can do, related tree- and gimple-level query functions,
related rtl-level query functions, and the functions that actually
generate code.  Some gimple optimisations therefore need:

#include "insn-config.h"
#include "expmed.h"
#include "dojump.h"
#include "explow.h"
#include "emit-rtl.h"
#include "varasm.h"
#include "stmt.h"
#include "expr.h"

purely to query whether the target has support for a particular operation.

This patch splits optabs up as follows:

      - optabs-query.[hc]: IL-independent functions for querying what a target
          can do natively.
      - optabs-tree.[hc]: tree and gimple query functions (an extension of
          optabs-query.[hc]).
      - optabs-libfuncs.[hc]: optabs-specific libfuncs (an extension of
          libfuncs.h)
      - optabs.h: For now includes optabs-query.h and optabs-libfuncs.h.

Only two files outside optabs need to include both optabs.h and
optabs-tree.h: expr.c and function.c.  I think that's expected given
that both are related to expand.

It might be good to split optabs.h further, but this is already quite
a big patch.

I changed can_conditionally_move_p from returning an int to returning
a bool and fixed a few formatting glitches.  There should be no other
changes to the functions themselves.

gcc/
	* Makefile.in (OBJS): Add optabs-libfuncs.o, optabs-query.o
	and optabs-tree.o.
	(GTFILES): Replace optabs.c with optabs-libfunc.c.
	* genopinit.c (main): Add an include guard to insn-opinit.h.
	Protect the rtx_code parts with NUM_RTX_CODE.
	* optabs.h: Split parts out to...
	* optabs-libfuncs.h, optabs-query.h, optabs-tree.h: ...these
	new files.
	* optabs.c: Split parts out to...
	* optabs-libfuncs.c, optabs-query.c, optabs-tree.c: ...these
	new files.
	* cilk-common.c: Include optabs-query.h rather than optabs.h.
	* fold-const.c: Likewise.
	* target-globals.c: Likewise.
	* tree-if-conv.c: Likewise.
	* tree-ssa-forwprop.c: Likewise.
	* tree-ssa-loop-prefetch.c: Likewise.
	* tree-ssa-math-opts.c: Include optabs-tree.h rather than
	optabs.h.  Remove unncessary include files.
	* tree-ssa-phiopt.c: Likewise.
	* tree-ssa-reassoc.c: Likewise.
	* tree-switch-conversion.c: Likewise.
	* tree-vect-data-refs.c: Likewise.
	* tree-vect-generic.c: Likewise.
	* tree-vect-loop.c: Likewise.
	* tree-vect-patterns.c: Likewise.
	* tree-vect-slp.c: Likewise.
	* tree-vect-stmts.c: Likewise.
	* tree-vrp.c: Likewise.
	* toplev.c: Include optabs-query.h and optabs-libfuncs.h
	rather than optabs.h.
	* expr.c: Include optabs-tree.h.
	* function.c: Likewise.

From-SVN: r227865
2015-09-17 14:28:59 +00:00