From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0B04A389367B; Tue, 12 Jan 2021 18:39:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B04A389367B From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/98597] [11 Regression] ICE in print_mem_ref since r11-6508-gabb1b6058c09a7c0 Date: Tue, 12 Jan 2021 18:39:38 +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: 11.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 18:39:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98597 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |law at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- The bug is clear: const bool addr =3D TREE_CODE (arg) =3D=3D ADDR_EXPR; if (addr) { arg =3D TREE_OPERAND (arg, 0); ... } makes arg sometimes pointer and sometimes what the pointer points to (which= can be another pointer or something completely different). So obviously tree arg_type =3D TREE_TYPE (TREE_TYPE (arg)); can't work reliably. Either the arg =3D TREE_OPERAND (arg, 0); should be done only if byte_off = =3D=3D 0, or everything else that uses TREE_TYPE (TREE_TYPE (arg)) needs to be change= d to do something different based on whether addr is true or false. I'd note that having the same variable represent different levels of indirection in the same code depending on some circumstances is a maintaina= nce nightmare. E.g. instead of having a bool whether arg was originally ADDR_EXPR or not, = it might be better to keep arg as it is and have another tree that would repre= sent what arg points to if it is ADDR_EXPR, otherwise NULL_TREE.=