From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1923) id 86C503858C60; Wed, 17 Jan 2024 19:14:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86C503858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705518840; bh=cqQE1/D0fWYkeY4s4OtBRMJQzVqQ3tWD3kPbSr1GUfY=; h=From:To:Subject:Date:From; b=Gyg869nIIzhzYTBhNm2xr39FkSpHkPzrbmtpfvvtsF2O1iGdxs+K8QNyPnNTDaJMN Q5OLczmbqyw7PDL6BeCh8m6ivIaqehqkU9SchH2KLF9SQOVQ8Hk5/ulpYFR+GZZ0iR Tb+niBfX+9fLDNgYPzLNa68Ddiqb9FBkiNmLA3lk= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Philipp Tomsich To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/vrull/heads/slp-improvements)] match.pd: Look through view_convert when folding vec_perms X-Act-Checkin: gcc X-Git-Author: Manolis Tsamis X-Git-Refname: refs/vendors/vrull/heads/slp-improvements X-Git-Oldrev: 88e655d3c454acca54c139df1a52a0eedab78640 X-Git-Newrev: 89a6e3d55d5b4422f6be334cfd8ea4127917068f Message-Id: <20240117191400.86C503858C60@sourceware.org> Date: Wed, 17 Jan 2024 19:14:00 +0000 (GMT) List-Id: https://gcc.gnu.org/g:89a6e3d55d5b4422f6be334cfd8ea4127917068f commit 89a6e3d55d5b4422f6be334cfd8ea4127917068f Author: Manolis Tsamis 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 ; */ (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 ;