From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5882F3858C41; Tue, 10 Oct 2023 14:37:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5882F3858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696948673; bh=NdG2kqTDGwVsZCnoHqR7lhw0FN31dF+74nVBufd1Eys=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WFdaDQcQ0XU5xgKuSzHi7F623J4QrgCn5G0XLfPpMM7rgr3y6vP+kaVjFwf8V8g+g htXPDXxrHf3NBI38E/frf2q7aukSkjrv4KiGu3QCkWpSpGurF1yRcGtazpZdo/LwIj IPNgnXZKdA1iKxFX43ONkO3eFCBz5ZnRAFmrIoyA= 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:37:52 +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 #7 from prathamesh3492 at gcc dot gnu.org --- (In reply to Richard Biener from comment #5) > It seems we have VECTOR_CST_NELTS_PER_PATTERN ({ 9.0e+0, 0.0, 0.0, 0.0 }) > 2 and VECTOR_CST_NPATTERNS =3D=3D 1. And the selector { 1, 0, 1, 2 } has > npatterns =3D=3D 1 and nelts-per-pattern =3D=3D 3. >=20 > /* (1) If SEL is a suitable mask as determined by > valid_mask_for_fold_vec_perm_cst_p, then: > res_npatterns =3D max of npatterns between ARG0, ARG1, and SEL > res_nelts_per_pattern =3D max of nelts_per_pattern between > ARG0, ARG1 and SEL. > (2) If SEL is not a suitable mask, and TYPE is VLS then: > res_npatterns =3D nelts in result vector. > res_nelts_per_pattern =3D 1. > This exception is made so that VLS ARG0, ARG1 and SEL work as before= .=20 > */ > if (valid_mask_for_fold_vec_perm_cst_p (arg0, arg1, sel, reason)) > { > res_npatterns > =3D std::max (VECTOR_CST_NPATTERNS (arg0), > std::max (VECTOR_CST_NPATTERNS (arg1), > sel.encoding ().npatterns ())); >=20 > res_nelts_per_pattern > =3D std::max (VECTOR_CST_NELTS_PER_PATTERN (arg0), > std::max (VECTOR_CST_NELTS_PER_PATTERN (arg1), > sel.encoding ().nelts_per_pattern ())); >=20 > res_nelts =3D res_npatterns * res_nelts_per_pattern; >=20 > this seems to be a case that doesn't fit, so the fix needs to be to > valid_mask_for_fold_vec_perm_cst_p which really looks a bit > unwieldly. valid_mask_for_fold_vec_perm_cst_p returns incorrectly true here, which is being addressed in PR111648 patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-October/631926.html Even if the vectors had integral element type: arg0 =3D arg1 =3D (v4si){ 9, 0, 0, 0 } // encoded as {9, 0, ...} and sel =3D { 1, 0, 1, 2 } // encoded as {1, 0, 1, ...} The pattern in sel {1, 0, 1, ...} would choose elements from arg0, and res would have incorrect encoding with step =3D -9: res =3D { arg0[1], arg0[0], arg0[1], ... }=20 =3D { 0, 9, 0, ... } And res[3] will be incorrectly computed as -9 instead of arg0[2]. However, for floating element types, even if encoding is correct, I assume it will still ICE when trying to derive elements not present in encoding since poly_int_cst can only deal with integral elements ? >=20 > An assert that res_nelts is power-of-two would be nice to add. Sorry, I don't understand. res_nelts for VLA need not be power of 2, since res_nelts_per_pattern can be 3. The encoding for res is chosen to be max of npatterns and max of nelts_per_pattern between arg0, arg1, and sel. Thanks, Prathamesh=