From patchwork Thu Aug 25 13:05:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp230713wro; Thu, 25 Aug 2022 06:07:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR50AD+1Tpm0KmL0jCUDTiX6qr2wzi9crqi7UoXG/cAMAJvpv3T66DfYMz+A6tevo5O4WcPf X-Received: by 2002:a05:6402:1f8c:b0:43e:8fab:76c with SMTP id c12-20020a0564021f8c00b0043e8fab076cmr3176000edc.126.1661432868328; Thu, 25 Aug 2022 06:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661432868; cv=none; d=google.com; s=arc-20160816; b=S03ACrjpkazf/aLp7zWnfQyw9FFulOK3vbgBvsLNcBqR01lu84LzJueLJVIquVXazF TORkBoACrHhlDB2tQ7SjItCTjjDLlzoFlStvDvEYhFAiPA69UM3Z/0L3U/Lsz5Hnhitw 5d4NtD2XeL8Nvm9aoAPmFncfA3TdTDEGxW3UkBJ5dV8tT/aIk7lyNIzv59pk0rti0OL8 xSLQ/1K6NzjRxmKNNJKEjVY/eAROwuBhHc6KmkL/FaXWut/6lujyBazM5MWfa9FlJawz kfuMvCqfE0E5eOW4XCrnGAR4BZKIHAulO97wKFYWUPuR0UdYSP8tDMZZ/oTT58OkOraW AEkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:in-reply-to:date:references:subject :mail-followup-to:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=k9wComfpFpVT3leG+4Q8zsmp1j/JSOMOJ6K9uRfdxbY=; b=egKoFKIMmkHNAdhYkZ9sFDQ9ioYioQ1po1lsZkA44QNUijA3PxvPDMmXPI96PDZJPP edJHoWUdsRFaE9AyrTAqtcC2NbVG+lXawauOzxKCZe+r/SddKij+mlSH4aRl7xp7cGq1 lKE8GtkYP+z7FR0QI2mS9UP4Sw4goNI5BylB5zsh2/BPOFEzzxCmF5LPJC4sHPg4Ovhe 8C7MGPrTI2aHfB04fi9qOBvc2FBDePKjee8+E/ELjBx9Go8SfzSh4Qh+mcT4fdTEpH0E 5F2KZWqRrs+bUwXIxsfLo9FTAG81uSpgIWXDNVC1DadFOrv1qEptnwCXrhiVT7WbolVV swJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EoJUjkAV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ht8-20020a170907608800b007309eb6dcbfsi4160479ejc.372.2022.08.25.06.07.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 06:07:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EoJUjkAV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABED938515D8 for ; Thu, 25 Aug 2022 13:07:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABED938515D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661432821; bh=k9wComfpFpVT3leG+4Q8zsmp1j/JSOMOJ6K9uRfdxbY=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=EoJUjkAVILrQNErye9CeEPTJ/KFnxf0efu5vz3xALWZlkMxHx+DeKrT+MRFo/kP+L 6ReefCq8AIGnxSHfJtVXcFPzBBbkFN+/CafeWQ7cVgCpmJrbjvJrIKuoI/es/DOxL2 +ow1wcKOZ7a7JFo6tFZQN8yu6oihQuX6xTHyh0BU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id EB8F53851C35 for ; Thu, 25 Aug 2022 13:05:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EB8F53851C35 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 29229D6E for ; Thu, 25 Aug 2022 06:05:40 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 39CCD3F71A for ; Thu, 25 Aug 2022 06:05:35 -0700 (PDT) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH 2/6] Split code out of vect_transform_slp_perm_load References: Date: Thu, 25 Aug 2022 14:05:33 +0100 In-Reply-To: (Richard Sandiford's message of "Thu, 25 Aug 2022 14:04:47 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-50.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742138630891196223?= X-GMAIL-MSGID: =?utf-8?q?1742138630891196223?= Similarly to the previous vectorizable_slp_permutation patch, this one splits out the main part of vect_transform_slp_perm_load so that a later patch can test a permutation without constructing a node for it. Also fixes a lingering use of STMT_VINFO_VECTYPE. gcc/ * tree-vect-slp.cc (vect_transform_slp_perm_load_1): Split out from... (vect_transform_slp_perm_load): ...here. Use SLP_TREE_VECTYPE instead of STMT_VINFO_VECTYPE. --- gcc/tree-vect-slp.cc | 54 ++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 13c242e5012..64b3379b530 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -6631,23 +6631,23 @@ vect_get_slp_defs (vec_info *, } } -/* Generate vector permute statements from a list of loads in DR_CHAIN. - If ANALYZE_ONLY is TRUE, only check that it is possible to create valid - permute statements for the SLP node NODE. Store the number of vector - permute instructions in *N_PERMS and the number of vector load - instructions in *N_LOADS. If DCE_CHAIN is true, remove all definitions - that were not needed. */ +/* A subroutine of vect_transform_slp_perm_load with two extra arguments: + - PERM gives the permutation that the caller wants to use for NODE, + which might be different from SLP_LOAD_PERMUTATION. + - DUMP_P controls whether the function dumps information. */ -bool -vect_transform_slp_perm_load (vec_info *vinfo, - slp_tree node, const vec &dr_chain, - gimple_stmt_iterator *gsi, poly_uint64 vf, - bool analyze_only, unsigned *n_perms, - unsigned int *n_loads, bool dce_chain) +static bool +vect_transform_slp_perm_load_1 (vec_info *vinfo, slp_tree node, + load_permutation_t &perm, + const vec &dr_chain, + gimple_stmt_iterator *gsi, poly_uint64 vf, + bool analyze_only, bool dump_p, + unsigned *n_perms, unsigned int *n_loads, + bool dce_chain) { stmt_vec_info stmt_info = SLP_TREE_SCALAR_STMTS (node)[0]; int vec_index = 0; - tree vectype = STMT_VINFO_VECTYPE (stmt_info); + tree vectype = SLP_TREE_VECTYPE (node); unsigned int group_size = SLP_TREE_SCALAR_STMTS (node).length (); unsigned int mask_element; machine_mode mode; @@ -6732,8 +6732,7 @@ vect_transform_slp_perm_load (vec_info *vinfo, { unsigned int iter_num = j / group_size; unsigned int stmt_num = j % group_size; - unsigned int i = (iter_num * DR_GROUP_SIZE (stmt_info) - + SLP_TREE_LOAD_PERMUTATION (node)[stmt_num]); + unsigned int i = (iter_num * DR_GROUP_SIZE (stmt_info) + perm[stmt_num]); bitmap_set_bit (used_in_lanes, i); if (repeating_p) { @@ -6759,7 +6758,7 @@ vect_transform_slp_perm_load (vec_info *vinfo, } else { - if (dump_enabled_p ()) + if (dump_p) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "permutation requires at " "least three vectors %G", @@ -6780,7 +6779,7 @@ vect_transform_slp_perm_load (vec_info *vinfo, indices.new_vector (mask, second_vec_index == -1 ? 1 : 2, nunits); if (!can_vec_perm_const_p (mode, mode, indices)) { - if (dump_enabled_p ()) + if (dump_p) { dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -6896,6 +6895,27 @@ vect_transform_slp_perm_load (vec_info *vinfo, return true; } +/* Generate vector permute statements from a list of loads in DR_CHAIN. + If ANALYZE_ONLY is TRUE, only check that it is possible to create valid + permute statements for the SLP node NODE. Store the number of vector + permute instructions in *N_PERMS and the number of vector load + instructions in *N_LOADS. If DCE_CHAIN is true, remove all definitions + that were not needed. */ + +bool +vect_transform_slp_perm_load (vec_info *vinfo, + slp_tree node, const vec &dr_chain, + gimple_stmt_iterator *gsi, poly_uint64 vf, + bool analyze_only, unsigned *n_perms, + unsigned int *n_loads, bool dce_chain) +{ + return vect_transform_slp_perm_load_1 (vinfo, node, + SLP_TREE_LOAD_PERMUTATION (node), + dr_chain, gsi, vf, analyze_only, + dump_enabled_p (), n_perms, n_loads, + dce_chain); +} + /* Produce the next vector result for SLP permutation NODE by adding a vector statement at GSI. If MASK_VEC is nonnull, add: