public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Philipp Tomsich <ptomsich@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/vrull/heads/slp-improvements)] match.pd: Look through view_convert when folding vec_perms
Date: Wed, 17 Jan 2024 19:14:00 +0000 (GMT)	[thread overview]
Message-ID: <20240117191400.86C503858C60@sourceware.org> (raw)

https://gcc.gnu.org/g:89a6e3d55d5b4422f6be334cfd8ea4127917068f

commit 89a6e3d55d5b4422f6be334cfd8ea4127917068f
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.
    
    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 7b4b15acc41..59a664293ea 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -9929,7 +9929,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
    {
@@ -9941,7 +9941,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);
@@ -9966,7 +9967,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>;

             reply	other threads:[~2024-01-17 19:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 19:14 Philipp Tomsich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-02-27 13:37 Philipp Tomsich
2024-01-23 20:57 Philipp Tomsich
2024-01-23 23:49 ` Andrew Pinski
2023-11-28 13:35 Philipp Tomsich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240117191400.86C503858C60@sourceware.org \
    --to=ptomsich@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).