This reduces more calls to get_vectype_for_scalar_type. * tree-vect-loop.cc (vect_transform_cycle_phi): Specify the vector type for invariant/external defs. * tree-vect-stmts.cc (vectorizable_shift): For invariant or external shifted operands use the result vector type. Specify the vector type for invariant/external defs. (vectorizable_store): Likewise. --- gcc/tree-vect-loop.cc | 2 +- gcc/tree-vect-stmts.cc | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 3af4160426b..9e531921e29 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -8749,7 +8749,7 @@ vect_transform_cycle_phi (loop_vec_info loop_vinfo, correctly if ncopies is not one. */ vect_get_vec_defs_for_operand (loop_vinfo, reduc_stmt_info, ncopies, initial_def, - &vec_initial_defs); + &vec_initial_defs, vectype_out); } else if (STMT_VINFO_REDUC_TYPE (reduc_info) == CONST_COND_REDUCTION || STMT_VINFO_REDUC_TYPE (reduc_info) == COND_REDUCTION) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 5ad306e2b08..88401a2a00b 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6126,19 +6126,11 @@ vectorizable_shift (vec_info *vinfo, "use not simple.\n"); return false; } - /* If op0 is an external or constant def, infer the vector type - from the scalar type. */ + /* If op0 is an external or constant def, use the output vector type. */ if (!vectype) - vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op0), slp_node); + vectype = vectype_out; if (vec_stmt) gcc_assert (vectype); - if (!vectype) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "no vectype for scalar type\n"); - return false; - } nunits_out = TYPE_VECTOR_SUBPARTS (vectype_out); nunits_in = TYPE_VECTOR_SUBPARTS (vectype); @@ -6426,8 +6418,8 @@ vectorizable_shift (vec_info *vinfo, (a special case for certain kind of vector shifts); otherwise, operand 1 should be of a vector type (the usual case). */ vect_get_vec_defs (vinfo, stmt_info, slp_node, ncopies, - op0, &vec_oprnds0, - vec_oprnd1 ? NULL_TREE : op1, &vec_oprnds1); + op0, vectype, &vec_oprnds0, + vec_oprnd1 ? NULL_TREE : op1, op1_vectype, &vec_oprnds1); /* Arguments are ready. Create the new vector stmt. */ FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0) @@ -8537,7 +8529,7 @@ vectorizable_store (vec_info *vinfo, op = vect_get_store_rhs (next_stmt_info); if (!costing_p) vect_get_vec_defs (vinfo, next_stmt_info, slp_node, ncopies, op, - &vec_oprnds); + vectype, &vec_oprnds); else update_prologue_cost (&prologue_cost, op); unsigned int group_el = 0; @@ -9303,7 +9295,7 @@ vectorizable_store (vec_info *vinfo, { vect_get_vec_defs_for_operand (vinfo, next_stmt_info, ncopies, op, - gvec_oprnds[i]); + gvec_oprnds[i], vectype); vec_oprnd = (*gvec_oprnds[i])[0]; dr_chain.quick_push (vec_oprnd); } -- 2.35.3