From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 7D4B13858D1E for ; Wed, 19 Apr 2023 10:47:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D4B13858D1E 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-x233.google.com with SMTP id y24so5908140ljm.6 for ; Wed, 19 Apr 2023 03:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681901219; x=1684493219; 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=90nvIyUjpG3OUHcbFPDHy4HzDo2fBPFzgKrtT7a6bEQ=; b=BjNW30LhNvvQCGQc5jb3on0PsAfSyVnlzPAySMF2jGFpIRb6PMJMa2MljKPnk+uxzD YbK/bH3an2mOhcxQB1gZ2O+/oJnac/afkaPjJzKBpoh639vxylItVx6OsMqEszOCLg9J aVGm/tJ0KR6oC5YM9o0D6Fj8ukJnqUrq5CBIyiu4pgYRWxPbb3dEPvwVjCXSQEU7Axol LA4n5WjzvB6YDUpSdD/9Ai8BD9jKn4Dw/lnB7u/3C2bmgUaMTcZlM0bL/BZzp/B/eY5e Shc3zMApT86JLo6fdDEMfYzXzTUncuUtIdj2vZRbQzcaVQPGkIPF416uAjdN125sYtpb M5Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681901219; x=1684493219; 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=90nvIyUjpG3OUHcbFPDHy4HzDo2fBPFzgKrtT7a6bEQ=; b=GPDbtcT25TY13Qz1nKQFCAp1WsL0X1H2G6o8oPxesuHTmcHeUhylGCQzcBHKMNlb6y xSCYxNq6xSpyknMISlu6d6Xim2i+R2OFsKXfAoBaOz1aChiIaPulbXV0aVp9pC0zVZdG zmNhQVQobH+PidryBM3aW0U05swzoSK+RhqhXfTmBQ5Bt87fHLZEOBul/dKaa5BGypbb twNqRpw5PqNYE+tCoYAlWCmUp08GrSHDJwmo9OQKLdRShz1bfIWAz5RiIAaB8iH7Adir ieWlc2SoMsZI0sMJCjhTeILjmf6kYc59yleYyN3eIEzDnYGAq9mV3IeLJ+bVGpAmEa7A 9tqw== X-Gm-Message-State: AAQBX9foRURUC7JQcPc/IJzWWNMx1PsMF0XrYhFNOQKjs4qOkt5J2JPP pTLps6Ao5nonmRTNvETCImV1lemclGDJpY9lbL4= X-Google-Smtp-Source: AKy350bwZjSBMHibcZMzJNMXjeuZaJ2Ba1XYsutuFmwAG4Hu1ehgD5Whq7cBGgi6nXjdEk3lPqC93UUgRnzCCww4SyY= X-Received: by 2002:a2e:8356:0:b0:2a8:bc46:6ba1 with SMTP id l22-20020a2e8356000000b002a8bc466ba1mr1776995ljh.3.1681901218804; Wed, 19 Apr 2023 03:46:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Wed, 19 Apr 2023 12:45:51 +0200 Message-ID: Subject: Re: [match.pd] [SVE] Add pattern to transform svrev(svrev(v)) --> v To: Prathamesh Kulkarni Cc: gcc Patches , Richard Sandiford Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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, Apr 19, 2023 at 11:21=E2=80=AFAM Prathamesh Kulkarni wrote: > > On Tue, 11 Apr 2023 at 19:36, Prathamesh Kulkarni > wrote: > > > > On Tue, 11 Apr 2023 at 14:17, Richard Biener wrote: > > > > > > On Wed, Apr 5, 2023 at 10:39=E2=80=AFAM Prathamesh Kulkarni via Gcc-p= atches > > > wrote: > > > > > > > > Hi, > > > > For the following test: > > > > > > > > svint32_t f(svint32_t v) > > > > { > > > > return svrev_s32 (svrev_s32 (v)); > > > > } > > > > > > > > We generate 2 rev instructions instead of nop: > > > > f: > > > > rev z0.s, z0.s > > > > rev z0.s, z0.s > > > > ret > > > > > > > > The attached patch tries to fix that by trying to recognize the fol= lowing > > > > pattern in match.pd: > > > > v1 =3D VEC_PERM_EXPR (v0, v0, mask) > > > > v2 =3D VEC_PERM_EXPR (v1, v1, mask) > > > > --> > > > > v2 =3D v0 > > > > if mask is { nelts - 1, nelts - 2, nelts - 3, ... } > > > > > > > > Code-gen with patch: > > > > f: > > > > ret > > > > > > > > Bootstrap+test passes on aarch64-linux-gnu, and SVE bootstrap in pr= ogress. > > > > Does it look OK for stage-1 ? > > > > > > I didn't look at the patch but tree-ssa-forwprop.cc:simplify_permutat= ion should > > > handle two consecutive permutes with the is_combined_permutation_iden= tity > > > which might need tweaking for VLA vectors > > Hi Richard, > > Thanks for the suggestions. The attached patch modifies > > is_combined_permutation_identity > > to recognize the above pattern. > > Does it look OK ? > > Bootstrap+test in progress on aarch64-linux-gnu and x86_64-linux-gnu. > Hi, > ping https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615502.html Can you instead of def_stmt pass in a bool whether rhs1 is equal to rhs2 and amend the function comment accordingly, say, tem =3D VEC_PERM ; res =3D VEC_PERM ; SAME_P specifies whether op0 and op1 compare equal. */ + if (def_stmt) + gcc_checking_assert (is_gimple_assign (def_stmt) + && gimple_assign_rhs_code (def_stmt) =3D=3D VEC_PE= RM_EXPR); this is then unnecessary mask =3D fold_ternary (VEC_PERM_EXPR, TREE_TYPE (mask1), mask1, mask1, m= ask2); + + /* For VLA masks, check for the following pattern: + v1 =3D VEC_PERM_EXPR (v0, v0, mask) + v2 =3D VEC_PERM_EXPR (v1, v1, mask) + --> + v2 =3D v0 you are not using 'mask' so please defer fold_ternary until after your special-case. + if (operand_equal_p (mask1, mask2, 0) + && !VECTOR_CST_NELTS (mask1).is_constant () + && def_stmt + && operand_equal_p (gimple_assign_rhs1 (def_stmt), + gimple_assign_rhs2 (def_stmt), 0)) + { + vec_perm_builder builder; + if (tree_to_vec_perm_builder (&builder, mask1)) + { + poly_uint64 nelts =3D TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask1)); + vec_perm_indices sel (builder, 1, nelts); + if (sel.series_p (0, 1, nelts - 1, -1)) + return 1; + } + return 0; I'm defering to Richard whether this is the correct way to check for a vect= or reversing mask (I wonder how constructing such mask is even possible) Richard. > Thanks, > Prathamesh > > > > Thanks, > > Prathamesh > > > > > > Richard. > > > > > > > > > > > Thanks, > > > > Prathamesh