From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 9237A3856DD2 for ; Wed, 25 May 2022 19:03:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9237A3856DD2 Received: by mail-ed1-x536.google.com with SMTP id j4so23759531edq.6 for ; Wed, 25 May 2022 12:03:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=P79QLxAk50d969lY+apRefTJRFuqvBcqDoj7KqdUeu8=; b=svBNb7knrEYSGJBXj/d+/GUItVtr9/HFgkG89+Je8Z1oBakDGAcQ2ZczPqDuXjqk9t AIPNKUx3UAKo7EZc7nrNtswpr79qEAhM+9lz/n3OD8Rew8q+oDkXQvxEnnZT0dVmyE/2 Vu2rOLus0BIoUgYIljdlaGhRqXZaJeoin/fO3NnqDKZAeu6Nwnxadj/AKHWW8nzaF5E2 6/0Wr0MW5O7fMWe5XixlOWEUXQOQ8fNWoYgkMZPRfyLh0t26twcvZP3psjaxOtWdvrm8 38ft7r7MFzsRGNWIPdakiXxr0RRX2h7JrVqamxfn5j1ibBLSVswWrbcTIrcKLkB2DBdd 5sOw== X-Gm-Message-State: AOAM5312xXpLwPF33I/YfC29pnRtIezFXzLPzYA9t10dg/Jsz5cxuIgx zUK3g93x484x8dAkmF+aWxpWgTH6tsv7kMiZWlBc5A== X-Google-Smtp-Source: ABdhPJwk0b/9SbiK0f8m2htV+QUIuAPaA4/U+SwN/H9UOAe6KFs5FYls94PEi4egdlxOXbh/JuOpms0moSQJiCFrgQM= X-Received: by 2002:a05:6402:2c3:b0:42a:ad46:aa33 with SMTP id b3-20020a05640202c300b0042aad46aa33mr35927341edx.385.1653505393312; Wed, 25 May 2022 12:03:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Prathamesh Kulkarni Date: Thu, 26 May 2022 00:32:37 +0530 Message-ID: Subject: Re: [0/9] [middle-end] Add param to vec_perm_const hook to specify mode of input operand To: Richard Biener Cc: gcc Patches , Richard Sandiford Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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-List-Received-Date: Wed, 25 May 2022 19:03:17 -0000 On Wed, 25 May 2022 at 18:27, Richard Biener w= rote: > > On Tue, May 24, 2022 at 9:22 PM Prathamesh Kulkarni via Gcc-patches > wrote: > > > > On Tue, 24 May 2022 at 14:50, Richard Sandiford > > wrote: > > > > > > Prathamesh Kulkarni writes: > > > > diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi > > > > index c5006afc00d..0a3c733ada9 100644 > > > > --- a/gcc/doc/tm.texi > > > > +++ b/gcc/doc/tm.texi > > > > @@ -6088,14 +6088,18 @@ for the given scalar type @var{type}. @var= {is_packed} is false if the scalar > > > > access using @var{type} is known to be naturally aligned. > > > > @end deftypefn > > > > > > > > -@deftypefn {Target Hook} bool TARGET_VECTORIZE_VEC_PERM_CONST (mac= hine_mode @var{mode}, rtx @var{output}, rtx @var{in0}, rtx @var{in1}, const= vec_perm_indices @var{&sel}) > > > > +@deftypefn {Target Hook} bool TARGET_VECTORIZE_VEC_PERM_CONST (mac= hine_mode @var{mode}, machine_mode @var{op_mode}, rtx @var{output}, rtx @va= r{in0}, rtx @var{in1}, const vec_perm_indices @var{&sel}) > > > > This hook is used to test whether the target can permute up to two > > > > -vectors of mode @var{mode} using the permutation vector @code{sel}= , and > > > > -also to emit such a permutation. In the former case @var{in0}, @v= ar{in1} > > > > -and @var{out} are all null. In the latter case @var{in0} and @var= {in1} are > > > > -the source vectors and @var{out} is the destination vector; all th= ree are > > > > -operands of mode @var{mode}. @var{in1} is the same as @var{in0} i= f > > > > -@var{sel} describes a permutation on one vector instead of two. > > > > +vectors of mode @var{op_mode} using the permutation vector @code{s= el}, > > > > +producing a vector of mode @var{mode}.The hook is also used to emi= t such > > > > > > Should be two spaces between =E2=80=9C@var{mode}.=E2=80=9D and =E2=80= =9CThe=E2=80=9D. > > > > > > > +a permutation. > > > > + > > > > +When the hook is being used to test whether the target supports a = permutation, > > > > +@var{in0}, @var{in1}, and @var{out} are all null.When the hook is = being used > > > > > > Same here: missing spaces before =E2=80=9CWhen=E2=80=9D. > > > > > > > +to emit a permutation, @var{in0} and @var{in1} are the source vect= ors of mode > > > > +@var{op_mode} and @var{out} is the destination vector of mode @var= {mode}. > > > > +@var{in1} is the same as @var{in0} if @var{sel} describes a permut= ation on one > > > > +vector instead of two. > > > > > > > > Return true if the operation is possible, emitting instructions fo= r it > > > > if rtxes are provided. > > > > diff --git a/gcc/match.pd b/gcc/match.pd > > > > index f5efa77560c..f2a527d9c42 100644 > > > > --- a/gcc/match.pd > > > > +++ b/gcc/match.pd > > > > @@ -7596,6 +7596,8 @@ and, > > > > (with > > > > { > > > > tree op0 =3D @0, op1 =3D @1, op2 =3D @2; > > > > + machine_mode result_mode =3D TYPE_MODE (type); > > > > + machine_mode op_mode =3D TYPE_MODE (TREE_TYPE (op0)); > > > > > > > > /* Build a vector of integers from the tree mask. */ > > > > vec_perm_builder builder; > > > > @@ -7703,12 +7705,12 @@ and, > > > > 2-argument version. */ > > > > tree oldop2 =3D op2; > > > > if (sel.ninputs () =3D=3D 2 > > > > - || can_vec_perm_const_p (TYPE_MODE (type), sel, false)= ) > > > > + || can_vec_perm_const_p (result_mode, op_mode, sel, fa= lse)) > > > > op2 =3D vec_perm_indices_to_tree (TREE_TYPE (op2), sel)= ; > > > > else > > > > { > > > > vec_perm_indices sel2 (builder, 2, nelts); > > > > - if (can_vec_perm_const_p (TYPE_MODE (type), sel2, fal= se)) > > > > + if (can_vec_perm_const_p (result_mode, op_mode, sel2,= false)) > > > > op2 =3D vec_perm_indices_to_tree (TREE_TYPE (op2), = sel2); > > > > else > > > > /* Not directly supported with either encoding, > > > > > > Please replace the use of TYPE_MODE here: > > > > > > /* See if the permutation is performing a single element > > > insert from a CONSTRUCTOR or constant and use a BIT_INSERT= _EXPR > > > in that case. But only if the vector mode is supported, > > > otherwise this is invalid GIMPLE. */ > > > if (TYPE_MODE (type) !=3D BLKmode > > > > > > as well. > > > > > > OK with those changes, thanks. > > Thanks, committed the patch in ae8decf1d2b8329af59592b4fa78ee8dfab3ba5e= . > > So the present state allows to ask can_vec_perm_const_p but the > implementation asks for > > 431 if (direct_optab_handler (vec_perm_optab, mode) !=3D > CODE_FOR_nothing) > 432 return true; > > which then breaks. Also the VEC_PERMs are not yet valid. Any reason thi= s > was committed half-way through the review process of the series? Hi Richard, I am very sorry about that. I thought the patch was approved, and committed it after testing on x86_64 and aarch64. Should I revert it ? Um sorry to ask a silly question -- I am not sure why does the patch break the above condition ? The patch still passes mode to direct_optab_handler as before, and IIUC does not affect modes for vec_perm_optab, so it shouldn't affect the call to direct_optab_handler above ? Thanks, Prathamesh > > At least I have a user in the vectorizer ready - allowing more permutes > from existing vectors (of different sizes now) to be SLP vectorized. > > Thanks, > Richard. > > > Thanks, > > Prathamesh > > > > > > Richard