This patch makes genmatch match calls based on combined_fn rather
than built_in_function and extends the matching to internal functions.
It also uses fold_const_call to fold the calls to a constant, rather
than going through fold_builtin_n.
In order to slightly simplify the code and remove potential
ambiguity, the patch enforces lower case for tree codes
(foo->FOO_EXPR), caps for functions (no built_in_hypot->BUILT_IN_HYPOT)
and requires an exact match for user-defined identifiers. The first two
were already met in practice but there were a couple of cases where
operator lists were defined in one case and used in another.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* match.pd: Use HYPOT and COS rather than hypot and cos.
Use CASE_CFN_* macros. Guard log/exp folds with
SCALAR_FLOAT_TYPE_P.
* genmatch.c (internal_fn): New enum.
(fn_id::fn): Change to an unsigned int.
(fn_id::fn_id): Accept internal_fn too.
(add_builtin): Rename to...
(add_function): ...this and turn into a template.
(get_operator): Only try one variation if the original name fails.
Only add _EXPR if the original name was all lower case.
Try converting internal and built-in function names to their
CFN equivalents.
(expr::gen_transform): Use maybe_build_call_expr_loc for generic.
(dt_simplify::gen_1): Likewise.
(dt_node::gen_kids_1): Use gimple_call_combined_fn for gimple
and get_call_combined_fn for generic.
(dt_simplify::gen): Use combined_fn as the type of fn_ids.
(decision_tree::gen): Likewise.
(main): Use lower case in the strings for {VIEW_,}CONVERT[012].
Use add_function rather than add_builtin. Register internal
functions too.
* generic-match-head.c: Include case-cfn-macros.h.
* gimple-fold.c (replace_stmt_with_simplification): Use
gimple_call_combined_fn to test whether we can keep an
existing call.
* gimple-match.h (code_helper): Replace built_in_function
with combined_fn.
* gimple-match-head.c: Include fold-const-call.h, internal-fn.h
and case-fn-macros.h.
(gimple_resimplify1): Use fold_const_call.
(gimple_resimplify2, gimple_resimplify3): Likewise.
(build_call_internal, build_call): New functions.
(maybe_push_res_to_seq): Use them.
(gimple_simplify): Use fold_const_call. Set *rcode to a combined_fn
rather than a built-in function.
* tree.h (build_call_expr_internal_loc): Declare.
(maybe_build_call_expr_loc): Likewise.
* tree.c (build_call_expr_internal_loc_array): New function.
(maybe_build_call_expr_loc): Likewise.
From-SVN: r230484
This patch extends mathfn_built_in to handle combined_fn, but keeps the
old built_in_function interface around since it's a common case.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* builtins.h (mathfn_built_in): Add a variant that takes
a combined_fn.
* builtins.c: Include case-cfn-macros.h.
(CASE_MATHFN): Use CASE_CFN_*.
(CASE_MATHFN_REENT): Use CFN_ codes.
(mathfn_built_in_2, mathfn_built_in_1): Replace built_in_function
argument with a combined_fn.
(mathfn_built_in): Add a variant that takes a combined_fn.
(expand_builtin_int_roundingfn_2): Update callers accordingly.
(fold_builtin_sincos, fold_builtin_classify): Likewise.
From-SVN: r230483
Another patch to extend uses of built_in_function to combined_fn,
this time in tree-vect-patterns.c. The old code didn't handle the
long double pow variants, but I think that's because noone had a target
that would benefit rather than because the code would mishandle them.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* tree-vect-patterns.c: Include case-cfn-macros.h.
(vect_recog_pow_pattern): Use combined_fn instead of built-in codes.
From-SVN: r230482
Another patch to extend uses of built_in_function to combined_fn, this time
in tree-ssa-math-opts.c.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* tree-ssa-math-opts.c: Include case-cfn-macros.h.
(execute_cse_sincos_1): Use combined_fn instead of built-in codes.
(pass_cse_sincos::execute): Likewise.
From-SVN: r230481
Another patch to extend uses of built_in_function to combined_fn, this time
in tree-ssa-reassoc.c.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* tree-ssa-reassoc.c: Include case-cfn-macros.h.
(stmt_is_power_of_op): Use combined_fn instead of built-in codes.
(decrement_power, acceptable_pow_call): Likewise.
(attempt_builtin_copysign): Likewise.
From-SVN: r230480
Another patch to extend uses of built_in_function to combined_fn, this time
in tree-vrp.c.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* tree-vrp.c: Include case-cfn-macros.h.
(extract_range_basic): Switch on combined_fn rather than handling
built-in functions and internal functions separately.
From-SVN: r230479
This patch generalises fold-const.[hc] routines to use combined_fn
instead of built_in_function. It also updates gimple-ssa-backprop,c
since the update is simple and it avoids churn on the call to
negate_mathfn_p.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* fold-const.h (negate_mathfn_p): Take a combined_fn rather
than a built_in_function.
(tree_call_nonnegative_warnv_p): Take a combined_fn rather than
a function decl.
(integer_valued_real_call_p): Likewise.
* fold-const.c: Include case-cfn-macros.h
(negate_mathfn_p): Take a combined_fn rather than a built_in_function.
(negate_expr_p): Update accordingly.
(tree_call_nonnegative_warnv_p): Take a combined_fn rather than
a function decl.
(integer_valued_real_call_p): Likewise.
(tree_invalid_nonnegative_warnv_p): Update accordingly.
(integer_valued_real_p): Likewise.
* gimple-fold.c (gimple_call_nonnegative_warnv_p): Update call
to tree_call_nonnegative_warnv_p.
(gimple_call_integer_valued_real_p): Likewise
integer_valued_real_call_p.
* gimple-ssa-backprop.c: Include case-cfn-macros.h.
(backprop::process_builtin_call_use): Extend to combined_fn.
(strip_sign_op_1): Likewise.
(backprop::process_use): Don't check for built-in calls here.
(backprop::execute): Likewise.
(backprop::optimize_builtin_call): Update call to negate_mathfn_p.
From-SVN: r230478
This patch extends fold_const_call so that it can handle internal
as well as built-in functions.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* fold-const-call.h (fold_const_call): Replace built_in_function
arguments with combined_fn arguments.
* fold-const-call.c: Include case-cfn-macros.h.
(fold_const_call_ss, fold_const_call_cs, fold_const_call_sc)
(fold_const_call_cc, fold_const_call_sss, fold_const_call_ccc)
(fold_const_call_ssss, fold_const_call_1, fold_const_call): Replace
built_in_function arguments with combined_fn arguments.
* builtins.c (fold_builtin_sincos, fold_builtin_1, fold_builtin_2)
(fold_builtin_3): Update calls to fold_const_call.
From-SVN: r230477
This patch automatically generates case macros such as:
CASE_CFN_SQRT
for each {F,,L} floating-point built-in function and each {,L,LL,IMAX}
integer built-in function. The macros match the same built-in
functions as CASE_FLT_FN and CASE_INT_FN but in addition include
the associated internal function, if any.
The idea is to make sure that users of combined_fn don't need to know
which built-in functions have internal-function equivalents. If we add
a new function to internal-fn.def, all combined_fn users should pick it
up automatically.
The generator wants to use "hash_set <nofree_string_hash>",
so the patch follows hash_map in using the types given by the
traits as the key. This is a no-op for current users of hash_set.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* Makefile.in (HASH_TABLE_H): Add GGC_H.
(MOSTLYCLEANFILES, generated_files): Add case-fn-macros.h.
(s-case-cfn-macros, case-cfn-macros.h, build/gencfn-macros.o)
(build/gencfn-macros$(build_exeext): New rules.
(genprogerr): Add cfn-macros.
* hash-set.h (hash_set): Use the traits value_type as the key.
* gencfn-macros.c: New file.
From-SVN: r230476
This patch adds internal function equivalents of all the INT_FN functions.
Unlike the math functions, these functions never set errno and the internal
functions should be exactly equivalent to the built-in ones. The reason
for defining the internal functions is so that we can extend the
functionality to other modes, in particular vector modes.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* internal-fn.def (DEF_INTERNAL_INT_FN): New macro.
(CLRSB, CLZ, CTZ, FFS, PARITY, POPCOUNT): New functions.
* builtins.c (associated_internal_fn): Handle them.
From-SVN: r230475
This patch adds internal functions for simple FLT_FN built-in functions,
in cases where an associated optab already exists. Unlike some of the
built-in functions, these internal functions never set errno.
LDEXP is an odd-one out in that its second operand is an integer.
All the others operate on uniform types.
The patch also adds a function to query the internal function associated
with a built-in function (if any), and another to test whether a given
gcall could be replaced by a call to an internal function on the current
target (as long as the caller deals with errno appropriately).
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* builtins.h (associated_internal_fn): Declare.
(replacement_internal_fn): Likewise.
* builtins.c: Include internal-fn.h
(associated_internal_fn, replacement_internal_fn): New functions.
* internal-fn.def (DEF_INTERNAL_FLT_FN): New macro.
(ACOS, ASIN, ATAN, COS, EXP, EXP10, EXP2, EXPM1, LOG, LOG10, LOG1P)
(LOG2, LOGB, SIGNIFICAND, SIN, SQRT, TAN, CEIL, FLOOR, NEARBYINT)
(RINT, ROUND, TRUNC, ATAN2, COPYSIGN, FMOD, POW, REMAINDER, SCALB)
(LDEXP): New functions.
* internal-fn.c: Include recog.h.
(unary_direct, binary_direct): New macros.
(expand_direct_optab_fn): New function.
(expand_unary_optab_fn): New macro.
(expand_binary_optab_fn): Likewise.
(direct_unary_optab_supported_p): Likewise.
(direct_binary_optab_supported_p): Likewise.
From-SVN: r230474
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
I'm working on a patch series that needs to be able to treat built-in
functions and internal functions in a similar way. This patch adds a
new enum, combined_fn, that combines the two together. It also adds
utility functions for seeing which combined_fn (if any) is called by
a given CALL_EXPR or gcall.
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
gcc/
* tree-core.h (internal_fn): Move immediately after the definition
of built_in_function.
(combined_fn): New enum.
* tree.h (as_combined_fn, builtin_fn_p, as_builtin_fn)
(internal_fn_p, as_internal_fn): New functions.
(get_call_combined_fn, combined_fn_name): Declare.
* tree.c (get_call_combined_fn): New function.
(combined_fn_name): Likewise.
* gimple.h (gimple_call_combined_fn): Declare.
* gimple.c (gimple_call_combined_fn): New function.
From-SVN: r230472
have var_decl in decompose, at tree.h:5105
gcc/
* cp/init.c (build_new_1): Check for expression constness
the right way.
testsuite/
* g++.dg/init/new46.C: New test.
From-SVN: r230468
2015-11-17 Sandra Loosemore <sandra@codesourcery.com>
PR target/56036
* doc/invoke.texi (Option Summary): Add -mms-bitfields to x86
option list.
(x86 Options): Add -mms-bitfields and -mno-ms-bitfields. Move
discussion of the Microsoft structure layout details here from
its former home in extend.texi.
* doc/extend.texi (x86 Variable Attributes): Replace detailed
discussion with pointer to its new location. Add cross-reference
to corresponding type attributes.
(x86 Type Attributes): Add cross-references to command-line options
and variable attributes.
From-SVN: r230467
PR target/68143
* config/arm/arm.c (arm_block_set_unaligned_vect): Keep track of
offset from dstbase and use it appropriately in
adjust_automodify_address.
(arm_block_set_aligned_vect): Likewise.
* gcc.c-torture/execute/pr68143_1.c: New test.
From-SVN: r230462
2015-11-17 Venkataramanan Kumar <Venkataramanan.Kumar@amd.com>
* tree-if-conv.c: Include varasm.h
(ref_DR_map): Define.
(baseref_DR_map): Like wise
(struct ifc_dr): Add new tree predicate field.
(hash_memrefs_baserefs_and_store_DRs_read_written_info): New function.
(memrefs_read_or_written_unconditionally): Remove.
(write_memrefs_written_at_least_once): Remove.
(ifcvt_memrefs_wont_trap): Use hash maps to query
unconditional read/written information.
(if_convertible_loop_p_1): Initialize hash maps and predicates
before hashing data references and delete hashmaps at the end.
2015-11-17 Venkataramanan Kumar <Venkataramanan.Kumar@amd.com>
* gcc.dg/tree-ssa/ifc-8.c: New test.
From-SVN: r230454
2015-11-16 Thomas Preud'homme <thomas.preudhomme@arm.com>
PR 56036
* doc/invoke.texi (Optimize Options): Move @end table to the right
place.
From-SVN: r230452
2015-11-16 Michael Meissner <meissner@linux.vnet.ibm.com>
* config/rs6000/vsx.md (VSX_L): Do not include IBM extended double
128-bit types, just types that fit in a single vector.
* config/rs6000/rs6000.md (FMOVE128_GPR): Likewise.
From-SVN: r230440
* doc/md.texi ('#' and '*' constraint modifiers): Do not include these
in the user documentation.
(define_peephole2, define_split): Similarly.
From-SVN: r230439
2015-11-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/58027
PR fortran/60993
* expr.c (gfc_check_init_expr): Prevent a redundant check when a
__convert_* function was inserted into an array constructor.
(gfc_check_assign_symbol): Check for an initialization expression
when a __convert_* was inserted.
2015-11-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/58027
PR fortran/60993
* gfortran.dg/pr58027.f90: New test.
From-SVN: r230433
Since r230164, in PR68330 combine ends up with a sign_extend of an
lshiftrt by some constant, and it does not know to morph that into a
zero_extract (the extend will always extend with zeroes). I think
it is best to let simplify-rtx always replace such a sign_extend by
a zero_extend, after which everything works as expected.
2015-11-15 Segher Boessenkool <segher@kernel.crashing.org>
PR rtl-optimization/68330
* simplify-rtx.c (simplify_unary_operation_1): Simplify SIGN_EXTEND
of LSHIFTRT by a non-zero constant integer.
From-SVN: r230429
2015-11-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/68306
* tree-vect-data-refs.c (vect_verify_datarefs_alignment): Fix
bogus copying from verify_data_ref_alignment and use continue
instead of return.
From-SVN: r230428