2011-04-20 10:21:25 +02:00
|
|
|
/* Internal functions.
|
2017-01-01 13:07:43 +01:00
|
|
|
Copyright (C) 2011-2017 Free Software Foundation, Inc.
|
2011-04-20 10:21:25 +02:00
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#ifndef GCC_INTERNAL_FN_H
|
|
|
|
#define GCC_INTERNAL_FN_H
|
|
|
|
|
2016-09-27 18:46:21 +02:00
|
|
|
/* INTEGER_CST values for IFN_UNIQUE function arg-0.
|
|
|
|
|
|
|
|
UNSPEC: Undifferentiated UNIQUE.
|
|
|
|
|
|
|
|
FORK and JOIN mark the points at which OpenACC partitioned
|
|
|
|
execution is entered or exited.
|
|
|
|
DEP_VAR = UNIQUE ({FORK,JOIN}, DEP_VAR, AXIS)
|
|
|
|
|
|
|
|
HEAD_MARK and TAIL_MARK are used to demark the sequence entering
|
|
|
|
or leaving partitioned execution.
|
|
|
|
DEP_VAR = UNIQUE ({HEAD,TAIL}_MARK, REMAINING_MARKS, ...PRIMARY_FLAGS)
|
|
|
|
|
|
|
|
The PRIMARY_FLAGS only occur on the first HEAD_MARK of a sequence. */
|
|
|
|
#define IFN_UNIQUE_CODES \
|
|
|
|
DEF(UNSPEC), \
|
|
|
|
DEF(OACC_FORK), DEF(OACC_JOIN), \
|
|
|
|
DEF(OACC_HEAD_MARK), DEF(OACC_TAIL_MARK)
|
|
|
|
|
2015-10-27 21:16:04 +01:00
|
|
|
enum ifn_unique_kind {
|
2016-09-27 18:46:21 +02:00
|
|
|
#define DEF(X) IFN_UNIQUE_##X
|
|
|
|
IFN_UNIQUE_CODES
|
|
|
|
#undef DEF
|
internal-fn.def (IFN_GOACC_DIM_SIZE, [...]): New.
* internal-fn.def (IFN_GOACC_DIM_SIZE, IFN_GOACC_DIM_POS,
IFN_GOACC_LOOP): New.
* internal-fn.h (enum ifn_unique_kind): Add IFN_UNIQUE_OACC_FORK,
IFN_UNIQUE_OACC_JOIN, IFN_UNIQUE_OACC_HEAD_MARK,
IFN_UNIQUE_OACC_TAIL_MARK.
(enum ifn_goacc_loop_kind): New.
* internal-fn.c (expand_UNIQUE): Add IFN_UNIQUE_OACC_FORK,
IFN_UNIQUE_OACC_JOIN cases.
(expand_GOACC_DIM_SIZE, expand_GOACC_DIM_POS): New.
(expand_GOACC_LOOP): New.
* target-insns.def (oacc_dim_pos, oacc_dim_size): New.
* omp-low.c: Include gimple-pretty-print.h.
(struct oacc_loop): New.
(enum oacc_loop_flags): New.
(oacc_thread_numbers): New.
(oacc_xform_loop): New.
(new_oacc_loop_raw, new_oacc_loop_outer, new_oacc_loop,
new_oacc_loop_routine, finish_oacc_loop, free_oacc_loop): New,
(dump_oacc_loop_part, dump_oacc_loop, debug_oacc_loop): New,
(oacc_loop_discover_walk, oacc_loop_sibling_nrevers,
oacc_loop_discovery): New.
(oacc_loop_xform_head_tail, oacc_loop_xform_loop,
oacc_loop_process): New.
(oacc_loop_fixed_partitions, oacc_loop_partition): New.
(execute_oacc_device_lower): Discover & process loops. Process
internal fns.
* target.def (goacc.fork_join): Change sense of hook, clarify
documentation.
* doc/tm.texi: Regenerated.
From-SVN: r229466
2015-10-28 00:46:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* INTEGER_CST values for IFN_GOACC_LOOP arg-0. Allows the precise
|
|
|
|
stepping of the compute geometry over the loop iterations to be
|
|
|
|
deferred until it is known which compiler is generating the code.
|
|
|
|
The action is encoded in a constant first argument.
|
|
|
|
|
|
|
|
CHUNK_MAX = LOOP (CODE_CHUNKS, DIR, RANGE, STEP, CHUNK_SIZE, MASK)
|
|
|
|
STEP = LOOP (CODE_STEP, DIR, RANGE, STEP, CHUNK_SIZE, MASK)
|
|
|
|
OFFSET = LOOP (CODE_OFFSET, DIR, RANGE, STEP, CHUNK_SIZE, MASK, CHUNK_NO)
|
|
|
|
BOUND = LOOP (CODE_BOUND, DIR, RANGE, STEP, CHUNK_SIZE, MASK, OFFSET)
|
|
|
|
|
|
|
|
DIR - +1 for up loop, -1 for down loop
|
|
|
|
RANGE - Range of loop (END - BASE)
|
|
|
|
STEP - iteration step size
|
|
|
|
CHUNKING - size of chunking, (constant zero for no chunking)
|
|
|
|
CHUNK_NO - chunk number
|
|
|
|
MASK - partitioning mask. */
|
|
|
|
|
2016-09-27 18:46:21 +02:00
|
|
|
#define IFN_GOACC_LOOP_CODES \
|
|
|
|
DEF(CHUNKS), DEF(STEP), DEF(OFFSET), DEF(BOUND)
|
internal-fn.def (IFN_GOACC_DIM_SIZE, [...]): New.
* internal-fn.def (IFN_GOACC_DIM_SIZE, IFN_GOACC_DIM_POS,
IFN_GOACC_LOOP): New.
* internal-fn.h (enum ifn_unique_kind): Add IFN_UNIQUE_OACC_FORK,
IFN_UNIQUE_OACC_JOIN, IFN_UNIQUE_OACC_HEAD_MARK,
IFN_UNIQUE_OACC_TAIL_MARK.
(enum ifn_goacc_loop_kind): New.
* internal-fn.c (expand_UNIQUE): Add IFN_UNIQUE_OACC_FORK,
IFN_UNIQUE_OACC_JOIN cases.
(expand_GOACC_DIM_SIZE, expand_GOACC_DIM_POS): New.
(expand_GOACC_LOOP): New.
* target-insns.def (oacc_dim_pos, oacc_dim_size): New.
* omp-low.c: Include gimple-pretty-print.h.
(struct oacc_loop): New.
(enum oacc_loop_flags): New.
(oacc_thread_numbers): New.
(oacc_xform_loop): New.
(new_oacc_loop_raw, new_oacc_loop_outer, new_oacc_loop,
new_oacc_loop_routine, finish_oacc_loop, free_oacc_loop): New,
(dump_oacc_loop_part, dump_oacc_loop, debug_oacc_loop): New,
(oacc_loop_discover_walk, oacc_loop_sibling_nrevers,
oacc_loop_discovery): New.
(oacc_loop_xform_head_tail, oacc_loop_xform_loop,
oacc_loop_process): New.
(oacc_loop_fixed_partitions, oacc_loop_partition): New.
(execute_oacc_device_lower): Discover & process loops. Process
internal fns.
* target.def (goacc.fork_join): Change sense of hook, clarify
documentation.
* doc/tm.texi: Regenerated.
From-SVN: r229466
2015-10-28 00:46:39 +01:00
|
|
|
enum ifn_goacc_loop_kind {
|
2016-09-27 18:46:21 +02:00
|
|
|
#define DEF(X) IFN_GOACC_LOOP_##X
|
|
|
|
IFN_GOACC_LOOP_CODES
|
|
|
|
#undef DEF
|
2015-10-27 21:16:04 +01:00
|
|
|
};
|
|
|
|
|
2015-11-04 17:57:36 +01:00
|
|
|
/* The GOACC_REDUCTION function defines a generic interface to support
|
|
|
|
gang, worker and vector reductions. All calls are of the following
|
|
|
|
form:
|
|
|
|
|
|
|
|
V = REDUCTION (CODE, REF_TO_RES, LOCAL_VAR, LEVEL, OP, OFFSET)
|
|
|
|
|
|
|
|
REF_TO_RES - is a reference to the original reduction varl, may be NULL
|
|
|
|
LOCAL_VAR is the intermediate reduction variable
|
|
|
|
LEVEL corresponds to the GOMP_DIM of the reduction
|
|
|
|
OP is the tree code of the reduction operation
|
|
|
|
OFFSET may be used as an offset into a reduction array for the
|
|
|
|
reductions occuring at this level.
|
|
|
|
In general the return value is LOCAL_VAR, which creates a data
|
|
|
|
dependency between calls operating on the same reduction. */
|
|
|
|
|
2016-09-27 18:46:21 +02:00
|
|
|
#define IFN_GOACC_REDUCTION_CODES \
|
|
|
|
DEF(SETUP), DEF(INIT), DEF(FINI), DEF(TEARDOWN)
|
2015-11-04 17:57:36 +01:00
|
|
|
enum ifn_goacc_reduction_kind {
|
2016-09-27 18:46:21 +02:00
|
|
|
#define DEF(X) IFN_GOACC_REDUCTION_##X
|
|
|
|
IFN_GOACC_REDUCTION_CODES
|
|
|
|
#undef DEF
|
2015-11-04 17:57:36 +01:00
|
|
|
};
|
|
|
|
|
2014-08-11 08:06:29 +02:00
|
|
|
/* Initialize internal function tables. */
|
|
|
|
|
|
|
|
extern void init_internal_fns ();
|
|
|
|
|
2011-04-20 10:21:25 +02:00
|
|
|
/* Return the name of internal function FN. The name is only meaningful
|
|
|
|
for dumps; it has no linkage. */
|
|
|
|
|
2011-04-28 03:25:01 +02:00
|
|
|
extern const char *const internal_fn_name_array[];
|
|
|
|
|
2011-04-20 10:21:25 +02:00
|
|
|
static inline const char *
|
|
|
|
internal_fn_name (enum internal_fn fn)
|
|
|
|
{
|
|
|
|
return internal_fn_name_array[(int) fn];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the ECF_* flags for function FN. */
|
|
|
|
|
2011-04-28 03:25:01 +02:00
|
|
|
extern const int internal_fn_flags_array[];
|
|
|
|
|
2011-04-20 10:21:25 +02:00
|
|
|
static inline int
|
|
|
|
internal_fn_flags (enum internal_fn fn)
|
|
|
|
{
|
|
|
|
return internal_fn_flags_array[(int) fn];
|
|
|
|
}
|
|
|
|
|
2014-08-11 08:06:29 +02:00
|
|
|
/* Return fnspec for function FN. */
|
|
|
|
|
|
|
|
extern GTY(()) const_tree internal_fn_fnspec_array[IFN_LAST + 1];
|
|
|
|
|
|
|
|
static inline const_tree
|
|
|
|
internal_fn_fnspec (enum internal_fn fn)
|
|
|
|
{
|
|
|
|
return internal_fn_fnspec_array[(int) fn];
|
|
|
|
}
|
|
|
|
|
Add basic support for direct_optab internal functions
This patch adds a concept of internal functions that map directly to an
optab (here called "direct internal functions"). The function can only
be used if the associated optab can be used.
We currently have four functions like that:
- LOAD_LANES
- STORE_LANES
- MASK_LOAD
- MASK_STORE
so the patch converts them to the new infrastructure. These four
all need different types of optabs, but future patches will add
regular unary and binary ones.
In general we need one or two modes to decide whether an optab is
supported, depending on whether it's a convert_optab or not.
This in turn means that we need up to two types to decide whether
an internal function is supported. The patch records which types
are needed for each internal function, using -1 if the return type
should be used and N>=0 if the type of argument N should be used.
(LOAD_LANES and STORE_LANES are unusual in that both optab modes
come from the same array type.)
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* coretypes.h (tree_pair): New type.
* internal-fn.def (DEF_INTERNAL_OPTAB_FN): New macro. Use it
for MASK_LOAD, LOAD_LANES, MASK_STORE and STORE_LANES.
* internal-fn.h (direct_internal_fn_info): New structure.
(direct_internal_fn_array): Declare.
(direct_internal_fn_p, direct_internal_fn): New functions.
(direct_internal_fn_types, direct_internal_fn_supported_p): Declare.
* internal-fn.c (not_direct, mask_load_direct, load_lanes_direct)
(mask_store_direct, store_lanes_direct): New macros.
(direct_internal_fn_array) New array.
(get_multi_vector_move): Return the optab handler without asserting
that it is available.
(expand_LOAD_LANES): Rename to...
(expand_load_lanes_optab_fn): ...this and add an optab argument.
(expand_STORE_LANES): Rename to...
(expand_store_lanes_optab_fn): ...this and add an optab argument.
(expand_MASK_LOAD): Rename to...
(expand_mask_load_optab_fn): ...this and add an optab argument.
(expand_MASK_STORE): Rename to...
(expand_mask_store_optab_fn): ...this and add an optab argument.
(direct_internal_fn_types, direct_optab_supported_p)
(multi_vector_optab_supported_p, direct_internal_fn_supported_p)
(direct_internal_fn_supported_p): New functions.
(direct_mask_load_optab_supported_p): New macro.
(direct_load_lanes_optab_supported_p): Likewise.
(direct_mask_store_optab_supported_p): Likewise.
(direct_store_lanes_optab_supported_p): Likewise.
From-SVN: r230473
2015-11-17 19:37:45 +01:00
|
|
|
/* Describes an internal function that maps directly to an optab. */
|
|
|
|
struct direct_internal_fn_info
|
|
|
|
{
|
|
|
|
/* optabs can be parameterized by one or two modes. These fields describe
|
|
|
|
how to select those modes from the types of the return value and
|
|
|
|
arguments. A value of -1 says that the mode is determined by the
|
|
|
|
return type while a value N >= 0 says that the mode is determined by
|
|
|
|
the type of argument N. A value of -2 says that this internal
|
|
|
|
function isn't directly mapped to an optab. */
|
|
|
|
signed int type0 : 8;
|
|
|
|
signed int type1 : 8;
|
2015-11-17 19:55:55 +01:00
|
|
|
/* True if the function is pointwise, so that it can be vectorized by
|
|
|
|
converting the return type and all argument types to vectors of the
|
|
|
|
same number of elements. E.g. we can vectorize an IFN_SQRT on
|
|
|
|
floats as an IFN_SQRT on vectors of N floats.
|
|
|
|
|
|
|
|
This only needs 1 bit, but occupies the full 16 to ensure a nice
|
|
|
|
layout. */
|
|
|
|
unsigned int vectorizable : 16;
|
Add basic support for direct_optab internal functions
This patch adds a concept of internal functions that map directly to an
optab (here called "direct internal functions"). The function can only
be used if the associated optab can be used.
We currently have four functions like that:
- LOAD_LANES
- STORE_LANES
- MASK_LOAD
- MASK_STORE
so the patch converts them to the new infrastructure. These four
all need different types of optabs, but future patches will add
regular unary and binary ones.
In general we need one or two modes to decide whether an optab is
supported, depending on whether it's a convert_optab or not.
This in turn means that we need up to two types to decide whether
an internal function is supported. The patch records which types
are needed for each internal function, using -1 if the return type
should be used and N>=0 if the type of argument N should be used.
(LOAD_LANES and STORE_LANES are unusual in that both optab modes
come from the same array type.)
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* coretypes.h (tree_pair): New type.
* internal-fn.def (DEF_INTERNAL_OPTAB_FN): New macro. Use it
for MASK_LOAD, LOAD_LANES, MASK_STORE and STORE_LANES.
* internal-fn.h (direct_internal_fn_info): New structure.
(direct_internal_fn_array): Declare.
(direct_internal_fn_p, direct_internal_fn): New functions.
(direct_internal_fn_types, direct_internal_fn_supported_p): Declare.
* internal-fn.c (not_direct, mask_load_direct, load_lanes_direct)
(mask_store_direct, store_lanes_direct): New macros.
(direct_internal_fn_array) New array.
(get_multi_vector_move): Return the optab handler without asserting
that it is available.
(expand_LOAD_LANES): Rename to...
(expand_load_lanes_optab_fn): ...this and add an optab argument.
(expand_STORE_LANES): Rename to...
(expand_store_lanes_optab_fn): ...this and add an optab argument.
(expand_MASK_LOAD): Rename to...
(expand_mask_load_optab_fn): ...this and add an optab argument.
(expand_MASK_STORE): Rename to...
(expand_mask_store_optab_fn): ...this and add an optab argument.
(direct_internal_fn_types, direct_optab_supported_p)
(multi_vector_optab_supported_p, direct_internal_fn_supported_p)
(direct_internal_fn_supported_p): New functions.
(direct_mask_load_optab_supported_p): New macro.
(direct_load_lanes_optab_supported_p): Likewise.
(direct_mask_store_optab_supported_p): Likewise.
(direct_store_lanes_optab_supported_p): Likewise.
From-SVN: r230473
2015-11-17 19:37:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const direct_internal_fn_info direct_internal_fn_array[IFN_LAST + 1];
|
|
|
|
|
|
|
|
/* Return true if FN is mapped directly to an optab. */
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
direct_internal_fn_p (internal_fn fn)
|
|
|
|
{
|
|
|
|
return direct_internal_fn_array[fn].type0 >= -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return optab information about internal function FN. Only meaningful
|
|
|
|
if direct_internal_fn_p (FN). */
|
|
|
|
|
|
|
|
inline const direct_internal_fn_info &
|
|
|
|
direct_internal_fn (internal_fn fn)
|
|
|
|
{
|
|
|
|
gcc_checking_assert (direct_internal_fn_p (fn));
|
|
|
|
return direct_internal_fn_array[fn];
|
|
|
|
}
|
|
|
|
|
|
|
|
extern tree_pair direct_internal_fn_types (internal_fn, tree, tree *);
|
|
|
|
extern tree_pair direct_internal_fn_types (internal_fn, gcall *);
|
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 10:08:49 +01:00
|
|
|
extern bool direct_internal_fn_supported_p (internal_fn, tree_pair,
|
|
|
|
optimization_type);
|
|
|
|
extern bool direct_internal_fn_supported_p (internal_fn, tree,
|
|
|
|
optimization_type);
|
Extend tree-call-cdce to calls whose result is used
For -fmath-errno, builtins.c currently expands calls to sqrt to:
y = sqrt_optab (x);
if (y != y)
[ sqrt (x); or errno = EDOM; ]
The drawbacks of this are:
- the call to sqrt is protected by the result of the optab rather
than the input. It would be better to check __builtin_isless (x, 0),
like tree-call-cdce.c does.
- the branch isn't exposed at the gimple level and so gets little
high-level optimisation.
- we do this for log too, but for log a zero input produces
-inf rather than a NaN, and sets errno to ERANGE rather than EDOM.
This patch moves the code to tree-call-cdce.c instead, with the optab
operation being represented as an internal function. This means that
we can use the existing argument-based range checks rather than the
result-based checks and that we get more gimple optimisation of
the branch.
Previously the pass was only enabled by default at -O2 or above,
but the old builtins.c code was enabled at -O. The patch therefore
enables the pass at -O as well.
The previous patch to cfgexpand.c handled cases where functions
don't (or are assumed not to) set errno, so this patch makes
the builtins.c code dead.
Tested on x86_64-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabi
and visium-elf (for the EDOM stuff).
gcc/
* builtins.c (expand_errno_check, expand_builtin_mathfn)
(expand_builtin_mathfn_2): Delete.
(expand_builtin): Remove handling of functions with
internal function equivalents.
* internal-fn.def (SET_EDOM): New internal function.
* internal-fn.h (set_edom_supported_p): Declare.
* internal-fn.c (expand_SET_EDOM): New function.
(set_edom_supported_p): Likewise.
* tree-call-cdce.c: Include builtins.h and internal-fn.h.
Rewrite comment at head of file.
(is_call_dce_candidate): Rename to...
(can_test_argument_range): ...this. Don't check gimple_call_lhs
or gimple_call_builtin_p here.
(edom_only_function): New function.
(shrink_wrap_one_built_in_call_with_conds): New function, split out
from...
(shrink_wrap_one_built_in_call): ...here.
(can_use_internal_fn, use_internal_fn): New functions.
(shrink_wrap_conditional_dead_built_in_calls): Call use_internal_fn
for calls that have an lhs.
(pass_call_cdce::gate): Remove optimize_function_for_speed_p check.
(pass_call_cdce::execute): Skip blocks that are optimized for size.
Check gimple_call_builtin_p here. Use can_use_internal_fn for
calls with an lhs.
* opts.c (default_options_table): Enable -ftree-builtin-call-cdce
at -O and above.
From-SVN: r230488
2015-11-17 19:51:55 +01:00
|
|
|
extern bool set_edom_supported_p (void);
|
Add basic support for direct_optab internal functions
This patch adds a concept of internal functions that map directly to an
optab (here called "direct internal functions"). The function can only
be used if the associated optab can be used.
We currently have four functions like that:
- LOAD_LANES
- STORE_LANES
- MASK_LOAD
- MASK_STORE
so the patch converts them to the new infrastructure. These four
all need different types of optabs, but future patches will add
regular unary and binary ones.
In general we need one or two modes to decide whether an optab is
supported, depending on whether it's a convert_optab or not.
This in turn means that we need up to two types to decide whether
an internal function is supported. The patch records which types
are needed for each internal function, using -1 if the return type
should be used and N>=0 if the type of argument N should be used.
(LOAD_LANES and STORE_LANES are unusual in that both optab modes
come from the same array type.)
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* coretypes.h (tree_pair): New type.
* internal-fn.def (DEF_INTERNAL_OPTAB_FN): New macro. Use it
for MASK_LOAD, LOAD_LANES, MASK_STORE and STORE_LANES.
* internal-fn.h (direct_internal_fn_info): New structure.
(direct_internal_fn_array): Declare.
(direct_internal_fn_p, direct_internal_fn): New functions.
(direct_internal_fn_types, direct_internal_fn_supported_p): Declare.
* internal-fn.c (not_direct, mask_load_direct, load_lanes_direct)
(mask_store_direct, store_lanes_direct): New macros.
(direct_internal_fn_array) New array.
(get_multi_vector_move): Return the optab handler without asserting
that it is available.
(expand_LOAD_LANES): Rename to...
(expand_load_lanes_optab_fn): ...this and add an optab argument.
(expand_STORE_LANES): Rename to...
(expand_store_lanes_optab_fn): ...this and add an optab argument.
(expand_MASK_LOAD): Rename to...
(expand_mask_load_optab_fn): ...this and add an optab argument.
(expand_MASK_STORE): Rename to...
(expand_mask_store_optab_fn): ...this and add an optab argument.
(direct_internal_fn_types, direct_optab_supported_p)
(multi_vector_optab_supported_p, direct_internal_fn_supported_p)
(direct_internal_fn_supported_p): New functions.
(direct_mask_load_optab_supported_p): New macro.
(direct_load_lanes_optab_supported_p): Likewise.
(direct_mask_store_optab_supported_p): Likewise.
(direct_store_lanes_optab_supported_p): Likewise.
From-SVN: r230473
2015-11-17 19:37:45 +01:00
|
|
|
|
2014-11-19 18:00:54 +01:00
|
|
|
extern void expand_internal_call (gcall *);
|
Short-cut generation of simple built-in functions
This patch short-circuits the builtins.c expansion code for a particular
gimple call if:
- the function has an associated internal function
- the target implements that internal function
- the call has no side effects
This allows a later patch to remove the builtins.c code, once calls with
side effects have been handled.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* builtins.h (called_as_built_in): Declare.
* builtins.c (called_as_built_in): Make external.
* internal-fn.h (expand_internal_call): Define a variant that
specifies the internal function explicitly.
* internal-fn.c (expand_load_lanes_optab_fn)
(expand_store_lanes_optab_fn, expand_ANNOTATE, expand_GOMP_SIMD_LANE)
(expand_GOMP_SIMD_VF, expand_GOMP_SIMD_LAST_LANE)
(expand_GOMP_SIMD_ORDERED_START, expand_GOMP_SIMD_ORDERED_END)
(expand_UBSAN_NULL, expand_UBSAN_BOUNDS, expand_UBSAN_VPTR)
(expand_UBSAN_OBJECT_SIZE, expand_ASAN_CHECK, expand_TSAN_FUNC_EXIT)
(expand_UBSAN_CHECK_ADD, expand_UBSAN_CHECK_SUB)
(expand_UBSAN_CHECK_MUL, expand_ADD_OVERFLOW, expand_SUB_OVERFLOW)
(expand_MUL_OVERFLOW, expand_LOOP_VECTORIZED)
(expand_mask_load_optab_fn, expand_mask_store_optab_fn)
(expand_ABNORMAL_DISPATCHER, expand_BUILTIN_EXPECT, expand_VA_ARG)
(expand_UNIQUE, expand_GOACC_DIM_SIZE, expand_GOACC_DIM_POS)
(expand_GOACC_LOOP, expand_GOACC_REDUCTION, expand_direct_optab_fn)
(expand_unary_optab_fn, expand_binary_optab_fn): Add an internal_fn
argument.
(internal_fn_expanders): Update prototype.
(expand_internal_call): Define a variant that specifies the
internal function explicitly. Use it to implement the previous
interface.
* cfgexpand.c (expand_call_stmt): Try to expand calls to built-in
functions as calls to internal functions.
From-SVN: r230487
2015-11-17 19:51:20 +01:00
|
|
|
extern void expand_internal_call (internal_fn, gcall *);
|
Make-lang.in (C_AND_OBJC_OBJS): Add gimple-parser.o.
2016-11-14 Prasad Ghangal <prasad.ghangal@gmail.com>
Richard Biener <rguenther@suse.de>
c/
* Make-lang.in (C_AND_OBJC_OBJS): Add gimple-parser.o.
* config-lang.in (gtfiles): Add c/c-parser.h.
* c-tree.h (enum c_declspec_word): Add cdw_gimple.
(struct c_declspecs): Add gimple_pass member and gimple_p flag.
* c-parser.c (enum c_id_kind, struct c_token,
c_parser_next_token_is, c_parser_next_token_is_not,
c_parser_next_token_is_keyword,
enum c_lookahead_kind, enum c_dtr_syn, enum c_parser_prec):
Split out to ...
* c-parser.h: ... new header.
* c-parser.c: Include c-parser.h and gimple-parser.h.
(c_parser_peek_token, c_parser_peek_2nd_token,
c_token_starts_typename, c_parser_next_token_starts_declspecs,
c_parser_next_tokens_start_declaration, c_parser_consume_token,
c_parser_error, c_parser_require, c_parser_skip_until_found,
c_parser_declspecs, c_parser_declarator, c_parser_peek_nth_token,
c_parser_type_name): Export.
(c_parser_tokens_buf): New function.
(c_parser_error): Likewise.
(c_parser_set_error): Likewise.
(c_parser_declspecs): Handle RID_GIMPLE.
(c_parser_declaration_or_fndef): Parse __GIMPLE marked body
via c_parser_parse_gimple_body.
* c-parser.h (c_parser_peek_token, c_parser_peek_2nd_token,
c_token_starts_typename, c_parser_next_token_starts_declspecs,
c_parser_next_tokens_start_declaration, c_parser_consume_token,
c_parser_error, c_parser_require, c_parser_skip_until_found,
c_parser_declspecs, c_parser_declarator, c_parser_peek_nth_token,
c_parser_type_name): Declare.
(struct c_parser): Declare forward.
(c_parser_tokens_buf): Declare.
(c_parser_error): Likewise.
(c_parser_set_error): Likewise.
* gimple-parser.c: New file.
* gimple-parser.h: Likewise.
obj-c/
* config-lang.in (gtfiles): Add c/c-parser.h.
c-family/
* c-common.h (c_common_resword): Add RID_GIMPLE, RID_PHI types.
* c-common.h (enum rid): Add RID_GIMPLE, RID_PHI.
* c.opt (fgimple): New option.
* doc/invoke.texi (fgimple): Document.
* dumpfile.h (TDF_GIMPLE): Add.
* dumpfile.c (dump_options): Add gimple.
* gimple-pretty-print.c (dump_gimple_switch): Adjust dump
for TDF_GIMPLE.
(dump_gimple_label): Likewise.
(dump_gimple_phi): Likewise.
(dump_gimple_bb_header): Likewise.
(dump_phi_nodes): Likewise.
(pp_cfg_jump): Likewise. Pass in dump flags.
(dump_implicit_edges): Adjust.
* passes.c (pass_init_dump_file): Do not dump function header
for TDF_GIMPLE.
* tree-cfg.c (dump_function_to_file): Dump function return type
and __GIMPLE keyword for TDF_GIMPLE. Change guard for dumping
GIMPLE stmts.
* tree-pretty-print.c (dump_decl_name): Adjust dump for TDF_GIMPLE.
(dump_generic_node): Likewise.
* function.h (struct function): Add pass_startwith member.
* passes.c (execute_one_pass): Implement startwith.
* tree-ssanames.c (make_ssa_name_fn): New argument, check for version
and assign proper version for parsed ssa names.
* tree-ssanames.h (make_ssa_name_fn): Add new argument to the function.
* internal-fn.c (expand_PHI): New function.
* internal-fn.h (expand_PHI): Declared here.
* internal-fn.def: New defination for PHI.
* tree-cfg.c (lower_phi_internal_fn): New function.
(build_gimple_cfg): Call it.
(verify_gimple_call): Condition for passing label as arg in internal
function PHI.
* tree-into-ssa.c (rewrite_add_phi_arguments): Handle already
present PHIs with arguments.
testsuite/
* gcc.dg/gimplefe-1.c: New testcase.
* gcc.dg/gimplefe-2.c: Likewise.
* gcc.dg/gimplefe-3.c: Likewise.
* gcc.dg/gimplefe-4.c: Likewise.
* gcc.dg/gimplefe-5.c: Likewise.
* gcc.dg/gimplefe-6.c: Likewise.
* gcc.dg/gimplefe-7.c: Likewise.
* gcc.dg/gimplefe-8.c: Likewise.
* gcc.dg/gimplefe-9.c: Likewise.
* gcc.dg/gimplefe-10.c: Likewise.
* gcc.dg/gimplefe-11.c: Likewise.
* gcc.dg/gimplefe-12.c: Likewise.
* gcc.dg/gimplefe-13.c: Likewise.
* gcc.dg/gimplefe-14.c: Likewise.
* gcc.dg/gimplefe-15.c: Likewise.
* gcc.dg/gimplefe-16.c: Likewise.
* gcc.dg/gimplefe-17.c: Likewise.
* gcc.dg/gimplefe-18.c: Likewise.
Co-Authored-By: Richard Biener <rguenther@suse.de>
From-SVN: r242387
2016-11-14 14:51:48 +01:00
|
|
|
extern void expand_PHI (internal_fn, gcall *);
|
2011-04-20 10:21:25 +02:00
|
|
|
|
|
|
|
#endif
|