From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 70CAF3858D1E; Wed, 2 Feb 2022 12:06:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70CAF3858D1E From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104334] [12 Regression] Ranger/dom miscompilation Date: Wed, 02 Feb 2022 12:06:18 +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: lto, needs-bisection, wrong-code X-Bugzilla-Severity: blocker X-Bugzilla-Who: jakub at gcc dot gnu.org 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: 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: Wed, 02 Feb 2022 12:06:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104334 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mrs at gcc dot gnu.org, | |rguenth at gcc dot gnu.org, | |rsandifo at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- The difference might be in: 1938 /* Optimize comparisons with constants. */ 1939 if (STATIC_CONSTANT_P (yi.len =3D=3D 1 && yi.val[0] >=3D 0)) 1940 return xi.len =3D=3D 1 && xi.to_uhwi () < (unsigned HOST_WIDE_I= NT) yi.val[0]; 1941 if (STATIC_CONSTANT_P (xi.len =3D=3D 1 && xi.val[0] >=3D 0)) 1942 return yi.len !=3D 1 || yi.to_uhwi () > (unsigned HOST_WIDE_INT) xi.val[0]; 1943 /* Optimize the case of two HWIs. The HWIs are implicitly sign-extended 1944 for precisions greater than HOST_BITS_WIDE_INT, but sign-exten= ding both 1945 values does not change the result. */ 1946 if (__builtin_expect (xi.len + yi.len =3D=3D 2, true)) 1947 { 1948 unsigned HOST_WIDE_INT xl =3D xi.to_uhwi (); 1949 unsigned HOST_WIDE_INT yl =3D yi.to_uhwi (); 1950 return xl < yl; 1951 } Perhaps with LTO STATIC_CONSTANT_P (yi.len && iy.val[0] >=3D 0) is true whi= le without LTO it is false. I'll verify that. Though, xi.len =3D=3D 1, xi.to_uhwi () is 3, yi.val[0] i= s 4 and yi.to_uhwi () is 0. So I think if STATIC_CONSTANT_P is true, it will return 3 < 4, while if it = is false, it will return 3 < 0. Now, the question is, do we consider those wi::lt_p (x, 4, sign) calls inva= lid if 4 is not representable in type, or does the STATIC_CONSTANT_P case need to also check precision, or mask Xi.val[0]? And another question is, the 2, 3, 4 cases handling seems like an optimizat= ion, so wi_fold at line 192 should give the right answer, but it doesn't.=