+2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
+
+ * machmode.h (mode_for_int_vector): Delete.
+ (related_int_vector_mode): Declare.
+ * stor-layout.c (mode_for_int_vector): Delete.
+ (related_int_vector_mode): New function.
+ * optabs.c (expand_vec_perm_1): Use related_int_vector_mode
+ instead of mode_for_int_vector.
+ (expand_vec_perm_const): Likewise.
+ * config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Likewise.
+ (aarch64_evpc_sve_tbl): Likewise.
+ * config/s390/s390.c (s390_expand_vec_compare_cc): Likewise.
+ (s390_expand_vcond): Likewise.
+
2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
* target.def (related_mode): New hook.
}
/* Return the integer vector mode associated with SVE mode MODE.
- Unlike mode_for_int_vector, this can handle the case in which
+ Unlike related_int_vector_mode, this can handle the case in which
MODE is a predicate (and thus has a different total size). */
machine_mode
gcc_assert (use_rsqrt_p (mode));
machine_mode mmsk = (VECTOR_MODE_P (mode)
- ? mode_for_int_vector (mode).require ()
+ ? related_int_vector_mode (mode).require ()
: int_mode_for_mode (mode).require ());
rtx xmsk = gen_reg_rtx (mmsk);
if (!recp)
if (d->testing_p)
return true;
- machine_mode sel_mode = mode_for_int_vector (d->vmode).require ();
+ machine_mode sel_mode = related_int_vector_mode (d->vmode).require ();
rtx sel = vec_perm_indices_to_rtx (sel_mode, d->perm);
if (d->one_vector_p)
emit_unspec2 (d->target, UNSPEC_TBL, d->op0, force_reg (sel_mode, sel));
case LE: cc_producer_mode = CCVFHEmode; code = GE; swap_p = true; break;
default: gcc_unreachable ();
}
- scratch_mode = mode_for_int_vector (GET_MODE (cmp1)).require ();
+ scratch_mode = related_int_vector_mode (GET_MODE (cmp1)).require ();
if (inv_p)
all_p = !all_p;
/* We always use an integral type vector to hold the comparison
result. */
- result_mode = mode_for_int_vector (cmp_mode).require ();
+ result_mode = related_int_vector_mode (cmp_mode).require ();
result_target = gen_reg_rtx (result_mode);
/* We allow vector immediates as comparison operands that
extern opt_scalar_int_mode int_mode_for_mode (machine_mode);
extern opt_machine_mode bitwise_mode_for_mode (machine_mode);
extern opt_machine_mode mode_for_vector (scalar_mode, poly_uint64);
-extern opt_machine_mode mode_for_int_vector (unsigned int, poly_uint64);
extern opt_machine_mode related_vector_mode (machine_mode, scalar_mode,
poly_uint64 = 0);
-
-/* Return the integer vector equivalent of MODE, if one exists. In other
- words, return the mode for an integer vector that has the same number
- of bits as MODE and the same number of elements as MODE, with the
- latter being 1 if MODE is scalar. The returned mode can be either
- an integer mode or a vector mode. */
-
-inline opt_machine_mode
-mode_for_int_vector (machine_mode mode)
-{
- return mode_for_int_vector (GET_MODE_UNIT_BITSIZE (mode),
- GET_MODE_NUNITS (mode));
-}
+extern opt_machine_mode related_int_vector_mode (machine_mode);
/* A class for iterating through possible bitfield modes. */
class bit_field_mode_iterator
class expand_operand ops[4];
gcc_assert (GET_MODE_CLASS (smode) == MODE_VECTOR_INT
- || mode_for_int_vector (tmode).require () == smode);
+ || related_int_vector_mode (tmode).require () == smode);
create_output_operand (&ops[0], target, tmode);
create_input_operand (&ops[3], sel, smode);
/* The optabs are only defined for selectors with the same width
as the values being permuted. */
machine_mode required_sel_mode;
- if (!mode_for_int_vector (mode).exists (&required_sel_mode)
- || !VECTOR_MODE_P (required_sel_mode))
+ if (!related_int_vector_mode (mode).exists (&required_sel_mode))
{
delete_insns_since (last);
return NULL_RTX;
return opt_machine_mode ();
}
-/* Return the mode for a vector that has NUNITS integer elements of
- INT_BITS bits each, if such a mode exists. The mode can be either
- an integer mode or a vector mode. */
-
-opt_machine_mode
-mode_for_int_vector (unsigned int int_bits, poly_uint64 nunits)
-{
- scalar_int_mode int_mode;
- machine_mode vec_mode;
- if (int_mode_for_size (int_bits, 0).exists (&int_mode)
- && mode_for_vector (int_mode, nunits).exists (&vec_mode))
- return vec_mode;
- return opt_machine_mode ();
-}
-
/* If a piece of code is using vector mode VECTOR_MODE and also wants
to operate on elements of mode ELEMENT_MODE, return the vector mode
it should use for those elements. If NUNITS is nonzero, ensure that
return targetm.vectorize.related_mode (vector_mode, element_mode, nunits);
}
+/* If a piece of code is using vector mode VECTOR_MODE and also wants
+ to operate on integer vectors with the same element size and number
+ of elements, return the vector mode it should use. Return an empty
+ opt_machine_mode if there is no supported vector mode with the
+ required properties.
+
+ Unlike mode_for_vector. any returned mode is guaranteed to satisfy
+ both VECTOR_MODE_P and targetm.vector_mode_supported_p. */
+
+opt_machine_mode
+related_int_vector_mode (machine_mode vector_mode)
+{
+ gcc_assert (VECTOR_MODE_P (vector_mode));
+ scalar_int_mode int_mode;
+ if (int_mode_for_mode (GET_MODE_INNER (vector_mode)).exists (&int_mode))
+ return related_vector_mode (vector_mode, int_mode,
+ GET_MODE_NUNITS (vector_mode));
+ return opt_machine_mode ();
+}
+
/* Return the alignment of MODE. This will be bounded by 1 and
BIGGEST_ALIGNMENT. */