+2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
+
+ * optabs.c (shift_amt_for_vec_perm_mask): Try using series_p
+ before testing each element individually.
+ * tree-vect-generic.c (lower_vec_perm): Likewise.
+
2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
* selftest.h (selftest::vec_perm_indices_c_tests): Declare.
static rtx
shift_amt_for_vec_perm_mask (machine_mode mode, const vec_perm_indices &sel)
{
- unsigned int i, first, nelt = GET_MODE_NUNITS (mode);
+ unsigned int nelt = GET_MODE_NUNITS (mode);
unsigned int bitsize = GET_MODE_UNIT_BITSIZE (mode);
-
- first = sel[0];
+ unsigned int first = sel[0];
if (first >= nelt)
return NULL_RTX;
- for (i = 1; i < nelt; i++)
- {
- int idx = sel[i];
- unsigned int expected = i + first;
- /* Indices into the second vector are all equivalent. */
- if (idx < 0 || (MIN (nelt, (unsigned) idx) != MIN (nelt, expected)))
- return NULL_RTX;
- }
+
+ if (!sel.series_p (0, 1, first, 1))
+ for (unsigned int i = 1; i < nelt; i++)
+ {
+ unsigned int expected = i + first;
+ /* Indices into the second vector are all equivalent. */
+ if (MIN (nelt, sel[i]) != MIN (nelt, expected))
+ return NULL_RTX;
+ }
return gen_int_shift_amount (mode, first * bitsize);
}
&& indices[0]
&& indices[0] < elements)
{
- for (i = 1; i < elements; ++i)
+ bool ok_p = indices.series_p (0, 1, indices[0], 1);
+ if (!ok_p)
{
- unsigned int expected = i + indices[0];
- /* Indices into the second vector are all equivalent. */
- if (MIN (elements, (unsigned) indices[i])
- != MIN (elements, expected))
- break;
+ for (i = 1; i < elements; ++i)
+ {
+ unsigned int expected = i + indices[0];
+ /* Indices into the second vector are all equivalent. */
+ if (MIN (elements, (unsigned) indices[i])
+ != MIN (elements, expected))
+ break;
+ }
+ ok_p = i == elements;
}
- if (i == elements)
+ if (ok_p)
{
gimple_assign_set_rhs3 (stmt, mask);
update_stmt (stmt);