[gcc(refs/vendors/vrull/heads/slp-improvements)] match.pd: Look through view_convert when folding vec_perms

Andrew Pinski pinskia@gmail.com
Tue Jan 23 23:49:05 GMT 2024


On Tue, Jan 23, 2024 at 12:57 PM Philipp Tomsich via Gcc-cvs
<gcc-cvs@gcc.gnu.org> wrote:
>
> https://gcc.gnu.org/g:b896c82f141211437b5b5b83a3537d6bd2d243dc
>
> commit b896c82f141211437b5b5b83a3537d6bd2d243dc
> Author: Manolis Tsamis <manolis.tsamis@vrull.eu>
> Date:   Wed Nov 1 12:27:28 2023 +0100
>
>     match.pd: Look through view_convert when folding vec_perms
>
>     The match.pd patterns to merge two vector permutes into one fail to
>     match when a (potentially no-op) view convert expressions is
>     separating the two permutes.  This is observable in the SLP tree for
>     the first loop of x264's satd and inhibits optimization.
>
>     This change adds a check whether a view_convert will be a no-op
>     (comparing the element precision) and rewrites the permute sequence
>     for those cases.

My suggestion is just use nop_convert instead and which does the
correct thing for a vector conversion between signed and unsigned
types.
Or  do you need one between integer and floating point types too?

Thanks,
Andrew

>
>     Ref #343
>
> Diff:
> ---
>  gcc/match.pd | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/match.pd b/gcc/match.pd
> index e42ecaf9ec7..be623d9773c 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -9965,7 +9965,7 @@ and,
>       d = VEC_PERM_EXPR <a, b, NEW_VCST>;  */
>
>  (simplify
> - (vec_perm (vec_perm@0 @1 @2 VECTOR_CST@3) @0 VECTOR_CST@4)
> + (vec_perm (view_convert?@0 (vec_perm @1 @2 VECTOR_CST@3)) @0 VECTOR_CST@4)
>   (if (TYPE_VECTOR_SUBPARTS (type).is_constant ())
>    (with
>     {
> @@ -9977,7 +9977,8 @@ and,
>       vec_perm_builder builder2 (nelts, nelts, 1);
>     }
>     (if (tree_to_vec_perm_builder (&builder0, @3)
> -       && tree_to_vec_perm_builder (&builder1, @4))
> +       && tree_to_vec_perm_builder (&builder1, @4)
> +       && element_precision (type) == element_precision (TREE_TYPE (@0)))
>      (with
>       {
>         vec_perm_indices sel0 (builder0, 2, nelts);
> @@ -10002,7 +10003,7 @@ and,
>          op0 = vec_perm_indices_to_tree (TREE_TYPE (@4), sel2);
>       }
>       (if (op0)
> -      (vec_perm @1 @2 { op0; })))))))
> +      (view_convert (vec_perm @1 @2 { op0; }))))))))
>
>  /* Merge
>       c = VEC_PERM_EXPR <a, b, VCST0>;


More information about the Gcc-cvs mailing list