diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2018-01-03 21:47:11 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2018-01-03 21:47:11 +0000 |
commit | 3133c3b628da0e39a3ae9cdbd4973de04b214589 (patch) | |
tree | 8d66cf57fd44dfbd34c07dda8a6236814461b96d | |
parent | aaeefd88f464de0a78fa66c8b5e2755babf0d47f (diff) | |
download | gcc-3133c3b628da0e39a3ae9cdbd4973de04b214589.zip gcc-3133c3b628da0e39a3ae9cdbd4973de04b214589.tar.gz gcc-3133c3b628da0e39a3ae9cdbd4973de04b214589.tar.bz2 |
Split rhs checking out of vectorizable_{,mask_load_}store
This patch splits out the rhs checking code that's common to both
vectorizable_mask_load_store and vectorizable_store.
2018-01-03 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* tree-vect-stmts.c (vect_check_store_rhs): New function,
split out from...
(vectorizable_mask_load_store): ...here.
(vectorizable_store): ...and here.
From-SVN: r256213
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/tree-vect-stmts.c | 80 |
2 files changed, 59 insertions, 28 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 86320f7..6086e15 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> + * tree-vect-stmts.c (vect_check_store_rhs): New function, + split out from... + (vectorizable_mask_load_store): ...here. + (vectorizable_store): ...and here. + +2018-01-03 Richard Sandiford <richard.sandiford@linaro.org> + * tree-vect-stmts.c (vect_check_load_store_mask): New function, split out from... (vectorizable_mask_load_store): ...here. diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index c493eb5..0d6c824 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -2092,6 +2092,55 @@ vect_check_load_store_mask (gimple *stmt, tree mask, tree *mask_vectype_out) return true; } +/* Return true if stored value RHS is suitable for vectorizing store + statement STMT. When returning true, store the type of the + vectorized store value in *RHS_VECTYPE_OUT and the type of the + store in *VLS_TYPE_OUT. */ + +static bool +vect_check_store_rhs (gimple *stmt, tree rhs, tree *rhs_vectype_out, + vec_load_store_type *vls_type_out) +{ + /* In the case this is a store from a constant make sure + native_encode_expr can handle it. */ + if (CONSTANT_CLASS_P (rhs) && native_encode_expr (rhs, NULL, 64) == 0) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "cannot encode constant as a byte sequence.\n"); + return false; + } + + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + gimple *def_stmt; + enum vect_def_type dt; + tree rhs_vectype; + if (!vect_is_simple_use (rhs, stmt_info->vinfo, &def_stmt, &dt, + &rhs_vectype)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "use not simple.\n"); + return false; + } + + tree vectype = STMT_VINFO_VECTYPE (stmt_info); + if (rhs_vectype && !useless_type_conversion_p (vectype, rhs_vectype)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "incompatible vector types.\n"); + return false; + } + + *rhs_vectype_out = rhs_vectype; + if (dt == vect_constant_def || dt == vect_external_def) + *vls_type_out = VLS_STORE_INVARIANT; + else + *vls_type_out = VLS_STORE; + return true; +} + /* Function vectorizable_mask_load_store. Check if STMT performs a conditional load or store that can be vectorized. @@ -2162,12 +2211,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, if (gimple_call_internal_fn (stmt) == IFN_MASK_STORE) { tree rhs = gimple_call_arg (stmt, 3); - if (!vect_is_simple_use (rhs, loop_vinfo, &def_stmt, &dt, &rhs_vectype)) + if (!vect_check_store_rhs (stmt, rhs, &rhs_vectype, &vls_type)) return false; - if (dt == vect_constant_def || dt == vect_external_def) - vls_type = VLS_STORE_INVARIANT; - else - vls_type = VLS_STORE; } else vls_type = VLS_LOAD; @@ -2201,9 +2246,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, else if (!VECTOR_MODE_P (TYPE_MODE (vectype)) || !can_vec_mask_load_store_p (TYPE_MODE (vectype), TYPE_MODE (mask_vectype), - vls_type == VLS_LOAD) - || (rhs_vectype - && !useless_type_conversion_p (vectype, rhs_vectype))) + vls_type == VLS_LOAD)) return false; if (!vec_stmt) /* transformation not required. */ @@ -5821,26 +5864,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, } op = gimple_assign_rhs1 (stmt); - - /* In the case this is a store from a constant make sure - native_encode_expr can handle it. */ - if (CONSTANT_CLASS_P (op) && native_encode_expr (op, NULL, 64) == 0) - return false; - - if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt, &rhs_vectype)) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "use not simple.\n"); - return false; - } - - if (dt == vect_constant_def || dt == vect_external_def) - vls_type = VLS_STORE_INVARIANT; - else - vls_type = VLS_STORE; - - if (rhs_vectype && !useless_type_conversion_p (vectype, rhs_vectype)) + if (!vect_check_store_rhs (stmt, op, &rhs_vectype, &vls_type)) return false; elem_type = TREE_TYPE (vectype); |