Hi,

vect_bb_slp_scalar_cost computes the scalar cost of a SLP node. If there are 
non-scalar uses of a definition, the costs for it and its operands (children) 
are ignored. The vector LIFE is used to keep track of this and an element is 
set to true, such that the def and its children are ignored. But as soon as an 
element is set to true it is never undone, that means the following sibling and 
parent nodes of the current node also stay ignored. This seems wrong to me, a 
simple fix would be to clone LIFE for every vector, such that changes to LIFE 
stay in the subtree:

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 032a9444a5a..f919645f28b 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2590,6 +2590,11 @@ vect_bb_slp_scalar_cost (basic_block bb,
   gimple *stmt;
   slp_tree child;

+  auto_vec<bool, 20> subtree_life;
+  subtree_life.safe_splice (*life);
+
+  life = &subtree_life;
+
   FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt)
     {
       unsigned stmt_cost;


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to