aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-05-17 14:26:38 +0200
committerRichard Biener <rguenther@suse.de>2024-05-22 13:18:28 +0200
commit0c7792f707368d0225a9a457895b847ef660c270 (patch)
tree2731196b806414f50490212f738604dc859d67f4
parent1a5e4dd83788ea4c049d354d83ad58a6a3d747e6 (diff)
downloadgcc-0c7792f707368d0225a9a457895b847ef660c270.zip
gcc-0c7792f707368d0225a9a457895b847ef660c270.tar.gz
gcc-0c7792f707368d0225a9a457895b847ef660c270.tar.bz2
Avoid requiring VEC_PERM represenatives
The following plugs one hole where we require a VEC_PERM node representative unnecessarily. This is for vect_check_store_rhs which looks at the RHS and checks whether a constant can be native encoded. The fix is to guard that with vect_constant_def additionally and making vect_is_simple_use forgiving for a missing SLP_TREE_REPRESENTATIVE when the child is a VEC_PERM node, initializing the scalar def to error_mark_node. * tree-vect-stmts.cc (vect_check_store_rhs): Look at *rhs only when it's a vec_constant_def. (vect_is_simple_use): When we have no representative for an internal node, fill in *op with error_mark_node.
-rw-r--r--gcc/tree-vect-stmts.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 6729595..4219ad8 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -2553,7 +2553,8 @@ vect_check_store_rhs (vec_info *vinfo, stmt_vec_info stmt_info,
/* 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 (rhs_dt == vect_constant_def
+ && CONSTANT_CLASS_P (*rhs) && native_encode_expr (*rhs, NULL, 64) == 0)
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -14002,8 +14003,26 @@ vect_is_simple_use (vec_info *vinfo, stmt_vec_info stmt, slp_tree slp_node,
*vectype = SLP_TREE_VECTYPE (child);
if (SLP_TREE_DEF_TYPE (child) == vect_internal_def)
{
- *op = gimple_get_lhs (SLP_TREE_REPRESENTATIVE (child)->stmt);
- return vect_is_simple_use (*op, vinfo, dt, def_stmt_info_out);
+ /* ??? VEC_PERM nodes might be intermediate and their lane value
+ have no representative (nor do we build a VEC_PERM stmt for
+ the actual operation). Note for two-operator nodes we set
+ a representative but leave scalar stmts empty as we'd only
+ have one for a subset of lanes. Ideally no caller would
+ require *op for internal defs. */
+ if (SLP_TREE_REPRESENTATIVE (child))
+ {
+ *op = gimple_get_lhs (SLP_TREE_REPRESENTATIVE (child)->stmt);
+ return vect_is_simple_use (*op, vinfo, dt, def_stmt_info_out);
+ }
+ else
+ {
+ gcc_assert (SLP_TREE_CODE (child) == VEC_PERM_EXPR);
+ *op = error_mark_node;
+ *dt = vect_internal_def;
+ if (def_stmt_info_out)
+ *def_stmt_info_out = NULL;
+ return true;
+ }
}
else
{