+2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
+
+ * machmode.h (mode_for_int_vector): New function.
+ * stor-layout.c (mode_for_int_vector): Likewise.
+ * config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Use it.
+ * config/powerpcspe/powerpcspe.c (rs6000_do_expand_vec_perm): Likewise.
+ * config/rs6000/rs6000.c (rs6000_do_expand_vec_perm): Likewise.
+ * config/s390/s390.c (s390_expand_vec_compare_cc): Likewise.
+ (s390_expand_vcond): Likewise.
+
2017-09-05 Richard Sandiford <richard.sandiford@linaro.org>
* machmode.h (opt_machine_mode): New type.
return false;
}
- machine_mode mmsk
- = mode_for_vector (int_mode_for_mode (GET_MODE_INNER (mode)).require (),
- GET_MODE_NUNITS (mode));
if (!recp)
{
if (!(flag_mlow_precision_sqrt
/* Caller assumes we cannot fail. */
gcc_assert (use_rsqrt_p (mode));
-
+ machine_mode mmsk = mode_for_int_vector (mode).require ();
rtx xmsk = gen_reg_rtx (mmsk);
if (!recp)
/* When calculating the approximate square root, compare the
imode = vmode;
if (GET_MODE_CLASS (vmode) != MODE_VECTOR_INT)
- imode = mode_for_vector
- (int_mode_for_mode (GET_MODE_INNER (vmode)).require (), nelt);
+ imode = mode_for_int_vector (vmode).require ();
x = gen_rtx_CONST_VECTOR (imode, gen_rtvec_v (nelt, perm));
x = expand_vec_perm (vmode, op0, op1, x, target);
imode = vmode;
if (GET_MODE_CLASS (vmode) != MODE_VECTOR_INT)
- imode = mode_for_vector
- (int_mode_for_mode (GET_MODE_INNER (vmode)).require (), nelt);
+ imode = mode_for_int_vector (vmode).require ();
x = gen_rtx_CONST_VECTOR (imode, gen_rtvec_v (nelt, perm));
x = expand_vec_perm (vmode, op0, op1, x, target);
case LE: cc_producer_mode = CCVFHEmode; code = GE; swap_p = true; break;
default: gcc_unreachable ();
}
- scratch_mode = mode_for_vector
- (int_mode_for_mode (GET_MODE_INNER (GET_MODE (cmp1))).require (),
- GET_MODE_NUNITS (GET_MODE (cmp1)));
- gcc_assert (scratch_mode != BLKmode);
+ scratch_mode = mode_for_int_vector (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_vector
- (int_mode_for_mode (GET_MODE_INNER (cmp_mode)).require (),
- GET_MODE_NUNITS (cmp_mode));
+ result_mode = mode_for_int_vector (cmp_mode).require ();
result_target = gen_reg_rtx (result_mode);
/* We allow vector immediates as comparison operands that
extern machine_mode mode_for_vector (scalar_mode, unsigned);
+extern opt_machine_mode mode_for_int_vector (unsigned int, unsigned int);
+
+/* 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));
+}
+
/* A class for iterating through possible bitfield modes. */
class bit_field_mode_iterator
{
return 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, unsigned int nunits)
+{
+ scalar_int_mode int_mode;
+ if (int_mode_for_size (int_bits, 0).exists (&int_mode))
+ {
+ machine_mode vec_mode = mode_for_vector (int_mode, nunits);
+ if (vec_mode != BLKmode)
+ return vec_mode;
+ }
+ return opt_machine_mode ();
+}
+
/* Return the alignment of MODE. This will be bounded by 1 and
BIGGEST_ALIGNMENT. */