gsi_replace (gsi, g, false);
}
\f
-/* Return a type for the widest vector mode whose components are of type
- TYPE, or NULL_TREE if none is found. */
+/* Return a type for the widest vector mode with the same element type as
+ type ORIGINAL_VECTOR_TYPE, with at most the same number of elements as type
+ ORIGINAL_VECTOR_TYPE and that is supported by the target for an operation
+ with optab OP, or return NULL_TREE if none is found. */
static tree
-type_for_widest_vector_mode (tree type, optab op)
+type_for_widest_vector_mode (tree original_vector_type, optab op)
{
+ gcc_assert (VECTOR_TYPE_P (original_vector_type));
+ tree type = TREE_TYPE (original_vector_type);
machine_mode inner_mode = TYPE_MODE (type);
machine_mode best_mode = VOIDmode, mode;
poly_int64 best_nunits = 0;
FOR_EACH_MODE_FROM (mode, mode)
if (GET_MODE_INNER (mode) == inner_mode
&& maybe_gt (GET_MODE_NUNITS (mode), best_nunits)
- && optab_handler (op, mode) != CODE_FOR_nothing)
+ && optab_handler (op, mode) != CODE_FOR_nothing
+ && known_le (GET_MODE_NUNITS (mode),
+ TYPE_VECTOR_SUBPARTS (original_vector_type)))
best_mode = mode, best_nunits = GET_MODE_NUNITS (mode);
if (best_mode == VOIDmode)
|| optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing))
{
tree vector_compute_type
- = type_for_widest_vector_mode (TREE_TYPE (type), op);
+ = type_for_widest_vector_mode (type, op);
if (vector_compute_type != NULL_TREE
- && subparts_gt (compute_type, vector_compute_type)
&& maybe_ne (TYPE_VECTOR_SUBPARTS (vector_compute_type), 1U)
&& (optab_handler (op, TYPE_MODE (vector_compute_type))
!= CODE_FOR_nothing))
/* Can't use get_compute_type here, as supportable_convert_operation
doesn't necessarily use an optab and needs two arguments. */
tree vec_compute_type
- = type_for_widest_vector_mode (TREE_TYPE (arg_type), mov_optab);
+ = type_for_widest_vector_mode (arg_type, mov_optab);
if (vec_compute_type
- && VECTOR_MODE_P (TYPE_MODE (vec_compute_type))
- && subparts_gt (arg_type, vec_compute_type))
+ && VECTOR_MODE_P (TYPE_MODE (vec_compute_type)))
{
unsigned HOST_WIDE_INT nelts
= constant_lower_bound (TYPE_VECTOR_SUBPARTS (vec_compute_type));