From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 907F53858420 for ; Mon, 3 Jan 2022 10:40:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 907F53858420 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 75D2C1F38B; Mon, 3 Jan 2022 10:40:23 +0000 (UTC) Received: from murzim.suse.de (murzim.suse.de [10.160.4.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 6CBE5A3B81; Mon, 3 Jan 2022 10:40:23 +0000 (UTC) Date: Mon, 3 Jan 2022 11:40:23 +0100 (CET) From: Richard Biener To: Richard Sandiford cc: Prathamesh Kulkarni , gcc Patches Subject: Re: [2/2] PR96463 -- changes to type checking vec_perm_expr in middle end In-Reply-To: Message-ID: <72p4o95q-697o-1o21-po9r-58r6rq3nq9n@fhfr.qr> References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Mon, 03 Jan 2022 10:40:26 -0000 On Fri, 17 Dec 2021, Richard Sandiford wrote: > Prathamesh Kulkarni writes: > > Hi, > > The attached patch rearranges order of type-check for vec_perm_expr > > and relaxes type checking for > > lhs = vec_perm_expr > > > > when: > > rhs1 == rhs2, > > lhs is variable length vector, > > rhs1 is fixed length vector, > > TREE_TYPE (lhs) == TREE_TYPE (rhs1) > > > > I am not sure tho if this check is correct ? My intent was to capture > > case when vec_perm_expr is used to "extend" fixed length vector to > > it's VLA equivalent. > > VLAness isn't really the issue. We want the same thing to work for > -msve-vector-bits=256, -msve-vector-bits=512, etc., even though the > vectors are fixed-length in that case. > > The principle is that for: > > A = VEC_PERM_EXPR ; > > the requirements are: > > - A, B, C and D must be vectors > - A, B and C must have the same element type > - D must have an integer element type > - A and D must have the same number of elements (NA) > - B and C must have the same number of elements (NB) > > The semantics are that we create a joined vector BC (all elements of B > followed by all element of C) and that: > > A[i] = BC[D[i] % (NB+NB)] > > for 0 ≤ i < NA. > > This operation makes sense even if NA != NB. But note that we don't currently expect NA != NB and the optab just has a single mode. I'd rather go with the simpler patch I posted as reply to the earlier mail rather such large refactoring at this point. Richard. > Thanks, > Richard > > > > > Thanks, > > Prathamesh > > > > diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c > > index 672e384ef09..9f91878c468 100644 > > --- a/gcc/tree-cfg.c > > +++ b/gcc/tree-cfg.c > > @@ -4325,10 +4325,11 @@ verify_gimple_assign_ternary (gassign *stmt) > > break; > > > > case VEC_PERM_EXPR: > > - if (!useless_type_conversion_p (lhs_type, rhs1_type) > > - || !useless_type_conversion_p (lhs_type, rhs2_type)) > > + if (TREE_CODE (rhs1_type) != VECTOR_TYPE > > + || TREE_CODE (rhs2_type) != VECTOR_TYPE > > + || TREE_CODE (rhs3_type) != VECTOR_TYPE) > > { > > - error ("type mismatch in %qs", code_name); > > + error ("vector types expected in %qs", code_name); > > debug_generic_expr (lhs_type); > > debug_generic_expr (rhs1_type); > > debug_generic_expr (rhs2_type); > > @@ -4336,11 +4337,14 @@ verify_gimple_assign_ternary (gassign *stmt) > > return true; > > } > > > > - if (TREE_CODE (rhs1_type) != VECTOR_TYPE > > - || TREE_CODE (rhs2_type) != VECTOR_TYPE > > - || TREE_CODE (rhs3_type) != VECTOR_TYPE) > > + if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE > > + || (TREE_CODE (rhs3) != VECTOR_CST > > + && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE > > + (TREE_TYPE (rhs3_type))) > > + != GET_MODE_BITSIZE (SCALAR_TYPE_MODE > > + (TREE_TYPE (rhs1_type)))))) > > { > > - error ("vector types expected in %qs", code_name); > > + error ("invalid mask type in %qs", code_name); > > debug_generic_expr (lhs_type); > > debug_generic_expr (rhs1_type); > > debug_generic_expr (rhs2_type); > > @@ -4348,15 +4352,18 @@ verify_gimple_assign_ternary (gassign *stmt) > > return true; > > } > > > > - if (maybe_ne (TYPE_VECTOR_SUBPARTS (rhs1_type), > > - TYPE_VECTOR_SUBPARTS (rhs2_type)) > > - || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs2_type), > > - TYPE_VECTOR_SUBPARTS (rhs3_type)) > > - || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs3_type), > > - TYPE_VECTOR_SUBPARTS (lhs_type))) > > + /* Accept lhs = vec_perm_expr if lhs is vector length agnostic, > > + and has same element type as v. */ > > + if (!TYPE_VECTOR_SUBPARTS (lhs_type).is_constant () > > + && operand_equal_p (rhs1, rhs2, 0) > > + && TYPE_VECTOR_SUBPARTS (rhs1_type).is_constant () > > + && TREE_TYPE (lhs_type) == TREE_TYPE (rhs1_type)) > > + return false; > > + > > + if (!useless_type_conversion_p (lhs_type, rhs1_type) > > + || !useless_type_conversion_p (lhs_type, rhs2_type)) > > { > > - error ("vectors with different element number found in %qs", > > - code_name); > > + error ("type mismatch in %qs", code_name); > > debug_generic_expr (lhs_type); > > debug_generic_expr (rhs1_type); > > debug_generic_expr (rhs2_type); > > @@ -4364,21 +4371,21 @@ verify_gimple_assign_ternary (gassign *stmt) > > return true; > > } > > > > - if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE > > - || (TREE_CODE (rhs3) != VECTOR_CST > > - && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE > > - (TREE_TYPE (rhs3_type))) > > - != GET_MODE_BITSIZE (SCALAR_TYPE_MODE > > - (TREE_TYPE (rhs1_type)))))) > > + if (maybe_ne (TYPE_VECTOR_SUBPARTS (rhs1_type), > > + TYPE_VECTOR_SUBPARTS (rhs2_type)) > > + || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs2_type), > > + TYPE_VECTOR_SUBPARTS (rhs3_type)) > > + || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs3_type), > > + TYPE_VECTOR_SUBPARTS (lhs_type))) > > { > > - error ("invalid mask type in %qs", code_name); > > + error ("vectors with different element number found in %qs", > > + code_name); > > debug_generic_expr (lhs_type); > > debug_generic_expr (rhs1_type); > > debug_generic_expr (rhs2_type); > > debug_generic_expr (rhs3_type); > > return true; > > } > > - > > return false; > > > > case SAD_EXPR: > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)