diff options
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/slp-11b.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/slp-perm-6.c | 8 | ||||
-rw-r--r-- | gcc/tree-vect-loop.c | 72 | ||||
-rw-r--r-- | gcc/tree-vect-slp.c | 48 |
4 files changed, 77 insertions, 53 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/slp-11b.c b/gcc/testsuite/gcc.dg/vect/slp-11b.c index 0cc2377..3f16c9c 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-11b.c +++ b/gcc/testsuite/gcc.dg/vect/slp-11b.c @@ -45,4 +45,4 @@ int main (void) /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_strided4 && vect_int_mult } } } } */ /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { vect_strided4 && vect_int_mult } } } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-6.c b/gcc/testsuite/gcc.dg/vect/slp-perm-6.c index 3848929..816486a 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-perm-6.c +++ b/gcc/testsuite/gcc.dg/vect/slp-perm-6.c @@ -106,7 +106,7 @@ int main (int argc, const char* argv[]) /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && {! vect_partial_vectors_usage_1 } } } } } } */ /* The epilogues are vectorized using partial vectors. */ /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { vect_perm3_int && { {! vect_load_lanes } && vect_partial_vectors_usage_1 } } } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_load_lanes } } } */ -/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ -/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ -/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { xfail { vect_perm3_int && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { xfail vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { xfail vect_load_lanes } } } */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 5e7188a..547894c 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2365,6 +2365,78 @@ start_over: "unsupported SLP instances\n"); goto again; } + + /* Check whether any load in ALL SLP instances is possibly permuted. */ + slp_tree load_node, slp_root; + unsigned i, x; + slp_instance instance; + bool can_use_lanes = true; + FOR_EACH_VEC_ELT (LOOP_VINFO_SLP_INSTANCES (loop_vinfo), x, instance) + { + slp_root = SLP_INSTANCE_TREE (instance); + int group_size = SLP_TREE_LANES (slp_root); + tree vectype = SLP_TREE_VECTYPE (slp_root); + bool loads_permuted = false; + FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), i, load_node) + { + if (!SLP_TREE_LOAD_PERMUTATION (load_node).exists ()) + continue; + unsigned j; + stmt_vec_info load_info; + FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (load_node), j, load_info) + if (SLP_TREE_LOAD_PERMUTATION (load_node)[j] != j) + { + loads_permuted = true; + break; + } + } + + /* If the loads and stores can be handled with load/store-lane + instructions record it and move on to the next instance. */ + if (loads_permuted + && vect_store_lanes_supported (vectype, group_size, false)) + { + FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), i, load_node) + { + stmt_vec_info stmt_vinfo = DR_GROUP_FIRST_ELEMENT + (SLP_TREE_SCALAR_STMTS (load_node)[0]); + /* Use SLP for strided accesses (or if we can't + load-lanes). */ + if (STMT_VINFO_STRIDED_P (stmt_vinfo) + || ! vect_load_lanes_supported + (STMT_VINFO_VECTYPE (stmt_vinfo), + DR_GROUP_SIZE (stmt_vinfo), false)) + break; + } + + can_use_lanes + = can_use_lanes && i == SLP_INSTANCE_LOADS (instance).length (); + + if (can_use_lanes && dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "SLP instance %p can use load/store-lanes\n", + instance); + } + else + { + can_use_lanes = false; + break; + } + } + + /* If all SLP instances can use load/store-lanes abort SLP and try again + with SLP disabled. */ + if (can_use_lanes) + { + ok = opt_result::failure_at (vect_location, + "Built SLP cancelled: can use " + "load/store-lanes\n"); + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "Built SLP cancelled: all SLP instances support " + "load/store-lanes\n"); + goto again; + } } /* Dissolve SLP-only groups. */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 11fe685..d498cd4 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2263,54 +2263,6 @@ vect_build_slp_instance (vec_info *vinfo, "SLP size %u vs. limit %u.\n", tree_size, max_tree_size); - /* Check whether any load is possibly permuted. */ - slp_tree load_node; - bool loads_permuted = false; - FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (new_instance), i, load_node) - { - if (!SLP_TREE_LOAD_PERMUTATION (load_node).exists ()) - continue; - unsigned j; - stmt_vec_info load_info; - FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (load_node), j, load_info) - if (SLP_TREE_LOAD_PERMUTATION (load_node)[j] != j) - { - loads_permuted = true; - break; - } - } - - /* If the loads and stores can be handled with load/store-lane - instructions do not generate this SLP instance. */ - if (is_a <loop_vec_info> (vinfo) - && loads_permuted - && kind == slp_inst_kind_store - && vect_store_lanes_supported - (STMT_VINFO_VECTYPE (scalar_stmts[0]), group_size, false)) - { - slp_tree load_node; - FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (new_instance), i, load_node) - { - stmt_vec_info stmt_vinfo = DR_GROUP_FIRST_ELEMENT - (SLP_TREE_SCALAR_STMTS (load_node)[0]); - /* Use SLP for strided accesses (or if we can't load-lanes). */ - if (STMT_VINFO_STRIDED_P (stmt_vinfo) - || ! vect_load_lanes_supported - (STMT_VINFO_VECTYPE (stmt_vinfo), - DR_GROUP_SIZE (stmt_vinfo), false)) - break; - } - if (i == SLP_INSTANCE_LOADS (new_instance).length ()) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "Built SLP cancelled: can use " - "load/store-lanes\n"); - vect_free_slp_instance (new_instance); - return false; - } - } - /* Fixup SLP reduction chains. */ if (kind == slp_inst_kind_reduc_chain) { |