When the invariant load is not uniform we cost it wrongly, fix that
and avoid using scalar_to_vec for non-splats. We have vec_construct
for that now.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
* tree-vect-stmts.cc (vectorizable_load): Cost non-uniform
invariant loads more appropriately.
---
gcc/tree-vect-stmts.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 631d31251e8..60f3c2c0fb5 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -10060,9 +10060,13 @@ vectorizable_load (vec_info *vinfo,
}
enum vect_cost_model_location cost_loc
= hoist_p ? vect_prologue : vect_body;
- unsigned int cost = record_stmt_cost (cost_vec, 1, scalar_load,
+ unsigned int cost = record_stmt_cost (cost_vec,
+ uniform_p
+ ? 1 : SLP_TREE_LANES (slp_node),
+ scalar_load,
slp_node, 0, cost_loc);
- cost += record_stmt_cost (cost_vec, 1, scalar_to_vec,
+ cost += record_stmt_cost (cost_vec, 1,
+ uniform_p ? scalar_to_vec : vec_construct,
slp_node, 0, cost_loc);
unsigned int prologue_cost = hoist_p ? cost : 0;
unsigned int inside_cost = hoist_p ? 0 : cost;
--
2.51.0