From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id D88F13858D28 for ; Tue, 22 Aug 2023 12:33:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D88F13858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2b72161c6e9so62660951fa.0 for ; Tue, 22 Aug 2023 05:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692707632; x=1693312432; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QAbs0lQFmJx4eCXcFjtFg5x5TfSEXXacivI1uREJ9Pk=; b=gXoR4NS1k6CNEG09hFOULBZL4CveFKr7gOVKlLF7fwT+l3+JRCGZO5nIKhZAHomm7/ fq5kRgdZQM9Tyt6iO3trjnN/3YrxrWwrHE9SRCXgxXu/AeGdDv4/woglMTLZ4LEX44Rd KXPB+6IaRSsphB4fuOfrH/mqzmnU8n+yKbFBHhqUvGaRuZQ1iyWgC89oMH4McN8GolPj WlXwQHi0HqWyeY2nSUN6q92GH3XdeWGgiyuXBxqC3ru0+yY5095vEde2ZEIGb+EO9YYd m7FtVfnHhXe3CrsWcyvKsOYLIblvabzcu0G+4y1gssOysqQ9FRB6nEincjyiCnc63ytV QGNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692707632; x=1693312432; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QAbs0lQFmJx4eCXcFjtFg5x5TfSEXXacivI1uREJ9Pk=; b=SZv0B2EHiZAQZKR+CTfFKkgpIMZYY9sackFA62/4+Z8FRVumxgkFcTRrZHESA4hRrr 6YS+NPNGRyiKxtf+KhQVxIqcj89bCwhqftfsAi7yEDTOonBqOlyToTuVvZ1ZiDxSo4MP vGcj+c6r4fMKRK6C2NaCl4Bq5rDNhMAb3D9tBXRXKoO51GgQZFEhAnGaipX4HuXbYZlQ u/DSRMs7WaM83Hmq8DB6xs+EuIgAU3j3Rw+Ugu84G4rb0Xw267tQuX5Ow0EvCQXskdMn DCYWtZzOKp1BGpHw8rajOMOHTehLnY5WypdzaOx7w3pVKJbvBpp/QaKp1YqWBJYSxNea rmPg== X-Gm-Message-State: AOJu0YwAY6Yp8sH28PUwVR9a7XBMxuPjVPqCJ4C7jmuZIG3whSy1Vyqu mxJJxmYRCmg/ToVLQ4ioW9Mq+xlH/Fxiq1lkmRM= X-Google-Smtp-Source: AGHT+IHUmQVs0ZwhPU0SineOQGypMuYQnUkiwWofIKiKZ1YcurE7V0Ki21DnTFzt7VAtNUW3I1kfXWGhvJ08AX3Sfmc= X-Received: by 2002:a2e:b054:0:b0:2bc:c433:fbac with SMTP id d20-20020a2eb054000000b002bcc433fbacmr1484945ljl.26.1692707632075; Tue, 22 Aug 2023 05:33:52 -0700 (PDT) MIME-Version: 1.0 References: <8c6c6b96-0b97-4eed-5b88-bda2b3dcc902@linux.ibm.com> In-Reply-To: <8c6c6b96-0b97-4eed-5b88-bda2b3dcc902@linux.ibm.com> From: Richard Biener Date: Tue, 22 Aug 2023 14:32:22 +0200 Message-ID: Subject: Re: [PATCH 1/3] vect: Remove some manual release in vectorizable_store To: "Kewen.Lin" Cc: GCC Patches , Richard Sandiford , Segher Boessenkool , Peter Bergner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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 List-Id: On Tue, Aug 22, 2023 at 10:45=E2=80=AFAM Kewen.Lin wr= ote: > > 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? OK. Thanks, Richard. > 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(-) > > 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 =3D vNULL; > - vec result_chain =3D vNULL; > - vec vec_oprnds =3D vNULL; > bool slp =3D (slp_node !=3D NULL); > unsigned int vec_num; > bb_vec_info bb_vinfo =3D dyn_cast (vinfo); > @@ -8601,6 +8598,7 @@ vectorizable_store (vec_info *vinfo, > > alias_off =3D build_int_cst (ref_type, 0); > stmt_vec_info next_stmt_info =3D first_stmt_info; > + auto_vec vec_oprnds (ncopies); > for (g =3D 0; g < group_size; g++) > { > running_off =3D offvar; > @@ -8682,7 +8680,7 @@ vectorizable_store (vec_info *vinfo, > } > } > next_stmt_info =3D 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 > =3D (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 =3D 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 =3D 0; i < group_size; i++) > + gvec_oprnds.quick_push (new auto_vec (ncopies)); > + auto_vec vec_oprnds; > for (j =3D 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 al= l 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 a= s 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 =3D first_stmt_info; > for (i =3D 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 =3D vect_get_store_rhs (next_stmt_info); > - vect_get_vec_defs_for_operand (vinfo, next_stmt_info, > - ncopies, op, &gvec_oprnd= s[i]); > - vec_oprnd =3D 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, n= copies, > + op, gvec_oprnds[i]); > + vec_oprnd =3D (*gvec_oprnds[i])[0]; > + dr_chain.quick_push (vec_oprnd); > next_stmt_info =3D DR_GROUP_NEXT_ELEMENT (next_stmt_inf= o); > } > 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 th= e > - defs stored in OPRNDS in the previous iteration (previous co= py). > - DR_CHAIN is then used as an input to vect_permute_store_chai= n(). > - If the store is not grouped, DR_GROUP_SIZE is 1, and DR_CHAI= N and > - OPRNDS are of size 1. */ > + /* DR_CHAIN is then used as an input to vect_permute_store_chai= n(). > + If the store is not grouped, DR_GROUP_SIZE is 1, and DR_CHAI= N is > + of size 1. */ > for (i =3D 0; i < group_size; i++) > { > - vec_oprnd =3D gvec_oprnds[i][j]; > - dr_chain[i] =3D gvec_oprnds[i][j]; > - oprnds[i] =3D gvec_oprnds[i][j]; > + vec_oprnd =3D (*gvec_oprnds[i])[j]; > + dr_chain[i] =3D vec_oprnd; > } > if (mask) > vec_mask =3D vec_masks[j]; > @@ -8975,13 +8970,9 @@ vectorizable_store (vec_info *vinfo, > { > new_stmt =3D NULL; > if (grouped_store) > - { > - if (j =3D=3D 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_i= nfo, > + gsi, &result_chain); > > stmt_vec_info next_stmt_info =3D first_stmt_info; > for (i =3D 0; i < vec_num; i++) > @@ -9278,15 +9269,6 @@ vectorizable_store (vec_info *vinfo, > } > } > > - for (i =3D 0; i < group_size; ++i) > - { > - vec oprndsi =3D gvec_oprnds[i]; > - oprndsi.release (); > - } > - oprnds.release (); > - result_chain.release (); > - vec_oprnds.release (); > - > return true; > } > > -- > 2.31.1