[3/4] match.pd: Teach forwprop to handle VLA VEC_PERM_EXPRs with VLS CONSTRUCTORs as arguments
Commit Message
Hi,
This patch is part of the WIP patch that follows in this series. It's
goal is to teach forwprop to handle VLA VEC_PERM_EXPRs with VLS
CONSTRUCTORs as arguments as preparation for the 'VLA constructor' hook
approach.
Kind Regards,
Andre
Comments
On Fri, 5 Aug 2022 at 18:26, Andre Vieira (lists)
<andre.simoesdiasvieira@arm.com> wrote:
>
> Hi,
>
> This patch is part of the WIP patch that follows in this series. It's
> goal is to teach forwprop to handle VLA VEC_PERM_EXPRs with VLS
> CONSTRUCTORs as arguments as preparation for the 'VLA constructor' hook
> approach.
/* Shuffle of a constructor. */
bool ret = false;
- tree res_type = TREE_TYPE (arg0);
+ tree res_type = TREE_TYPE (gimple_get_lhs (stmt));
tree opt = fold_ternary (VEC_PERM_EXPR, res_type, arg0, arg1, op2);
if (!opt
|| (TREE_CODE (opt) != CONSTRUCTOR && TREE_CODE (opt) != VECTOR_CST))
This has to be TREE_TYPE (arg0). I had changed it to TREE_TYPE
(gimple_assign_lhs (stmt)) and it caused
several ICE's on ppc64le (PR106360)
For details, see:
https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598611.html
I currently have a patch in review that extends fold_vec_perm to
handle differing vector lengths:
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599126.html
Thanks,
Prathamesh
>
> Kind Regards,
> Andre
@@ -7852,14 +7852,24 @@ and,
if (!tree_to_vec_perm_builder (&builder, op2))
return NULL_TREE;
+ /* FIXME: disable folding of a VEC_PERM_EXPR with a VLA mask and VLS
+ CONSTRUCTORS, since that would yield a VLA CONSTRUCTOR which we
+ currently do not support. */
+ if (!TYPE_VECTOR_SUBPARTS (type).is_constant ()
+ && (TYPE_VECTOR_SUBPARTS (TREE_TYPE (op0)).is_constant ()
+ || TYPE_VECTOR_SUBPARTS (TREE_TYPE (op1)).is_constant ()))
+ return NULL_TREE;
+
/* Create a vec_perm_indices for the integer vector. */
poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (type);
bool single_arg = (op0 == op1);
vec_perm_indices sel (builder, single_arg ? 1 : 2, nelts);
}
- (if (sel.series_p (0, 1, 0, 1))
+ (if (sel.series_p (0, 1, 0, 1)
+ && useless_type_conversion_p (type, TREE_TYPE (op0)))
{ op0; }
- (if (sel.series_p (0, 1, nelts, 1))
+ (if (sel.series_p (0, 1, nelts, 1)
+ && useless_type_conversion_p (type, TREE_TYPE (op1)))
{ op1; }
(with
{
@@ -2661,7 +2661,7 @@ simplify_permutation (gimple_stmt_iterator *gsi)
/* Shuffle of a constructor. */
bool ret = false;
- tree res_type = TREE_TYPE (arg0);
+ tree res_type = TREE_TYPE (gimple_get_lhs (stmt));
tree opt = fold_ternary (VEC_PERM_EXPR, res_type, arg0, arg1, op2);
if (!opt
|| (TREE_CODE (opt) != CONSTRUCTOR && TREE_CODE (opt) != VECTOR_CST))