From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id 1AFC2385770F for ; Thu, 18 May 2023 06:12:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1AFC2385770F 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-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4f00d41df22so11560757e87.1 for ; Wed, 17 May 2023 23:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684390344; x=1686982344; 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=I2a5JVj2u6GuSZJZOAn1989qGhAaAzFqA5Sx+mTPOso=; b=Z1/4Q8GlA4uEUYJ9wG6zJzo8BnWz0yT4vXCSBRWXGql3Y129Us0XeGSRprLTxlqqBY jn6DzDUtQBzkdKF64Hv0Rutu8uAzNyws8NybuJA1fgbUbaXPlTrfVUlRUkjwq251Q17Q BpNFmAAGP6eRHKgYiwiMZBuxWdziegGYvL5miiteVolSnVsFH7hZqP+UQ5g7OHNGvxrT rINAU29eQ4HDC1Juzo/mVLUerNoVbT8z5yELJ7txlcg7Untr6Z1EqHX38RKhP27+QgX3 0nI5pt0ih4LMvhij8yRm0CBMcgm4QP8AcQfCzfBNeLYxA4uzSWtQsfytIDHSOP681EPf MTJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684390344; x=1686982344; 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=I2a5JVj2u6GuSZJZOAn1989qGhAaAzFqA5Sx+mTPOso=; b=CTFKkoExIqWez8yaojFLvC90C0aU97iaEREIuQxjKZ88BIXxWGkrcVq8Tq26tqkdqp 7QvfYWbyybPhvSUkGu27Ad2WzKPLZDant5PIHqIAQfXmy4Z5gTPSomKgd1oBfu5rnKFi 2HwU3lqgwgqel//Gk2f4ras/83NCQYKxzvFegotZAR2ocTZq9cnxLq/NmiUTUPrO8E68 iZ5m5Lw2b1R4I47pknd3dTi+eqDIy5G9OJ+2sXnrOERNHVfTm9psGXKf1YPH38b2i8n6 Q07fPAAvoF54rOTCVMD52SWsbxDrQ2zaEPNUXzgwrUO4pqG4JirPg4F81Az0F+UHuBl8 bATg== X-Gm-Message-State: AC+VfDxtAt29y1gXHG5pDNVrO/ZWbPBm30yONpYn4UIckN5QfiY4XFhr CRkkHAOMpj0Zt4EYvPbX+Lsr+ufT096z0CGhp+Y= X-Google-Smtp-Source: ACHHUZ6eTvfge8noCfhEaFFTdPMQsnTXyRxiPVtf71Yzr2HYbYP0W7t53Uu+P6xuhKhg5aWhzBuFZ6LquqoOJdb21f8= X-Received: by 2002:ac2:5110:0:b0:4f2:147b:7ee with SMTP id q16-20020ac25110000000b004f2147b07eemr626429lfb.20.1684390344083; Wed, 17 May 2023 23:12:24 -0700 (PDT) MIME-Version: 1.0 References: <72a5c5db-bc06-eded-d229-82af34342515@linux.ibm.com> In-Reply-To: From: Richard Biener Date: Thu, 18 May 2023 08:12:11 +0200 Message-ID: Subject: Re: [PATCH 1/2] vect: Refactor code for index == count in vect_transform_slp_perm_load_1 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Wed, May 17, 2023 at 9:19=E2=80=AFAM Kewen.Lin wro= te: > > Hi Richi, > > on 2023/5/17 14:34, Richard Biener wrote: > > On Wed, May 17, 2023 at 8:09=E2=80=AFAM Kewen.Lin = wrote: > >> > >> Hi, > >> > >> This patch is to refactor the handlings for the case (index > >> =3D=3D count) in a loop of vect_transform_slp_perm_load_1, in > >> order to prepare a subsequent adjustment on *nperm. This > >> patch doesn't have any functional changes. > > > > The diff is impossible to be reviewed - can you explain the > > refactoring you have done or also attach a patch more clearly > > showing what you change? > > Sorry, I should have made it more clear. > It mainly to combine these two hunks: > > if (index =3D=3D count && !noop_p) > { > // A ... > // ++*n_perms; > } > > if (index =3D=3D count) > { > if (!analyze_only) > { > if (!noop_p) > // B1 ... > > // B2 ... > > for ... > { > if (!noop_p) > // B3 building VEC_PERM_EXPR > else > // B4 building nothing (no uses for B2 and its seq) > } > } > // B5 > } > > The former can be part of the latter, so it becomes to: > > if (index =3D=3D count) > { > if (!noop_p) > { > // A ... > // ++*n_perms; > > if (!analyze_only) > { > // B1 ... > // B2 ... > for ... > // B3 building VEC_PERM_EXPR > } > } > else if (!analyze_only) > { > // no B2 since no any further uses here. > for ... > // B4 building nothing > } > // B5 ... > } Ah, thanks - that made reviewing easy. 1/2 is OK for trunk. Thanks, Richard. > But it's mainly the basic for the subsequent patch for consistent n_perms= calculation, > the patch 2/2 is to make it further become to: > > if (index =3D=3D count) > { > if (!noop_p) > { > // A ... > > if (!analyze_only) > // B1 ... > > // B2 ... (trivial computations during analyze_only or not) > > for ... > { > // ++*n_perms; (now n_perms is consistent with building = VEC_PERM_EXPR) > if (analyze_only) > continue; > // B3 building VEC_PERM_EXPR > } > } > else if (!analyze_only) > { > // no B2 since no any further uses here. > for ... > // B4 building nothing > } > // B5 ... > } > > BR, > Kewen > > > > > >> Bootstrapped and regtested on x86_64-redhat-linux, > >> aarch64-linux-gnu and powerpc64{,le}-linux-gnu. > >> > >> BR, > >> Kewen > >> ----- > >> gcc/ChangeLog: > >> > >> * tree-vect-slp.cc (vect_transform_slp_perm_load_1): Refactor = the > >> handling on the case index =3D=3D count. > >> --- > >> gcc/tree-vect-slp.cc | 89 ++++++++++++++++++++++---------------------= - > >> 1 file changed, 44 insertions(+), 45 deletions(-) > >> > >> diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc > >> index 3b7a21724ec..e5c9d7e766e 100644 > >> --- a/gcc/tree-vect-slp.cc > >> +++ b/gcc/tree-vect-slp.cc > >> @@ -8230,59 +8230,50 @@ vect_transform_slp_perm_load_1 (vec_info *vinf= o, slp_tree node, > >> noop_p =3D false; > >> mask[index++] =3D mask_element; > >> > >> - if (index =3D=3D count && !noop_p) > >> + if (index =3D=3D count) > >> { > >> - indices.new_vector (mask, second_vec_index =3D=3D -1 ? 1 : 2= , nunits); > >> - if (!can_vec_perm_const_p (mode, mode, indices)) > >> + if (!noop_p) > >> { > >> - if (dump_p) > >> + indices.new_vector (mask, second_vec_index =3D=3D -1 ? 1= : 2, nunits); > >> + if (!can_vec_perm_const_p (mode, mode, indices)) > >> { > >> - dump_printf_loc (MSG_MISSED_OPTIMIZATION, > >> - vect_location, > >> - "unsupported vect permute { "); > >> - for (i =3D 0; i < count; ++i) > >> + if (dump_p) > >> { > >> - dump_dec (MSG_MISSED_OPTIMIZATION, mask[i]); > >> - dump_printf (MSG_MISSED_OPTIMIZATION, " "); > >> + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_l= ocation, > >> + "unsupported vect permute { "); > >> + for (i =3D 0; i < count; ++i) > >> + { > >> + dump_dec (MSG_MISSED_OPTIMIZATION, mask[i]); > >> + dump_printf (MSG_MISSED_OPTIMIZATION, " "); > >> + } > >> + dump_printf (MSG_MISSED_OPTIMIZATION, "}\n"); > >> } > >> - dump_printf (MSG_MISSED_OPTIMIZATION, "}\n"); > >> + gcc_assert (analyze_only); > >> + return false; > >> } > >> - gcc_assert (analyze_only); > >> - return false; > >> - } > >> > >> - ++*n_perms; > >> - } > >> + ++*n_perms; > >> > >> - if (index =3D=3D count) > >> - { > >> - if (!analyze_only) > >> - { > >> - tree mask_vec =3D NULL_TREE; > >> - > >> - if (! noop_p) > >> - mask_vec =3D vect_gen_perm_mask_checked (vectype, indi= ces); > >> + if (!analyze_only) > >> + { > >> + tree mask_vec =3D vect_gen_perm_mask_checked (vectyp= e, indices); > >> > >> - if (second_vec_index =3D=3D -1) > >> - second_vec_index =3D first_vec_index; > >> + if (second_vec_index =3D=3D -1) > >> + second_vec_index =3D first_vec_index; > >> > >> - for (unsigned int ri =3D 0; ri < nvectors_per_build; ++r= i) > >> - { > >> - /* Generate the permute statement if necessary. */ > >> - tree first_vec =3D dr_chain[first_vec_index + ri]; > >> - tree second_vec =3D dr_chain[second_vec_index + ri]; > >> - gimple *perm_stmt; > >> - if (! noop_p) > >> + for (unsigned int ri =3D 0; ri < nvectors_per_build;= ++ri) > >> { > >> - gassign *stmt =3D as_a (stmt_info->s= tmt); > >> + /* Generate the permute statement if necessary. = */ > >> + tree first_vec =3D dr_chain[first_vec_index + ri= ]; > >> + tree second_vec =3D dr_chain[second_vec_index + = ri]; > >> + gassign *stmt =3D as_a (stmt_info->st= mt); > >> tree perm_dest > >> =3D vect_create_destination_var (gimple_assign= _lhs (stmt), > >> vectype); > >> perm_dest =3D make_ssa_name (perm_dest); > >> - perm_stmt > >> + gimple *perm_stmt > >> =3D gimple_build_assign (perm_dest, VEC_PERM_E= XPR, > >> - first_vec, second_vec, > >> - mask_vec); > >> + first_vec, second_vec, = mask_vec); > >> vect_finish_stmt_generation (vinfo, stmt_info, p= erm_stmt, > >> gsi); > >> if (dce_chain) > >> @@ -8290,15 +8281,23 @@ vect_transform_slp_perm_load_1 (vec_info *vinf= o, slp_tree node, > >> bitmap_set_bit (used_defs, first_vec_index += ri); > >> bitmap_set_bit (used_defs, second_vec_index = + ri); > >> } > >> + > >> + /* Store the vector statement in NODE. */ > >> + SLP_TREE_VEC_STMTS (node) [vect_stmts_counter++] > >> + =3D perm_stmt; > >> } > >> - else > >> - { > >> - /* If mask was NULL_TREE generate the requested > >> - identity transform. */ > >> - perm_stmt =3D SSA_NAME_DEF_STMT (first_vec); > >> - if (dce_chain) > >> - bitmap_set_bit (used_defs, first_vec_index + r= i); > >> - } > >> + } > >> + } > >> + else if (!analyze_only) > >> + { > >> + for (unsigned int ri =3D 0; ri < nvectors_per_build; ++r= i) > >> + { > >> + tree first_vec =3D dr_chain[first_vec_index + ri]; > >> + /* If mask was NULL_TREE generate the requested > >> + identity transform. */ > >> + gimple *perm_stmt =3D SSA_NAME_DEF_STMT (first_vec); > >> + if (dce_chain) > >> + bitmap_set_bit (used_defs, first_vec_index + ri); > >> > >> /* Store the vector statement in NODE. */ > >> SLP_TREE_VEC_STMTS (node)[vect_stmts_counter++] =3D = perm_stmt; > >> -- > >> 2.39.1 > >