From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id A84D53858410 for ; Fri, 17 Dec 2021 11:07:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A84D53858410 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 59C4D1435; Fri, 17 Dec 2021 03:07:51 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB4213F5A1; Fri, 17 Dec 2021 03:07:50 -0800 (PST) From: Richard Sandiford To: Prathamesh Kulkarni Mail-Followup-To: Prathamesh Kulkarni , gcc Patches , Richard Biener , richard.sandiford@arm.com Cc: gcc Patches , Richard Biener Subject: Re: [2/2] PR96463 -- changes to type checking vec_perm_expr in middle end References: Date: Fri, 17 Dec 2021 11:07:49 +0000 In-Reply-To: (Prathamesh Kulkarni's message of "Fri, 17 Dec 2021 15:35:12 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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 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: Fri, 17 Dec 2021 11:07:53 -0000 Prathamesh Kulkarni writes: > Hi, > The attached patch rearranges order of type-check for vec_perm_expr > and relaxes type checking for > lhs =3D vec_perm_expr > > when: > rhs1 =3D=3D rhs2, > lhs is variable length vector, > rhs1 is fixed length vector, > TREE_TYPE (lhs) =3D=3D 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=3D256, -msve-vector-bits=3D512, etc., even though the vectors are fixed-length in that case. The principle is that for: A =3D 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] =3D BC[D[i] % (NB+NB)] for 0 =E2=89=A4 i < NA. This operation makes sense even if NA !=3D NB. 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; >=20=20 > 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) !=3D VECTOR_TYPE > + || TREE_CODE (rhs2_type) !=3D VECTOR_TYPE > + || TREE_CODE (rhs3_type) !=3D 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; > } >=20=20 > - if (TREE_CODE (rhs1_type) !=3D VECTOR_TYPE > - || TREE_CODE (rhs2_type) !=3D VECTOR_TYPE > - || TREE_CODE (rhs3_type) !=3D VECTOR_TYPE) > + if (TREE_CODE (TREE_TYPE (rhs3_type)) !=3D INTEGER_TYPE > + || (TREE_CODE (rhs3) !=3D VECTOR_CST > + && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE > + (TREE_TYPE (rhs3_type))) > + !=3D 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; > } >=20=20 > - 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 =3D vec_perm_expr if lhs is vector lengt= h 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) =3D=3D TREE_TYPE (rhs1_type))=20 > + 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; > } >=20=20 > - if (TREE_CODE (TREE_TYPE (rhs3_type)) !=3D INTEGER_TYPE > - || (TREE_CODE (rhs3) !=3D VECTOR_CST > - && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE > - (TREE_TYPE (rhs3_type))) > - !=3D 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; >=20=20 > case SAD_EXPR: