The following fixes an oversight in the guards covering VEC_PERM_EXPR
folding. When the existing permutes are not handled by the CPU then
we know we have not yet applied vector lowering. But only when we
also consider the variable permute fallback.
This doesn't fix the PR because !can_vec_perm_p does not tell us
the truth since both vector lowering and RTL expansion will eventually
consider vec_shl and vec_shr. I'd like to retire those fallbacks
of vec_perm_const, we instead should require for targets to
syntesize a whole vector shift themselves.
The alternative would be to (optionally?) pass in op0 and op1
to can_vec_perm_const_p.
Thoughts?
Thanks,
Richard.
PR middle-end/125875
* match.pd: When checking for !can_vec_perm_const_p also
allow variable permutes.
---
gcc/match.pd | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/gcc/match.pd b/gcc/match.pd
index 475939a0b63..d8073a90956 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -11688,9 +11688,9 @@ and,
number of VEC_PERM_EXPRs that can't be handled. */
if (can_vec_perm_const_p (result_mode, op_mode, sel2, false)
|| (single_use (@0)
- ? (!can_vec_perm_const_p (result_mode, op_mode, sel0, false)
- || !can_vec_perm_const_p (result_mode, op_mode, sel1, false))
- : !can_vec_perm_const_p (result_mode, op_mode, sel1, false)))
+ ? (!can_vec_perm_const_p (result_mode, op_mode, sel0, true)
+ || !can_vec_perm_const_p (result_mode, op_mode, sel1, true))
+ : !can_vec_perm_const_p (result_mode, op_mode, sel1, true)))
op0 = vec_perm_indices_to_tree (TREE_TYPE (@5), sel2);
}
(if (op0)
@@ -11755,9 +11755,9 @@ and,
number of VEC_PERM_EXPRs that can't be handled. */
if (can_vec_perm_const_p (result_mode, op_mode, sel2, false)
|| (single_use (@0)
- ? (!can_vec_perm_const_p (result_mode, op_mode, sel0, false)
- || !can_vec_perm_const_p (result_mode, op_mode, sel1,
false))
- : !can_vec_perm_const_p (result_mode, op_mode, sel1, false)))
+ ? (!can_vec_perm_const_p (result_mode, op_mode, sel0, true)
+ || !can_vec_perm_const_p (result_mode, op_mode, sel1, true))
+ : !can_vec_perm_const_p (result_mode, op_mode, sel1, true)))
op0 = vec_perm_indices_to_tree (TREE_TYPE (@4), sel2);
}
(if (op0)
@@ -11819,9 +11819,9 @@ and,
number of VEC_PERM_EXPRs that can't be handled. */
if (can_vec_perm_const_p (result_mode, op_mode, sel2, false)
|| (single_use (@0)
- ? (!can_vec_perm_const_p (result_mode, op_mode, sel0, false)
- || !can_vec_perm_const_p (result_mode, op_mode, sel1,
false))
- : !can_vec_perm_const_p (result_mode, op_mode, sel1, false)))
+ ? (!can_vec_perm_const_p (result_mode, op_mode, sel0, true)
+ || !can_vec_perm_const_p (result_mode, op_mode, sel1, true))
+ : !can_vec_perm_const_p (result_mode, op_mode, sel1, true)))
op0 = vec_perm_indices_to_tree (TREE_TYPE (@4), sel2);
}
(if (op0)
--
2.51.0