From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BFE86385701B; Tue, 10 Oct 2023 14:07:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFE86385701B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696946846; bh=M1DwYsTUMN99A3A+lX/lOvRveWn8izDEizoqwgRMIaI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=clpkGgK7E//3xus6TxxO7hsgawCR4wzlJoTEOm3vLDKIzw1XvFAD86JVWLdDuPHkG xAkeGbSs1j7pGrLij5oBLsdOotKhhRmclGQlYjqKbgy9wTDN4PvFigVRJqmGjb/auR msO9oKUXsSCmDi2A5XLUAjRvi57Te5EDxOWjfKzQ= From: "prathamesh3492 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/111754] [14 Regression] ICE: in decompose, at rtl.h:2313 at -O Date: Tue, 10 Oct 2023 14:07:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: prathamesh3492 at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: prathamesh3492 at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111754 --- Comment #6 from prathamesh3492 at gcc dot gnu.org --- (In reply to rguenther@suse.de from comment #4) > On Tue, 10 Oct 2023, prathamesh3492 at gcc dot gnu.org wrote: >=20 > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111754 > >=20 > > --- Comment #3 from prathamesh3492 at gcc dot gnu.org --- > > The issue is that we only support integral vector types in fold_vec_per= m_cst, > > but fail to check for the same before calling it from fold_vec_perm. > > The following tweak fixes the ICE: > >=20 > > diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc > > index 4f8561509ff..a29a8af6d2f 100644 > > --- a/gcc/fold-const.cc > > +++ b/gcc/fold-const.cc > > @@ -10801,7 +10801,8 @@ fold_vec_perm (tree type, tree arg0, tree arg1,= const > > vec_perm_indices &sel) > > return NULL_TREE; > >=20 > > if (TREE_CODE (arg0) =3D=3D VECTOR_CST > > - && TREE_CODE (arg1) =3D=3D VECTOR_CST) > > + && TREE_CODE (arg1) =3D=3D VECTOR_CST > > + && INTEGRAL_TYPE_P (TREE_TYPE (type))) > > return fold_vec_perm_cst (type, arg0, arg1, sel); >=20 > Huh, that looks wrong. I fail to see how the element type matters > at all. IIUC, the element type matters for VLA folding when sel has a stepped seque= nce because in that case we need to derive elements from the encoding using vector_cst_elt / vector_cst_int_elt, and it gets enforced for VLS vectors t= oo because they are handled in unified manner in fold_vec_perm_cst. Another possible approach is to use "VLS exception" in fold_vec_perm_cst to encode all the elements: res_npatterns =3D res_nelts; res_nelts_per_patterns =3D 1 just like we do if valid_mask_for_fold_vec_perm_cst_p returns false. Does the following fix look OK instead ? diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 4f8561509ff..356eb052fbc 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -10642,6 +10642,11 @@ valid_mask_for_fold_vec_perm_cst_p (tree arg0, tree arg1, if (sel_nelts_per_pattern < 3) return true; + /* If SEL contains stepped sequence, ensure that we are dealing with + integral vector_cst. */ + if (!INTEGRAL_TYPE_P (TREE_TYPE (arg0))) + return false; + for (unsigned pattern =3D 0; pattern < sel_npatterns; pattern++) { poly_uint64 a1 =3D sel[pattern + sel_npatterns];=