From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 038C7388CC02; Mon, 12 Jul 2021 15:35:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 038C7388CC02 From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101335] [12 Regression] wrong code at -O2 and above (casts between signed and unsigned) by r12-1796 Date: Mon, 12 Jul 2021 15:35:21 +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: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: amacleod at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.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 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: Mon, 12 Jul 2021 15:35:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101335 --- Comment #2 from Andrew Macleod --- yeah, it because we have been treating casts to objects of the same precisi= on as equivalences. This normally works fine, but in this case we have c_9 =3D (int)_2 c_9 =3D=3D _2 _3 =3D c_9 - 10 so _3 is < c_9 d_10 =3D (unsigned)_3 d_10 =3D=3D _3=20 if (_2 < d_10) with the equivalences, it now thinks that d_10 < _2. So I have to either not allow compounding relations thru casting equivalenc= es (painful), or something else. -fwrapv make its work because we don't register the relation _3 < c_9 if wrapping is on. I'm running an experiment... When the recomputation code was introduced, it completely eliminated the need to track downcasts. It seems that removing a= ll equivalences between casts doesn't miss anything either, so perhaps this ol= der bit isn't needed anymore. I'm running it thru the testsuite now...=