From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 495E8385840F; Wed, 10 Jan 2024 08:57:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 495E8385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704877043; bh=8X3rhb3MtJj882D+0BeIyU4Wl+c5TLtyufk+CO99OYE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m30g088YdUQTB3Kh1DHjr9xU+AgnfGbuwy0Uw+pxSnsbQ4jAsT56YzBDxkQRYb5fr 2bmCc1HGt57mZ8tZ3eC9GEaKerWd3PqvTnUDZMEXPVtUlO0SLqvB7jeVCoSFjYtvuo 0olD1nf2PRVXeD7V+UYU2vvpvYj+nk3L7okVtBrg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/113255] [11/12/13/14 Regression] wrong code with -O2 -mtune=k8 Date: Wed, 10 Jan 2024 08:57:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 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=3D113255 --- Comment #10 from Richard Biener --- Hmm, trying to fix find_base_term isn't enough, init_alias_analysis find_base_value needs to be adjusted as well. One "obvious" mistake there is a missing diff --git a/gcc/alias.cc b/gcc/alias.cc index b2ec4806d22..6aeb2167520 100644 --- a/gcc/alias.cc +++ b/gcc/alias.cc @@ -1492,6 +1492,13 @@ find_base_value (rtx src) { rtx temp, src_0 =3D XEXP (src, 0), src_1 =3D XEXP (src, 1); + /* If both operands of a MINUS are known pointers then the + base is not either of them. */ + if (GET_CODE (src) =3D=3D MINUS + && REG_P (src_0) && REG_POINTER (src_0) + && REG_P (src_1) && REG_POINTER (src_1)) + return 0; + /* If either operand is a REG that is a known pointer, then it is the base. */ if (REG_P (src_0) && REG_POINTER (src_0)) but of course that's not conservative - not having REG_POINTER set doesn't mean it's not a pointer. But even when we assume REG_POINTER is correct the minus operands might not be REG_P. This is really all totally wrong for what it is (pointer analysis on RTL). On RTL we also lost constraints that arithmetic stays within an object. It should likely be scrapped completely and re-done, possibly having SET_DEST_POINTS_TO to be able to put SSA points-to info to SETs (REG_ATTRs are too coarse, but would be possible as well, losing some of the flow sensitivity). Incoming args & frame analysis would need to be implemented of course. As said, I'm not sure analyzing RTL will yield anything good while being conservative - and optimistic points-to is what leads us to these kind of bugs ...=