aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-data-refs.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-01-02 18:26:06 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-01-02 18:26:06 +0000
commit7ac7e2868d450dfb9080166ddc4abcc21b86fab3 (patch)
tree944b586115ea01dff6dac70820714852c4cf2029 /gcc/tree-vect-data-refs.c
parent4aae3cb3559802faee3b5cb58d9315dcc5000bc8 (diff)
downloadgcc-7ac7e2868d450dfb9080166ddc4abcc21b86fab3.zip
gcc-7ac7e2868d450dfb9080166ddc4abcc21b86fab3.tar.gz
gcc-7ac7e2868d450dfb9080166ddc4abcc21b86fab3.tar.bz2
Split can_vec_perm_p into can_vec_perm_{var,const}_p
This patch splits can_vec_perm_p into two functions: can_vec_perm_var_p for testing permute operations with variable selection vectors, and can_vec_perm_const_p for testing permute operations with specific constant selection vectors. This means that we can pass the constant selection vector by reference. Constant permutes can still use a variable permute as a fallback. A later patch adds a check to makre sure that we don't truncate the vector indices when doing this. However, have_whole_vector_shift checked: if (direct_optab_handler (vec_perm_const_optab, mode) == CODE_FOR_nothing) return false; which had the effect of disallowing the fallback to variable permutes. I'm not sure whether that was the intention or whether it was just supposed to short-cut the loop on targets that don't support permutes. (But then why bother? The first check in the loop would fail and we'd bail out straightaway.) The patch adds a parameter for disallowing the fallback. I think it makes sense to do this for the following code in the VEC_PERM_EXPR folder: /* Some targets are deficient and fail to expand a single argument permutation while still allowing an equivalent 2-argument version. */ if (need_mask_canon && arg2 == op2 && !can_vec_perm_p (TYPE_MODE (type), false, &sel) && can_vec_perm_p (TYPE_MODE (type), false, &sel2)) since it's really testing whether the expand_vec_perm_const code expects a particular form. 2018-01-02 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * optabs-query.h (can_vec_perm_p): Delete. (can_vec_perm_var_p, can_vec_perm_const_p): Declare. * optabs-query.c (can_vec_perm_p): Split into... (can_vec_perm_var_p, can_vec_perm_const_p): ...these two functions. (can_mult_highpart_p): Use can_vec_perm_const_p to test whether a particular selector is valid. * tree-ssa-forwprop.c (simplify_vector_constructor): Likewise. * tree-vect-data-refs.c (vect_grouped_store_supported): Likewise. (vect_grouped_load_supported): Likewise. (vect_shift_permute_load_chain): Likewise. * tree-vect-slp.c (vect_build_slp_tree_1): Likewise. (vect_transform_slp_perm_load): Likewise. * tree-vect-stmts.c (perm_mask_for_reverse): Likewise. (vectorizable_bswap): Likewise. (vect_gen_perm_mask_checked): Likewise. * fold-const.c (fold_ternary_loc): Likewise. Don't take implementations of variable permutation vectors into account when deciding which selector to use. * tree-vect-loop.c (have_whole_vector_shift): Don't check whether vec_perm_const_optab is supported; instead use can_vec_perm_const_p with a false third argument. * tree-vect-generic.c (lower_vec_perm): Use can_vec_perm_const_p to test whether the constant selector is valid and can_vec_perm_var_p to test whether a variable selector is valid. From-SVN: r256091
Diffstat (limited to 'gcc/tree-vect-data-refs.c')
-rw-r--r--gcc/tree-vect-data-refs.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 014862a..bbbeef6 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4600,11 +4600,11 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
if (3 * i + nelt2 < nelt)
sel[3 * i + nelt2] = 0;
}
- if (!can_vec_perm_p (mode, false, &sel))
+ if (!can_vec_perm_const_p (mode, sel))
{
if (dump_enabled_p ())
dump_printf (MSG_MISSED_OPTIMIZATION,
- "permutaion op not supported by target.\n");
+ "permutation op not supported by target.\n");
return false;
}
@@ -4617,11 +4617,11 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
if (3 * i + nelt2 < nelt)
sel[3 * i + nelt2] = nelt + j2++;
}
- if (!can_vec_perm_p (mode, false, &sel))
+ if (!can_vec_perm_const_p (mode, sel))
{
if (dump_enabled_p ())
dump_printf (MSG_MISSED_OPTIMIZATION,
- "permutaion op not supported by target.\n");
+ "permutation op not supported by target.\n");
return false;
}
}
@@ -4637,11 +4637,11 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
sel[i * 2] = i;
sel[i * 2 + 1] = i + nelt;
}
- if (can_vec_perm_p (mode, false, &sel))
+ if (can_vec_perm_const_p (mode, sel))
{
for (i = 0; i < nelt; i++)
sel[i] += nelt / 2;
- if (can_vec_perm_p (mode, false, &sel))
+ if (can_vec_perm_const_p (mode, sel))
return true;
}
}
@@ -5179,7 +5179,7 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
sel[i] = 3 * i + k;
else
sel[i] = 0;
- if (!can_vec_perm_p (mode, false, &sel))
+ if (!can_vec_perm_const_p (mode, sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5192,7 +5192,7 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
sel[i] = i;
else
sel[i] = nelt + ((nelt + k) % 3) + 3 * (j++);
- if (!can_vec_perm_p (mode, false, &sel))
+ if (!can_vec_perm_const_p (mode, sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5209,11 +5209,11 @@ vect_grouped_load_supported (tree vectype, bool single_element_p,
gcc_assert (pow2p_hwi (count));
for (i = 0; i < nelt; i++)
sel[i] = i * 2;
- if (can_vec_perm_p (mode, false, &sel))
+ if (can_vec_perm_const_p (mode, sel))
{
for (i = 0; i < nelt; i++)
sel[i] = i * 2 + 1;
- if (can_vec_perm_p (mode, false, &sel))
+ if (can_vec_perm_const_p (mode, sel))
return true;
}
}
@@ -5540,7 +5540,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
sel[i] = i * 2;
for (i = 0; i < nelt / 2; ++i)
sel[nelt / 2 + i] = i * 2 + 1;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5554,7 +5554,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
sel[i] = i * 2 + 1;
for (i = 0; i < nelt / 2; ++i)
sel[nelt / 2 + i] = i * 2;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5568,7 +5568,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
For vector length 8 it is {4 5 6 7 8 9 10 11}. */
for (i = 0; i < nelt; i++)
sel[i] = nelt / 2 + i;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5583,7 +5583,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
sel[i] = i;
for (i = nelt / 2; i < nelt; i++)
sel[i] = nelt + i;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5646,7 +5646,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
sel[i] = 3 * k + (l % 3);
k++;
}
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5660,7 +5660,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
For vector length 8 it is {6 7 8 9 10 11 12 13}. */
for (i = 0; i < nelt; i++)
sel[i] = 2 * (nelt / 3) + (nelt % 3) + i;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5673,7 +5673,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
For vector length 8 it is {5 6 7 8 9 10 11 12}. */
for (i = 0; i < nelt; i++)
sel[i] = 2 * (nelt / 3) + 1 + i;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5686,7 +5686,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
For vector length 8 it is {3 4 5 6 7 8 9 10}. */
for (i = 0; i < nelt; i++)
sel[i] = (nelt / 3) + (nelt % 3) / 2 + i;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5699,7 +5699,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain,
For vector length 8 it is {5 6 7 8 9 10 11 12}. */
for (i = 0; i < nelt; i++)
sel[i] = 2 * (nelt / 3) + (nelt % 3) / 2 + i;
- if (!can_vec_perm_p (TYPE_MODE (vectype), false, &sel))
+ if (!can_vec_perm_const_p (TYPE_MODE (vectype), sel))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,