Commit 2df41500 by Richard Sandiford Committed by Richard Sandiford

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  <richard.sandiford@arm.com>

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
parent 1c84a2d2
2019-11-14 Richard Sandiford <richard.sandiford@arm.com> 2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
* 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 <richard.sandiford@arm.com>
* tree-vectorizer.h (vec_info::vector_size): Replace with... * tree-vectorizer.h (vec_info::vector_size): Replace with...
(vec_info::vector_mode): ...this new field. (vec_info::vector_mode): ...this new field.
* tree-vect-loop.c (vect_update_vf_for_slp): Update accordingly. * tree-vect-loop.c (vect_update_vf_for_slp): Update accordingly.
...@@ -3295,10 +3295,10 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -3295,10 +3295,10 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
return false; return false;
} }
} }
/* If all arguments are external or constant defs use a vector type with /* If all arguments are external or constant defs, infer the vector type
the same size as the output vector type. */ from the scalar type. */
if (!vectype_in) 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) if (vec_stmt)
gcc_assert (vectype_in); gcc_assert (vectype_in);
if (!vectype_in) if (!vectype_in)
...@@ -4787,10 +4787,10 @@ vectorizable_conversion (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -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 /* If op0 is an external or constant def, infer the vector type
the same size as the output vector type. */ from the scalar type. */
if (!vectype_in) 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) if (vec_stmt)
gcc_assert (vectype_in); gcc_assert (vectype_in);
if (!vectype_in) if (!vectype_in)
...@@ -5586,10 +5586,10 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -5586,10 +5586,10 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
"use not simple.\n"); "use not simple.\n");
return false; return false;
} }
/* If op0 is an external or constant def use a vector type with /* If op0 is an external or constant def, infer the vector type
the same size as the output vector type. */ from the scalar type. */
if (!vectype) 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) if (vec_stmt)
gcc_assert (vectype); gcc_assert (vectype);
if (!vectype) if (!vectype)
...@@ -5688,7 +5688,7 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -5688,7 +5688,7 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
"vector/vector shift/rotate found.\n"); "vector/vector shift/rotate found.\n");
if (!op1_vectype) 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 incompatible_op1_vectype_p
= (op1_vectype == NULL_TREE = (op1_vectype == NULL_TREE
|| maybe_ne (TYPE_VECTOR_SUBPARTS (op1_vectype), || maybe_ne (TYPE_VECTOR_SUBPARTS (op1_vectype),
...@@ -6019,8 +6019,8 @@ vectorizable_operation (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -6019,8 +6019,8 @@ vectorizable_operation (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
"use not simple.\n"); "use not simple.\n");
return false; return false;
} }
/* If op0 is an external or constant def use a vector type with /* If op0 is an external or constant def, infer the vector type
the same size as the output vector type. */ from the scalar type. */
if (!vectype) if (!vectype)
{ {
/* For boolean type we cannot determine vectype by /* For boolean type we cannot determine vectype by
...@@ -6040,7 +6040,7 @@ vectorizable_operation (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -6040,7 +6040,7 @@ vectorizable_operation (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
vectype = vectype_out; vectype = vectype_out;
} }
else else
vectype = get_same_sized_vectype (TREE_TYPE (op0), vectype_out); vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op0));
} }
if (vec_stmt) if (vec_stmt)
gcc_assert (vectype); gcc_assert (vectype);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment