From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E16173858403; Mon, 4 Dec 2023 13:03:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E16173858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701694988; bh=QferJk35IObfvW38jQ+OUu9kj+PWm31TzZcu1NQMJxo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UaoWYTx/5ny45r4pxS2Kw8a0TFCY5A02whOyIPZokaK0AsSAhuZcgXMarc9g9y+pa cEWf+4v+xz+YeCqpfSxXfk4ZtOvvZAMl5qVRNuWQs0hrThf+Qa1ZhoDeRnGeWeqXZV FroRM4wx/ADAuaGZ6NIZpcMN+5Gp2pkN2noet2gg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/89270] [11/12/13/14 regression] AVR ICE: verify_gimple failed Date: Mon, 04 Dec 2023 13:03:07 +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: 9.0 X-Bugzilla-Keywords: addr-space X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to everconfirmed cc bug_status cf_reconfirmed_on 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=3D89270 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org Ever confirmed|0 |1 CC| |jsm28 at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2023-12-04 --- Comment #12 from Richard Biener --- Confirmed. We have a NOP_EXPR from the 24bit pointer __memx address-space to long int (32bit). That's an extension and we don't know how to do that since POINTERS_EXTEND_UNSIGNED is not defined for AVR. Note that for GIMPLE verification the exception would be #if defined(POINTERS_EXTEND_UNSIGNED) || (TYPE_MODE (rhs1_type) =3D=3D ptr_mode && (TYPE_PRECISION (lhs_type) =3D=3D BITS_PER_WORD /* word_mode */ || (TYPE_PRECISION (lhs_type) =3D=3D GET_MODE_PRECISION (Pmode)))) #endif but that's currently written without address-spaces in mind (because POINTERS_EXTEND_UNSIGNED is defined without address-spaces in mind). I think the "bug" is that the C frontend emits extern const unsigned char __data_load_end; __uint24 top =3D (__uint24) (long int) &__data_load_end; so it inserts the widening to 'long int' here. And that's the fault of convert.cc:convert_to_integer_1 which does /* Convert to an unsigned integer of the correct width first, and from there widen/truncate to the required type. Some targets support t= he coexistence of multiple valid pointer sizes, so fetch the one we n= eed from the type. */ if (!dofold) return build1 (CONVERT_EXPR, type, expr); expr =3D fold_build1 (CONVERT_EXPR, lang_hooks.types.type_for_size (TYPE_PRECISION (intype), 0), expr); return fold_convert (type, expr); using type_for_mode would have yielded the __int24 type here. The code is more or less present since the original version of convert.c I'd argue the most correct way to deal with this is to _remove_ the intermediate conversion done by convert.c since it only papers over possible user errors? The C standard says the only supported conversion is to/from [u]intptr_t, that's probably what the above tried to do. But then it looks like it doesn't achieve its intent. Now, c_common_type_for_size doesn't handle registered_builtin_types like c_common_type_for_mode does, so extending that to cover these fixes the issue as well.=