summaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-17 18:47:44 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-17 18:47:44 +0000
commit3a18d05c6e55490e20387ffed5a7a41582cd4f38 (patch)
tree85646c7ff97526585c06596877a86bf8c493a6b3 /gcc/gimple-fold.c
parente3240774da4f4334cd5ab34579770788a99d17f1 (diff)
downloadgcc-3a18d05c6e55490e20387ffed5a7a41582cd4f38.tar.gz
Add genmatch support for internal functions
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230484 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 436e29b37b7..1ab20d11fa7 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -3369,7 +3369,7 @@ replace_stmt_with_simplification (gimple_stmt_iterator *gsi,
}
}
else if (rcode.is_fn_code ()
- && gimple_call_builtin_p (stmt, rcode))
+ && gimple_call_combined_fn (stmt) == rcode)
{
unsigned i;
for (i = 0; i < gimple_call_num_args (stmt); ++i)