From 2df4150075c03f8a292c40afd3bb25febb673578 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 14 Nov 2019 15:06:34 +0000 Subject: [PATCH] Make less use of get_same_sized_vectype Some callers of get_same_sized_vectype were dealing with operands that are constant or defined externally, and so have no STMT_VINFO_VECTYPE available. Under the current model, using get_same_sized_vectype for that case is equivalent to using get_vectype_for_scalar_type, since get_vectype_for_scalar_type always returns vectors of the same size, once a size is fixed. Using get_vectype_for_scalar_type is arguably more obvious though: if we're using the same scalar type as we would for internal definitions, we should use the same vector type too. (Constant and external definitions sometimes let us change the original scalar type to a "nicer" scalar type, but that isn't what's happening here.) This is a prerequisite to supporting multiple vector sizes in the same vec_info. 2019-11-14 Richard Sandiford gcc/ * tree-vect-stmts.c (vectorizable_call): If an operand is constant or external, use get_vectype_for_scalar_type rather than get_same_sized_vectype to get its vector type. (vectorizable_conversion, vectorizable_shift): Likewise. (vectorizable_operation): Likewise. From-SVN: r278238 --- gcc/ChangeLog | 8 ++++++++ gcc/tree-vect-stmts.c | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bd9eeecea9e..28baebee3b7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-11-14 Richard Sandiford + + * tree-vect-stmts.c (vectorizable_call): If an operand is + constant or external, use get_vectype_for_scalar_type + rather than get_same_sized_vectype to get its vector type. + (vectorizable_conversion, vectorizable_shift): Likewise. + (vectorizable_operation): Likewise. + 2019-11-14 Richard Sandiford * tree-vectorizer.h (vec_info::vector_size): Replace with... diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 43b2b0fa84e..b7fff782277 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -3295,10 +3295,10 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, return false; } } - /* If all arguments are external or constant defs use a vector type with - the same size as the output vector type. */ + /* If all arguments are external or constant defs, infer the vector type + from the scalar type. */ if (!vectype_in) - vectype_in = get_same_sized_vectype (rhs_type, vectype_out); + vectype_in = get_vectype_for_scalar_type (vinfo, rhs_type); if (vec_stmt) gcc_assert (vectype_in); if (!vectype_in) @@ -4787,10 +4787,10 @@ vectorizable_conversion (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, } } - /* If op0 is an external or constant defs use a vector type of - the same size as the output vector type. */ + /* If op0 is an external or constant def, infer the vector type + from the scalar type. */ if (!vectype_in) - vectype_in = get_same_sized_vectype (rhs_type, vectype_out); + vectype_in = get_vectype_for_scalar_type (vinfo, rhs_type); if (vec_stmt) gcc_assert (vectype_in); if (!vectype_in) @@ -5586,10 +5586,10 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, "use not simple.\n"); return false; } - /* If op0 is an external or constant def use a vector type with - the same size as the output vector type. */ + /* If op0 is an external or constant def, infer the vector type + from the scalar type. */ if (!vectype) - vectype = get_same_sized_vectype (TREE_TYPE (op0), vectype_out); + vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op0)); if (vec_stmt) gcc_assert (vectype); if (!vectype) @@ -5688,7 +5688,7 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, "vector/vector shift/rotate found.\n"); if (!op1_vectype) - op1_vectype = get_same_sized_vectype (TREE_TYPE (op1), vectype_out); + op1_vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op1)); incompatible_op1_vectype_p = (op1_vectype == NULL_TREE || maybe_ne (TYPE_VECTOR_SUBPARTS (op1_vectype), @@ -6019,8 +6019,8 @@ vectorizable_operation (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, "use not simple.\n"); return false; } - /* If op0 is an external or constant def use a vector type with - the same size as the output vector type. */ + /* If op0 is an external or constant def, infer the vector type + from the scalar type. */ if (!vectype) { /* For boolean type we cannot determine vectype by @@ -6040,7 +6040,7 @@ vectorizable_operation (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, vectype = vectype_out; } else - vectype = get_same_sized_vectype (TREE_TYPE (op0), vectype_out); + vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op0)); } if (vec_stmt) gcc_assert (vectype); -- 2.30.2