From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2711B383D020; Mon, 5 Jul 2021 19:25:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2711B383D020 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101335] wrong code at -O2 and above Date: Mon, 05 Jul 2021 19:25:58 +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: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on keywords version short_desc everconfirmed bug_status 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, 05 Jul 2021 19:25:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101335 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-07-05 Keywords| |wrong-code Version|unknown |12.0 Summary|wrong code at -Os and above |wrong code at -O2 and above |on x86_64-linux-gnu | Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski --- Also -fwrapv works around the issue, -fsanitize=3Dundefined does not output= any undefined behavior either. EVRP has the first difference. Before EVRP we had: a.0_1 =3D aD.1942; // -1u _2 =3D ~a.0_1; //0u c_9 =3D (intD.6) _2; //0 _3 =3D c_9 + -10; // -10 d_10 =3D (unsigned intD.9) _3; //-10u if (_2 < d_10) // 0u < -10u which is true But EVRP: Predicate evaluates to: DON'T KNOW folding with relation >=20 Predicate evaluates to: 0 EVRP:hybrid: Second query simplifed stmt Folded into: if (0 !=3D 0) ---- CUT ---- Looks like this value relation is being used but rather it should have just converted to !=3D rather < with the casts happening: Registering value_relation (_3 < c_9) (bb2) at _3 =3D c_9 + -10;=