From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1923) id 481E33875455; Tue, 28 Nov 2023 13:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 481E33875455 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701178505; bh=Mg8BcvwLRnpMVGnZfjnsRiGrVadqVGM2CapD1V2ZK6M=; h=From:To:Subject:Date:From; b=jFNHR5U70XYkV/Q4kaQHtYm9wxzijPDmgqqcy4ENKHuhHbNipvEmkka2HKif+hBcY HUVv96tmaPH0NamF8rxbHRxYzz1DNkXCPz/gm6Eh5LGLxx+V/fRLQA0aI+i+za6Cfc exJxlJbrsbfqRmGdoCd7SOIWZ7bB96bdmAIQPlcw= 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: c8eb943687266e13cdd95286518cdeed2508237a X-Git-Newrev: e9bbe3d12c929449053eadb485bcfa5586d311e0 Message-Id: <20231128133505.481E33875455@sourceware.org> Date: Tue, 28 Nov 2023 13:35:05 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e9bbe3d12c929449053eadb485bcfa5586d311e0 commit e9bbe3d12c929449053eadb485bcfa5586d311e0 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 b30de36e836..c41e1f8796b 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -9818,7 +9818,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 { @@ -9830,7 +9830,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); @@ -9855,7 +9856,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 ;