if (3 * i + nelt2 < nelt)
sel[3 * i + nelt2] = 0;
}
- perm3_mask_low = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm3_mask_low != NULL);
+ perm3_mask_low = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0; i < nelt; i++)
{
if (3 * i + nelt2 < nelt)
sel[3 * i + nelt2] = nelt + j2++;
}
- perm3_mask_high = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm3_mask_high != NULL);
+ perm3_mask_high = vect_gen_perm_mask_checked (vectype, sel);
vect1 = dr_chain[0];
vect2 = dr_chain[1];
sel[i * 2] = i;
sel[i * 2 + 1] = i + nelt;
}
- perm_mask_high = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm_mask_high != NULL);
+ perm_mask_high = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0; i < nelt; i++)
sel[i] += nelt / 2;
- perm_mask_low = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm_mask_low != NULL);
+ perm_mask_low = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0, n = log_length; i < n; i++)
{
sel[i] = 3 * i + k;
else
sel[i] = 0;
- perm3_mask_low = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm3_mask_low != NULL);
+ perm3_mask_low = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0, j = 0; i < nelt; i++)
if (3 * i + k < 2 * nelt)
else
sel[i] = nelt + ((nelt + k) % 3) + 3 * (j++);
- perm3_mask_high = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm3_mask_high != NULL);
+ perm3_mask_high = vect_gen_perm_mask_checked (vectype, sel);
first_vect = dr_chain[0];
second_vect = dr_chain[1];
for (i = 0; i < nelt; ++i)
sel[i] = i * 2;
- perm_mask_even = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm_mask_even != NULL);
+ perm_mask_even = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0; i < nelt; ++i)
sel[i] = i * 2 + 1;
- perm_mask_odd = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm_mask_odd != NULL);
+ perm_mask_odd = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0; i < log_length; i++)
{
supported by target\n");
return false;
}
- perm2_mask1 = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm2_mask1 != NULL);
+ perm2_mask1 = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0; i < nelt / 2; ++i)
sel[i] = i * 2 + 1;
supported by target\n");
return false;
}
- perm2_mask2 = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm2_mask2 != NULL);
+ perm2_mask2 = vect_gen_perm_mask_checked (vectype, sel);
/* Generating permutation constant to shift all elements.
For vector length 8 it is {4 5 6 7 8 9 10 11}. */
"shift permutation is not supported by target\n");
return false;
}
- shift1_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (shift1_mask != NULL);
+ shift1_mask = vect_gen_perm_mask_checked (vectype, sel);
/* Generating permutation constant to select vector from 2.
For vector length 8 it is {0 1 2 3 12 13 14 15}. */
"select is not supported by target\n");
return false;
}
- select_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (select_mask != NULL);
+ select_mask = vect_gen_perm_mask_checked (vectype, sel);
for (i = 0; i < log_length; i++)
{
supported by target\n");
return false;
}
- perm3_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm3_mask != NULL);
+ perm3_mask = vect_gen_perm_mask_checked (vectype, sel);
/* Generating permutation constant to shift all elements.
For vector length 8 it is {6 7 8 9 10 11 12 13}. */
"shift permutation is not supported by target\n");
return false;
}
- shift1_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (shift1_mask != NULL);
+ shift1_mask = vect_gen_perm_mask_checked (vectype, sel);
/* Generating permutation constant to shift all elements.
For vector length 8 it is {5 6 7 8 9 10 11 12}. */
"shift permutation is not supported by target\n");
return false;
}
- shift2_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (shift2_mask != NULL);
+ shift2_mask = vect_gen_perm_mask_checked (vectype, sel);
/* Generating permutation constant to shift all elements.
For vector length 8 it is {3 4 5 6 7 8 9 10}. */
"shift permutation is not supported by target\n");
return false;
}
- shift3_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (shift3_mask != NULL);
+ shift3_mask = vect_gen_perm_mask_checked (vectype, sel);
/* Generating permutation constant to shift all elements.
For vector length 8 it is {5 6 7 8 9 10 11 12}. */
"shift permutation is not supported by target\n");
return false;
}
- shift4_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (shift4_mask != NULL);
+ shift4_mask = vect_gen_perm_mask_checked (vectype, sel);
for (k = 0; k < 3; k++)
{
for (i = 0; i < gather_off_nunits; ++i)
sel[i] = i | nunits;
- perm_mask = vect_gen_perm_mask (gather_off_vectype, sel);
- gcc_assert (perm_mask != NULL_TREE);
+ perm_mask = vect_gen_perm_mask_checked (gather_off_vectype, sel);
}
else if (nunits == gather_off_nunits * 2)
{
sel[i] = i < gather_off_nunits
? i : i + nunits - gather_off_nunits;
- perm_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm_mask != NULL_TREE);
+ perm_mask = vect_gen_perm_mask_checked (vectype, sel);
ncopies *= 2;
for (i = 0; i < nunits; ++i)
sel[i] = i | gather_off_nunits;
- mask_perm_mask = vect_gen_perm_mask (masktype, sel);
- gcc_assert (mask_perm_mask != NULL_TREE);
+ mask_perm_mask = vect_gen_perm_mask_checked (masktype, sel);
}
else
gcc_unreachable ();
for (i = 0; i < nunits; ++i)
sel[i] = nunits - 1 - i;
- return vect_gen_perm_mask (vectype, sel);
+ if (!can_vec_perm_p (TYPE_MODE (vectype), false, sel))
+ return NULL_TREE;
+ return vect_gen_perm_mask_checked (vectype, sel);
}
/* Function vectorizable_store.
return true;
}
-/* Given a vector type VECTYPE and permutation SEL returns
- the VECTOR_CST mask that implements the permutation of the
- vector elements. If that is impossible to do, returns NULL. */
+/* Given a vector type VECTYPE, turns permutation SEL into the equivalent
+ VECTOR_CST mask. No checks are made that the target platform supports the
+ mask, so callers may wish to test can_vec_perm_p separately, or use
+ vect_gen_perm_mask_checked. */
tree
-vect_gen_perm_mask (tree vectype, unsigned char *sel)
+vect_gen_perm_mask_any (tree vectype, const unsigned char *sel)
{
tree mask_elt_type, mask_type, mask_vec, *mask_elts;
int i, nunits;
nunits = TYPE_VECTOR_SUBPARTS (vectype);
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, sel))
- return NULL;
-
mask_elt_type = lang_hooks.types.type_for_mode
(int_mode_for_mode (TYPE_MODE (TREE_TYPE (vectype))), 1);
mask_type = get_vectype_for_scalar_type (mask_elt_type);
return mask_vec;
}
+/* Checked version of vect_gen_perm_mask_any. Asserts can_vec_perm_p. */
+
+tree
+vect_gen_perm_mask_checked (tree vectype, const unsigned char *sel)
+{
+ gcc_assert (can_vec_perm_p (TYPE_MODE (vectype), false, sel));
+ return vect_gen_perm_mask_any (vectype, sel);
+}
+
/* Given a vector variable X and Y, that was generated for the scalar
STMT, generate instructions to permute the vector elements of X and Y
using permutation mask MASK_VEC, insert them at *GSI and return the
for (i = 0; i < gather_off_nunits; ++i)
sel[i] = i | nunits;
- perm_mask = vect_gen_perm_mask (gather_off_vectype, sel);
- gcc_assert (perm_mask != NULL_TREE);
+ perm_mask = vect_gen_perm_mask_checked (gather_off_vectype, sel);
}
else if (nunits == gather_off_nunits * 2)
{
sel[i] = i < gather_off_nunits
? i : i + nunits - gather_off_nunits;
- perm_mask = vect_gen_perm_mask (vectype, sel);
- gcc_assert (perm_mask != NULL_TREE);
+ perm_mask = vect_gen_perm_mask_checked (vectype, sel);
ncopies *= 2;
}
else