diff options
author | Richard Biener <rguenther@suse.de> | 2021-04-15 13:03:21 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-04-26 11:04:00 +0200 |
commit | b972e036f40c12b106f9070c3e8adea0eb8a45fa (patch) | |
tree | c7ea13fc150948db248df196e567eac1c4ddd729 /gcc/tree-vect-generic.c | |
parent | 152334cfb7a17bb3f1356f31a2e808d3ee459605 (diff) | |
download | gcc-b972e036f40c12b106f9070c3e8adea0eb8a45fa.zip gcc-b972e036f40c12b106f9070c3e8adea0eb8a45fa.tar.gz gcc-b972e036f40c12b106f9070c3e8adea0eb8a45fa.tar.bz2 |
Move gimplify_buildN API local to only remaining user
This moves the legacy gimplify_buildN API to tree-vect-generic.c,
its only user and elides the gimplification step, making it a wrapper
around gimple_build, adjusting tree_vec_extract for this.
I've noticed that vector CTOR expansion doesn't deal with unfolded
{} and thus this makes it more resilent. I've also adjusted the
match.pd vector CTOR extraction code to make sure it doesn't
produce a CTOR when folding would make it a vector constant.
2021-04-15 Richard Biener <rguenther@suse.de>
* tree-cfg.h (gimplify_build1): Remove.
(gimplify_build2): Likewise.
(gimplify_build3): Likewise.
* tree-cfg.c (gimplify_build1): Move to tree-vect-generic.c.
(gimplify_build2): Likewise.
(gimplify_build3): Likewise.
* tree-vect-generic.c (gimplify_build1): Move from tree-cfg.c.
Modernize.
(gimplify_build2): Likewise.
(gimplify_build3): Likewise.
(tree_vec_extract): Use resimplify with following SSA edges.
(expand_vector_parallel): Avoid passing NULL size/bitpos
to tree_vec_extract.
* expr.c (store_constructor): Deal with zero-element CTORs.
* match.pd (bit_field_ref <vector CTOR>): Make sure to
produce vector constants when possible.
Diffstat (limited to 'gcc/tree-vect-generic.c')
-rw-r--r-- | gcc/tree-vect-generic.c | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index c8d8493..751f181 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -41,9 +41,54 @@ along with GCC; see the file COPYING3. If not see #include "vec-perm-indices.h" #include "insn-config.h" #include "tree-ssa-dce.h" +#include "gimple-fold.h" +#include "gimple-match.h" #include "recog.h" /* FIXME: for insn_data */ +/* Build a ternary operation and gimplify it. Emit code before GSI. + Return the gimple_val holding the result. */ + +static tree +gimplify_build3 (gimple_stmt_iterator *gsi, enum tree_code code, + tree type, tree a, tree b, tree c) +{ + location_t loc = gimple_location (gsi_stmt (*gsi)); + gimple_seq stmts = NULL; + tree ret = gimple_build (&stmts, loc, code, type, a, b, c); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + return ret; +} + +/* Build a binary operation and gimplify it. Emit code before GSI. + Return the gimple_val holding the result. */ + +static tree +gimplify_build2 (gimple_stmt_iterator *gsi, enum tree_code code, + tree type, tree a, tree b) +{ + location_t loc = gimple_location (gsi_stmt (*gsi)); + gimple_seq stmts = NULL; + tree ret = gimple_build (&stmts, loc, code, type, a, b); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + return ret; +} + +/* Build a unary operation and gimplify it. Emit code before GSI. + Return the gimple_val holding the result. */ + +static tree +gimplify_build1 (gimple_stmt_iterator *gsi, enum tree_code code, tree type, + tree a) +{ + location_t loc = gimple_location (gsi_stmt (*gsi)); + gimple_seq stmts = NULL; + tree ret = gimple_build (&stmts, loc, code, type, a); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + return ret; +} + + static void expand_vector_operations_1 (gimple_stmt_iterator *, bitmap); /* Return the number of elements in a vector type TYPE that we have @@ -122,23 +167,25 @@ typedef tree (*elem_op_func) (gimple_stmt_iterator *, tree, tree, tree, tree, tree, enum tree_code, tree); +/* Extract the vector element of type TYPE at BITPOS with BITSIZE from T + and return it. */ + tree tree_vec_extract (gimple_stmt_iterator *gsi, tree type, tree t, tree bitsize, tree bitpos) { - if (TREE_CODE (t) == SSA_NAME) - { - gimple *def_stmt = SSA_NAME_DEF_STMT (t); - if (is_gimple_assign (def_stmt) - && (gimple_assign_rhs_code (def_stmt) == VECTOR_CST - || (bitpos - && gimple_assign_rhs_code (def_stmt) == CONSTRUCTOR))) - t = gimple_assign_rhs1 (def_stmt); - } - if (bitpos) - return gimplify_build3 (gsi, BIT_FIELD_REF, type, t, bitsize, bitpos); - else - return gimplify_build1 (gsi, VIEW_CONVERT_EXPR, type, t); + /* We're using the resimplify API and maybe_push_res_to_seq to + simplify the BIT_FIELD_REF but restrict the simplification to + a single stmt while at the same time following SSA edges for + simplification with already emitted CTORs. */ + gimple_match_op opr; + opr.set_op (BIT_FIELD_REF, type, t, bitsize, bitpos); + opr.resimplify (NULL, follow_all_ssa_edges); + gimple_seq stmts = NULL; + tree res = maybe_push_res_to_seq (&opr, &stmts); + gcc_assert (res); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + return res; } static tree @@ -327,7 +374,8 @@ expand_vector_parallel (gimple_stmt_iterator *gsi, elem_op_func f, tree type, scalar_int_mode mode = int_mode_for_size (tree_to_uhwi (TYPE_SIZE (type)), 0).require (); compute_type = lang_hooks.types.type_for_mode (mode, 1); - result = f (gsi, compute_type, a, b, NULL_TREE, NULL_TREE, code, type); + result = f (gsi, compute_type, a, b, bitsize_zero_node, + TYPE_SIZE (compute_type), code, type); warning_at (loc, OPT_Wvector_operation_performance, "vector operation will be expanded with a " "single scalar operation"); |