From patchwork Tue Aug 22 08:45:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 136472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3490091vqi; Tue, 22 Aug 2023 01:46:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbcYuwmGyctdu3WBAUFS/CwMjt8T5PvP1wXUJC4m7PxDrHwzurMO9dVbJvlGdj/kLqRelt X-Received: by 2002:a05:6512:1115:b0:4ff:8f76:677f with SMTP id l21-20020a056512111500b004ff8f76677fmr7049104lfg.67.1692693989820; Tue, 22 Aug 2023 01:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692693989; cv=none; d=google.com; s=arc-20160816; b=dkOoQvX66pUr+e0gnNnoPnzYCQhK8CSfrrC2HlinPnXHWCWfUYXp3YRdEzcG0r98zM TUwCbw0++4vbjJDQxo6R4n30f59HUvFmpSJlDQ23kSDA5HBJmV9DWBuj43E4RJeFo6Qq f2Gx4dOL4K8EqULNeJiqnSG2e8TktjDDBYHAG9xYkU3UMsR+JBnBGJgwLi4Ja96o8lgd +YK7Fq9M+b9Als8ctYo4wtdjF3UiIOn1/kMNGPIZBu5/+sE8R+wFXALO9SL2nlRA/u+7 LoAEv6iSxmW+IKBCHnC+PeHK2SfEP33YaqM46AlkvVz4XhORV42gP08uk7YQ8U4KvF+K rUiA== 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 :content-transfer-encoding:cc:to:subject:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=E6s5z8MRtf2z2yzWsOonQLiMAxeHj6QDFUR+g51IPaA=; fh=Gv6PAYpoZePgnyLjqy3TiguihZUSZfKa6GhguGNpSZ8=; b=vowWHl2a5nUD3zWi1e6AkHW+HppN1QgMlPq537tC5ZavW0BCk8rMdGIStGcJnXsuZV sfWAD5i8EDIEGC2xeKfiQq5nplbAP9mkLjmPPWnyqtkuE7BQt9DNtnX+kpXqJqDbSRNi cpMNsvs4J7p4RM5liBLvUI1xKgYHV9mKauofDXf72rWRVgxKQpTZxaXi0X0rNMCphaTE xPifiLrFYahGf/fPjI6lW6GB+dNUW7FfdpQLE87dFxz7213MX3iYVvDr7Iw1CEJLScy7 cxOo/QhXxr9iqrXl+Bxx8jZQhx9bTRRnN52edV8sseOmlSjshVz7dm2ItZM7CE9i7kjE smbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=H18fDI1W; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d15-20020a50fb0f000000b00523d8bee81dsi7240878edq.611.2023.08.22.01.46.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 01:46:29 -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=H18fDI1W; 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 7463D3857033 for ; Tue, 22 Aug 2023 08:46:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7463D3857033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692693988; bh=E6s5z8MRtf2z2yzWsOonQLiMAxeHj6QDFUR+g51IPaA=; h=Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=H18fDI1W0ZCnZJqIQeQCLnVGD9AMUlk4mRpI+CkuJu/RsDyYV8th7F8BDLlbrhBjX SFlYOzH/yldep580TveG83nhLrnusZDj9su9fVShjy9WfkgY30Yi7WFU9ninDugxhj cLkSekszCrZiKYzF9ZiLieIgtd/rdzyVjvOAslDQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 581E33856943 for ; Tue, 22 Aug 2023 08:45:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 581E33856943 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37M89i2h027905; Tue, 22 Aug 2023 08:45:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sms22s90w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Aug 2023 08:45:35 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 37M8CC1t002816; Tue, 22 Aug 2023 08:45:35 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sms22s90g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Aug 2023 08:45:35 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37M6pHYL007167; Tue, 22 Aug 2023 08:45:33 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3smak7dx4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Aug 2023 08:45:33 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37M8jVFr5636722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Aug 2023 08:45:31 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AACFE20040; Tue, 22 Aug 2023 08:45:31 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA6602004B; Tue, 22 Aug 2023 08:45:29 +0000 (GMT) Received: from [9.197.233.216] (unknown [9.197.233.216]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 22 Aug 2023 08:45:29 +0000 (GMT) Message-ID: <8c6c6b96-0b97-4eed-5b88-bda2b3dcc902@linux.ibm.com> Date: Tue, 22 Aug 2023 16:45:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US Subject: [PATCH 1/3] vect: Remove some manual release in vectorizable_store To: GCC Patches Cc: Richard Biener , Richard Sandiford , Segher Boessenkool , Peter Bergner X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ATL1ijLBFj12BlHUQ5TVOfOIYCH3DrIm X-Proofpoint-ORIG-GUID: zbDWvt1AsKQYokO9BVVePPH9K_yAh8AD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-22_07,2023-08-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 phishscore=0 priorityscore=1501 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308220065 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774918292689486792 X-GMAIL-MSGID: 1774918292689486792 Hi, To avoid some duplicates in some follow-up patches on function vectorizable_store, this patch is to adjust some existing vec with auto_vec and remove some manual release invocation. Also refactor a bit and remove some useless codes. Bootstrapped and regtested on x86_64-redhat-linux, aarch64-linux-gnu and powerpc64{,le}-linux-gnu. Is it ok for trunk? BR, Kewen ----- gcc/ChangeLog: * tree-vect-stmts.cc (vectorizable_store): Remove vec oprnds, adjust vec result_chain, vec_oprnd with auto_vec, and adjust gvec_oprnds with auto_delete_vec. --- gcc/tree-vect-stmts.cc | 64 +++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 41 deletions(-) -- 2.31.1 diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 1580a396301..fcaa4127e52 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -8200,9 +8200,6 @@ vectorizable_store (vec_info *vinfo, stmt_vec_info first_stmt_info; bool grouped_store; unsigned int group_size, i; - vec oprnds = vNULL; - vec result_chain = vNULL; - vec vec_oprnds = vNULL; bool slp = (slp_node != NULL); unsigned int vec_num; bb_vec_info bb_vinfo = dyn_cast (vinfo); @@ -8601,6 +8598,7 @@ vectorizable_store (vec_info *vinfo, alias_off = build_int_cst (ref_type, 0); stmt_vec_info next_stmt_info = first_stmt_info; + auto_vec vec_oprnds (ncopies); for (g = 0; g < group_size; g++) { running_off = offvar; @@ -8682,7 +8680,7 @@ vectorizable_store (vec_info *vinfo, } } next_stmt_info = DR_GROUP_NEXT_ELEMENT (next_stmt_info); - vec_oprnds.release (); + vec_oprnds.truncate(0); if (slp) break; } @@ -8690,9 +8688,6 @@ vectorizable_store (vec_info *vinfo, return true; } - auto_vec dr_chain (group_size); - oprnds.create (group_size); - gcc_assert (alignment_support_scheme); vec_loop_masks *loop_masks = (loop_vinfo && LOOP_VINFO_FULLY_MASKED_P (loop_vinfo) @@ -8783,11 +8778,15 @@ vectorizable_store (vec_info *vinfo, STMT_VINFO_RELATED_STMT for the next copies. */ + auto_vec dr_chain (group_size); + auto_vec result_chain (group_size); auto_vec vec_masks; tree vec_mask = NULL; auto_vec vec_offsets; - auto_vec > gvec_oprnds; - gvec_oprnds.safe_grow_cleared (group_size, true); + auto_delete_vec> gvec_oprnds (group_size); + for (i = 0; i < group_size; i++) + gvec_oprnds.quick_push (new auto_vec (ncopies)); + auto_vec vec_oprnds; for (j = 0; j < ncopies; j++) { gimple *new_stmt; @@ -8803,11 +8802,11 @@ vectorizable_store (vec_info *vinfo, else { /* For interleaved stores we collect vectorized defs for all the - stores in the group in DR_CHAIN and OPRNDS. DR_CHAIN is then - used as an input to vect_permute_store_chain(). + stores in the group in DR_CHAIN. DR_CHAIN is then used as an + input to vect_permute_store_chain(). If the store is not grouped, DR_GROUP_SIZE is 1, and DR_CHAIN - and OPRNDS are of size 1. */ + is of size 1. */ stmt_vec_info next_stmt_info = first_stmt_info; for (i = 0; i < group_size; i++) { @@ -8817,11 +8816,10 @@ vectorizable_store (vec_info *vinfo, that there is no interleaving, DR_GROUP_SIZE is 1, and only one iteration of the loop will be executed. */ op = vect_get_store_rhs (next_stmt_info); - vect_get_vec_defs_for_operand (vinfo, next_stmt_info, - ncopies, op, &gvec_oprnds[i]); - vec_oprnd = gvec_oprnds[i][0]; - dr_chain.quick_push (gvec_oprnds[i][0]); - oprnds.quick_push (gvec_oprnds[i][0]); + vect_get_vec_defs_for_operand (vinfo, next_stmt_info, ncopies, + op, gvec_oprnds[i]); + vec_oprnd = (*gvec_oprnds[i])[0]; + dr_chain.quick_push (vec_oprnd); next_stmt_info = DR_GROUP_NEXT_ELEMENT (next_stmt_info); } if (mask) @@ -8863,16 +8861,13 @@ vectorizable_store (vec_info *vinfo, else { gcc_assert (!LOOP_VINFO_USING_SELECT_VL_P (loop_vinfo)); - /* For interleaved stores we created vectorized defs for all the - defs stored in OPRNDS in the previous iteration (previous copy). - DR_CHAIN is then used as an input to vect_permute_store_chain(). - If the store is not grouped, DR_GROUP_SIZE is 1, and DR_CHAIN and - OPRNDS are of size 1. */ + /* DR_CHAIN is then used as an input to vect_permute_store_chain(). + If the store is not grouped, DR_GROUP_SIZE is 1, and DR_CHAIN is + of size 1. */ for (i = 0; i < group_size; i++) { - vec_oprnd = gvec_oprnds[i][j]; - dr_chain[i] = gvec_oprnds[i][j]; - oprnds[i] = gvec_oprnds[i][j]; + vec_oprnd = (*gvec_oprnds[i])[j]; + dr_chain[i] = vec_oprnd; } if (mask) vec_mask = vec_masks[j]; @@ -8975,13 +8970,9 @@ vectorizable_store (vec_info *vinfo, { new_stmt = NULL; if (grouped_store) - { - if (j == 0) - result_chain.create (group_size); - /* Permute. */ - vect_permute_store_chain (vinfo, dr_chain, group_size, stmt_info, - gsi, &result_chain); - } + /* Permute. */ + vect_permute_store_chain (vinfo, dr_chain, group_size, stmt_info, + gsi, &result_chain); stmt_vec_info next_stmt_info = first_stmt_info; for (i = 0; i < vec_num; i++) @@ -9278,15 +9269,6 @@ vectorizable_store (vec_info *vinfo, } } - for (i = 0; i < group_size; ++i) - { - vec oprndsi = gvec_oprnds[i]; - oprndsi.release (); - } - oprnds.release (); - result_chain.release (); - vec_oprnds.release (); - return true; }