From f8f8fee8a29c116bf8fe29a93cc555b37835c8bd Mon Sep 17 00:00:00 2001 From: Ira Rosen Date: Wed, 12 Sep 2007 05:09:17 +0000 Subject: [PATCH] tree-vect-transform.c (vect_get_slp_defs): Don't build a vector for oprnd1 if not required. * tree-vect-transform.c (vect_get_slp_defs): Don't build a vector for oprnd1 if not required. (vectorizable_operation): Use scalar operand in SLP in case of shift with scalar argument. From-SVN: r128412 --- gcc/ChangeLog | 7 +++++++ gcc/tree-vect-transform.c | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a045d10ab6..6d8433d234a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-09-12 Ira Rosen + + * tree-vect-transform.c (vect_get_slp_defs): Don't build a vector + for oprnd1 if not required. + (vectorizable_operation): Use scalar operand in SLP in case of + shift with scalar argument. + 2007-09-12 Ira Rosen * params.def (PARAM_MIN_VECT_LOOP_BOUND): Change default and minimum diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c index e2ee92b0d0e..5331fcd763a 100644 --- a/gcc/tree-vect-transform.c +++ b/gcc/tree-vect-transform.c @@ -1392,7 +1392,9 @@ vect_get_slp_vect_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds) call vect_get_constant_vectors() to create vector stmts. Otherwise, the def-stmts must be already vectorized and the vectorized stmts must be stored in the LEFT/RIGHT node of SLP_NODE, and we call - vect_get_slp_vect_defs() to retrieve them. */ + vect_get_slp_vect_defs() to retrieve them. + If VEC_OPRNDS1 is NULL, don't get vector defs for the second operand (from + the right node. This is used when the second operand must remain scalar. */ static void vect_get_slp_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds0, @@ -1420,7 +1422,7 @@ vect_get_slp_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds0, return; operation = GIMPLE_STMT_OPERAND (first_stmt, 1); - if (TREE_OPERAND_LENGTH (operation) == unary_op) + if (TREE_OPERAND_LENGTH (operation) == unary_op || !vec_oprnds1) return; *vec_oprnds1 = VEC_alloc (tree, heap, @@ -3891,11 +3893,9 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt, vec_dest = vect_create_destination_var (scalar_dest, vectype); if (!slp_node) - { - vec_oprnds0 = VEC_alloc (tree, heap, 1); - if (op_type == binary_op) - vec_oprnds1 = VEC_alloc (tree, heap, 1); - } + vec_oprnds0 = VEC_alloc (tree, heap, 1); + if (op_type == binary_op) + vec_oprnds1 = VEC_alloc (tree, heap, 1); /* In case the vectorization factor (VF) is bigger than the number of elements that we can fit in a vectype (nunits), we have to generate @@ -3957,8 +3957,7 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt, if (j == 0) { if (op_type == binary_op - && (code == LSHIFT_EXPR || code == RSHIFT_EXPR) - && !slp_node) + && (code == LSHIFT_EXPR || code == RSHIFT_EXPR)) { /* Vector shl and shr insn patterns can be defined with scalar operand 2 (shift operand). In this case, use constant or loop @@ -3974,11 +3973,14 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt, } } + /* vec_oprnd is available if operand 1 should be of a scalar-type + (a special case for certain kind of vector shifts); otherwise, + operand 1 should be of a vector type (the usual case). */ if (op_type == binary_op && !vec_oprnd1) vect_get_vec_defs (op0, op1, stmt, &vec_oprnds0, &vec_oprnds1, slp_node); else - vect_get_vec_defs (op0, NULL_TREE, stmt, &vec_oprnds0, &vec_oprnds1, + vect_get_vec_defs (op0, NULL_TREE, stmt, &vec_oprnds0, NULL, slp_node); } else -- 2.30.2