From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 72ED238582BA; Thu, 25 Jan 2024 08:53:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72ED238582BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706172780; bh=6QbYJtV4IA/zOQaGiCMJ3pQK/qmv6yprVgqxj/DLS8U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OgHd1QgQMgKAPVW7AyZ0ngmFSIYviGp5HweuqP20nwaGWbnRngTqQhVODswF5McU/ daACvkTAGHcCpDCKBLEVe0ifb5s/1i6cHqikWTQKJTTjFMcV76mEaEJaRNhehIEgK1 jQSg+lalPIeO0RzZJXpntwhN0A78fJn+D3s2qeWc= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113576] [14 regression] 502.gcc_r hangs r14-8223-g1c1853a70f9422169190e65e568dcccbce02d95c Date: Thu, 25 Jan 2024 08:52:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D113576 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rsandifo at gcc dot gnu.org --- Comment #11 from Richard Biener --- (In reply to Hongtao Liu from comment #8) > maybe=20 >=20 > diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc > index 1fd957288d4..6d321f9baef 100644 > --- a/gcc/fold-const.cc > +++ b/gcc/fold-const.cc > @@ -8035,6 +8035,9 @@ native_encode_vector_part (const_tree expr, unsigned > char *ptr, int len, > unsigned int extract_elts =3D extract_bytes * elts_per_byte; > for (unsigned int i =3D 0; i < extract_elts; ++i) > { > + /* Don't encode any bit beyond the range of the vector. */ > + if (first_elt + i > count) > + break; Hmm. I think that VECTOR_CST_ELT should have ICEd for out-of-bound element queries but it seems to make up elements for us here. Richard? But yes, we do unsigned int extract_elts =3D extract_bytes * elts_per_byte; and since native_encode_* and native_interpret_* operate on bytes we have difficulties dealing with bit-precision entities with padding. There's either the possibility to fail encoding when that happens or do something else. Note that RTL expansion will do case VECTOR_CST: { tree tmp =3D NULL_TREE;=20 if (VECTOR_MODE_P (mode)) return const_vector_from_tree (exp); scalar_int_mode int_mode; if (is_int_mode (mode, &int_mode)) { tree type_for_mode =3D lang_hooks.types.type_for_mode (int_mode= , 1); if (type_for_mode) tmp =3D fold_unary_loc (loc, VIEW_CONVERT_EXPR, type_for_mode, exp); which I think should always succeed (otherwise it falls back to expanding a CTOR). That means failing to encode/interpret might get into store_constructor which I think will zero a register destination and thus fill padding with zeros. So yeah, something like this looks OK, but I think instead of only testing against 'count' we should also test against TYPE_VECTOR_SUBPARTS (that might be variable, so with known_gt). Would be interesting to see whether this fixes the issue without the now installed patch.=