From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1923) id 24C46385800E; Tue, 23 Jan 2024 20:57:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24C46385800E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706043436; bh=JcoycJgS3Pzb0ooAkAw+0Fg4Yxqm0q71C/CaA5z1Sa0=; h=From:To:Subject:Date:From; b=P0aPmQDflculNI3f1nubG+f7KSX00vs1l1EO2D1lTJYwrXfTbwAu+v61GL/pa8GUI FeU8msgBlCYa5X0dcVKPI4arjwt0G9gJW8jdWjCwocSpV6yoUx+C6EYIDtJ1ncgRo7 rUvb1SW45Q6Ij2yNczW0TBizXIxLaMb2of0u3pNc= 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: 6fe9f962a2ba10a11e31f73867d6608d0736ff55 X-Git-Newrev: b896c82f141211437b5b5b83a3537d6bd2d243dc Message-Id: <20240123205716.24C46385800E@sourceware.org> Date: Tue, 23 Jan 2024 20:57:16 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b896c82f141211437b5b5b83a3537d6bd2d243dc commit b896c82f141211437b5b5b83a3537d6bd2d243dc 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 e42ecaf9ec7..be623d9773c 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -9965,7 +9965,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 { @@ -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 ;